Changeset 8153 for src/Pugs/Compile

Show
Ignore:
Timestamp:
12/10/05 13:24:15 (3 years ago)
Author:
gaal
Message:

* Refactor Cxt, Pos, and Prag nodes in Exp to a unified Ann

(for Annotation) type. This should ease work on lexical pragmas.

Location:
src/Pugs/Compile
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Compile/Haskell.hs

    r5890 r8153  
    6565    argC1 = compile arg1 
    6666    argC2 = compile arg2 
    67 compile (Cxt _ arg) = compile arg 
    68 compile (Pos _ arg) = compile arg 
     67compile (Ann _ arg) = compile arg 
    6968compile (Val (VInt i)) = [| return (VInt i) |] 
    7069compile (Val (VStr s)) = [| return (VStr s) |] 
  • src/Pugs/Compile/PIL2.hs

    r7866 r8153  
    128128 
    129129instance Compile Exp PIL_Stmts where 
    130     compile (Pos _ rest) = compile rest -- fmap (PPos pos rest) $ compile rest 
    131     compile (Cxt cxt rest) = enter cxt $ compile rest 
     130    compile (Ann (Pos _) rest) = compile rest -- fmap (PPos pos rest) $ compile rest 
     131    compile (Ann (Cxt cxt) rest) = enter cxt $ compile rest 
     132    -- XXX: pragmas? 
    132133    compile (Stmts (Pad SOur _ exp) rest) = do 
    133134        compile $ mergeStmts exp rest 
     
    183184 
    184185instance Compile Exp PIL_Stmt where 
    185     compile (Pos pos rest) = fmap (PPos pos rest) $ compile rest 
    186     compile (Cxt cxt rest) = enter cxt $ compile rest 
     186    compile (Ann (Pos pos) rest) = fmap (PPos pos rest) $ compile rest 
     187    compile (Ann (Cxt cxt) rest) = enter cxt $ compile rest 
     188    -- XXX: pragmas? 
    187189    compile Noop = return PNoop 
    188190    compile (Val val) = do 
     
    257259 
    258260instance Compile Exp PIL_LValue where 
    259     compile (Pos _ rest) = compile rest -- fmap (PPos pos rest) $ compile rest 
    260     compile (Cxt cxt rest) = enter cxt $ compile rest 
     261    compile (Ann (Pos _) rest) = compile rest -- fmap (PPos pos rest) $ compile rest 
     262    compile (Ann (Cxt cxt) rest) = enter cxt $ compile rest 
    261263    compile (Var name) = return $ PVar name 
    262264    compile (Syn (sigil:"::()") exps) = do 
     
    352354{-| Compiles various 'Exp's to 'PIL_Expr's. -} 
    353355instance Compile Exp PIL_Expr where 
    354     compile (Pos _ rest) = compile rest -- fmap (PPos pos rest) $ compile rest 
    355     compile (Cxt cxt rest) = enter cxt $ compile rest 
     356    compile (Ann (Pos _) rest) = compile rest -- fmap (PPos pos rest) $ compile rest 
     357    compile (Ann (Cxt cxt) rest) = enter cxt $ compile rest 
    356358    compile (Var name) = return . PExp $ PVar name 
    357359    compile exp@(Val (VCode _)) = compile $ Syn "sub" [exp] 
  • src/Pugs/Compile/Pugs.hs

    r7843 r8153  
    6161            , text "return" <+> parens (text $ "Syn " ++ show syn ++ " exps") 
    6262            ] 
    63     compile (Cxt cxt exp) = compileShow2 "Cxt" cxt exp 
    64     compile (Pos pos exp) = compileShow2 "Pos" pos exp 
     63    compile (Ann (Cxt cxt) exp) = compileShow2 "Cxt" cxt exp 
     64    compile (Ann (Pos pos) exp) = compileShow2 "Pos" pos exp 
     65    compile (Ann (Prag prag) exp) = compileShow2 "Prag" prag exp 
    6566    compile (Pad scope pad exp) = do 
    6667        padC <- compile pad