Changeset 15297 for src/Pugs/Compile.hs
- Timestamp:
- 02/18/07 15:59:02 (21 months ago)
- Files:
-
- 1 modified
-
src/Pugs/Compile.hs (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Compile.hs
r15296 r15297 1 {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fno-warn-orphans -funbox-strict-fields -cpp -fno-warn-deprecations -fallow-overlapping-instances -foverloaded-strings#-}1 {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fno-warn-orphans -funbox-strict-fields -cpp -fno-warn-deprecations -fallow-overlapping-instances #-} 2 2 3 3 {-| … … 89 89 decls <- eachM cvList $ \(i, cv) -> do 90 90 compile (("&*END_" ++ show i), cv) :: Comp [PIL_Decl] 91 compile ("&*END" :: String, concat decls)91 compile ("&*END", concat decls) 92 92 canCompile ((_:twigil:_), _) | not (isAlphaNum twigil) = return [] 93 93 canCompile (name, [(_, sym)]) = do … … 186 186 -- XXX - kludge. 187 187 decl = App (_Var func) Nothing [(Val (VStr pkg))] 188 func = "&" ++ (capitalize (cast sym)) ++ "::_create"188 func = "&" ++ (capitalize sym) ++ "::_create" 189 189 capitalize [] = [] 190 190 capitalize (c:cs) = toUpper c:cs … … 287 287 -- XXX: pragmas? 288 288 compile (Var name) = return $ _PVar name 289 compile (Syn syn exps) | sigil:"::()" <- cast syn= do289 compile (Syn (sigil:"::()") exps) = do 290 290 compile $ App (_Var "&Pugs::Internals::symbolic_deref") Nothing $ 291 (Val . _VStr $ sigil:""):exps292 compile (App (Var var) (Just inv) args) | var == cast (__"&goto")= do291 (Val . VStr $ sigil:""):exps 292 compile (App (Var var) (Just inv) args) | var == cast "&goto" = do 293 293 cxt <- askTCxt 294 294 funC <- compile inv … … 325 325 compile (Syn "\\[]" exps) = do 326 326 compile (App (_Var "&circumfix:[]") Nothing exps) 327 compile (Syn syn exps) | name@(sigil:"{}") <- cast syn,(sigil ==) `any` "$@%&" = do327 compile (Syn name@(sigil:"{}") exps) | (sigil ==) `any` "$@%&" = do 328 328 compile (App (_Var $ "&circumfix:" ++ name) Nothing exps) 329 329 compile (Syn "\\{}" exps) = do … … 338 338 (lhsC, rhsC) <- enterLValue $ compile exps 339 339 return $ PBind [lhsC] rhsC 340 compile (Syn syn [lhs, exp]) | last (cast syn)== '=' = do341 let op = "&infix:" ++ init (cast syn)340 compile (Syn syn [lhs, exp]) | last syn == '=' = do 341 let op = "&infix:" ++ init syn 342 342 compile $ Syn "=" [lhs, App (_Var op) Nothing [lhs, exp]] 343 343 compile (Syn "but" [obj, block]) = … … 363 363 condC <- enter (CxtItem $ mkType "Bool") $ compile cond 364 364 bodyC <- enter CxtVoid $ compile body 365 funC <- compile (_Var $ "&statement_control:" ++ castname)365 funC <- compile (_Var $ "&statement_control:" ++ name) 366 366 return . PStmt . PExp $ PApp cxt funC Nothing [pBlock condC, bodyC] 367 367 compLoop exp = compError exp … … 373 373 compConditional (Syn name exps) = do 374 374 [condC, trueC, falseC] <- compile exps 375 funC <- compile $ _Var ("&statement_control:" ++ castname)375 funC <- compile $ _Var ("&statement_control:" ++ name) 376 376 cxt <- askTCxt 377 377 return $ PApp cxt funC Nothing [condC, PThunk trueC, PThunk falseC]
