summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorkrc <unknown>2003-08-19 22:04:54 +0000
committerkrc <unknown>2003-08-19 22:04:54 +0000
commita465e8bda2a03163fa45976c531307faeea76490 (patch)
treef244fca66c65ad20e8fac7a9d62b92113e1a7755 /ghc
parent5c15e80ba77d4e30a84578df95ad32e471b0ff8c (diff)
downloadhaskell-a465e8bda2a03163fa45976c531307faeea76490.tar.gz
[project @ 2003-08-19 22:04:54 by krc]
Added correct parsing of external calls. External calls are assumed to be static C calls, but this assumption should always hold since compiling to External Core will fail for programs that contain any other kind of external call. Added correct parsing of the null-pointer literal (0::GHCziPrim.Addrzh) -- this caused an "unknown integer literal type" error before.
Diffstat (limited to 'ghc')
-rw-r--r--ghc/compiler/parser/ParserCore.y12
1 files changed, 9 insertions, 3 deletions
diff --git a/ghc/compiler/parser/ParserCore.y b/ghc/compiler/parser/ParserCore.y
index 6a7fb1d822..dd438b1413 100644
--- a/ghc/compiler/parser/ParserCore.y
+++ b/ghc/compiler/parser/ParserCore.y
@@ -1,6 +1,8 @@
{
module ParserCore ( parseCore ) where
+import ForeignCall
+
import HsCore
import RdrHsSyn
import HsSyn
@@ -199,8 +201,10 @@ exp :: { UfExpr RdrName }
"InlineCall" -> UfNote UfInlineCall $3
"InlineMe" -> UfNote UfInlineMe $3
}
--- | '%external' STRING aty { External $2 $3 }
-
+ | '%external' STRING aty { UfFCall (ForeignCall.CCall
+ (CCallSpec (StaticTarget
+ (mkFastString $2))
+ CCallConv (PlaySafe False))) $3 }
alts1 :: { [UfAlt RdrName] }
: alt { [$1] }
| alt ';' alts1 { $1:$3 }
@@ -264,6 +268,7 @@ convIntLit i (HsTyVar n)
| n == intPrimRdrName = MachInt i
| n == wordPrimRdrName = MachWord i
| n == charPrimRdrName = MachChar (fromInteger i)
+ | n == addrPrimRdrName && i == 0 = MachNullAddr
convIntLit i aty
= pprPanic "Unknown integer literal type" (ppr aty $$ ppr intPrimRdrName)
@@ -275,12 +280,13 @@ convRatLit i aty
= pprPanic "Unknown rational literal type" (ppr aty $$ ppr intPrimRdrName)
-wordPrimRdrName, intPrimRdrName, floatPrimRdrName, doublePrimRdrName :: RdrName
+wordPrimRdrName, intPrimRdrName, floatPrimRdrName, doublePrimRdrName, addrPrimRdrName :: RdrName
wordPrimRdrName = nameRdrName wordPrimTyConName
intPrimRdrName = nameRdrName intPrimTyConName
charPrimRdrName = nameRdrName charPrimTyConName
floatPrimRdrName = nameRdrName floatPrimTyConName
doublePrimRdrName = nameRdrName doublePrimTyConName
+addrPrimRdrName = nameRdrName addrPrimTyConName
happyError :: P a
happyError s l = failP (show l ++ ": Parse error\n") (take 100 s) l