Changeset 5266
- Timestamp:
- 07/07/05 07:44:01 (4 years ago)
- svk:copy_cache_prev:
- 7266
- Location:
- src
- Files:
-
- 3 modified
-
Main.hs (modified) (1 diff)
-
Pugs/Compile/Pugs.hs (modified) (1 diff)
-
Pugs/Parser.hs (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Main.hs
r5158 r5266 89 89 -- "-e foo bar.p6" executes "foo" with @*ARGS[0] eq "bar.p6", 90 90 -- "-E foo bar.p6" executes "foo" and then bar.p6. 91 -- XXX - Wrong -- Need to preserve environment across -E runs 91 92 run (("-E"):prog:rest) = run ("-e":prog:[]) >> run rest 92 93 run ("-":args) = do doRun "-" args =<< readStdin -
src/Pugs/Compile/Pugs.hs
r5137 r5266 75 75 76 76 instance Compile (String, [(TVar Bool, TVar VRef)]) where 77 compile ((_:'?':_), _) = return empty -- XXX - @?INIT etc; punt for now 77 compile ((_:'?':_), _) = return empty -- XXX - @?S etc; punt for now 78 compile ((_:'*':_), _) = return empty -- XXX - @*INIT etc; punt for now 78 79 compile ((_:'=':_), _) = return empty -- XXX - @=POS etc; punt for now 79 80 compile (n, tvars) = do -
src/Pugs/Parser.hs
r5169 r5266 680 680 681 681 vcode2initBlock :: Val -> RuleParser Exp 682 vcode2initBlock code = vcode2initOrCheckBlock "@ ?INIT" True code682 vcode2initBlock code = vcode2initOrCheckBlock "@*INIT" True code 683 683 684 684 vcode2checkBlock :: Val -> RuleParser Exp 685 vcode2checkBlock code = vcode2initOrCheckBlock "@ ?CHECK" False code685 vcode2checkBlock code = vcode2initOrCheckBlock "@*CHECK" False code 686 686 687 687 vcode2initOrCheckBlock :: String -> Bool -> Val -> RuleParser Exp … … 689 689 -- Similar as with FIRST {...}, we transform our input: 690 690 -- my $x = INIT { 42 } is transformed into 691 -- BEGIN { push @ ?INIT, { FIRST { 42 } } }; my $x = @?INIT[(index)]();691 -- BEGIN { push @*INIT, { FIRST { 42 } } }; my $x = @*INIT[(index)](); 692 692 -- Or, with CHECK: 693 693 -- my $x = CHECK { 42 } is transformed into 694 -- BEGIN { push @ ?CHECK, { FIRST { 42 } } }; my $x = @?CHECK[(index)]();694 -- BEGIN { push @*CHECK, { FIRST { 42 } } }; my $x = @*CHECK[(index)](); 695 695 -- This is the inner FIRST {...} block we generate. 696 696 body <- vcode2firstBlock code … … 698 698 | otherwise = checkForIOLeak 699 699 rv <- unsafeEvalExp $ 700 -- BEGIN { push @ ?INIT, { FIRST {...} } }700 -- BEGIN { push @*INIT, { FIRST {...} } } 701 701 App (Var "&push") (Just $ Var magicalVar) 702 702 [ Syn "sub" [ Val $ VCode mkSub { subBody = possiblyCheck body }]] … … 704 704 let (Val (VInt elems)) = rv 705 705 -- Finally, we can return the transformed expression. 706 -- elems is the new number of elems in @ ?INIT (as push returns the new706 -- elems is the new number of elems in @*INIT (as push returns the new 707 707 -- number of elems), but we're interested in the index, so we -1 it. 708 708 return $ App (Syn "[]" [Var magicalVar, Val . VInt $ elems - 1]) Nothing []
