Changeset 5266

Show
Ignore:
Timestamp:
07/07/05 07:44:01 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
7266
Message:

* Finish the transition from @?CHECK and @?INIT to

@*CHECK and @*INIT.

Location:
src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/Main.hs

    r5158 r5266  
    8989--   "-e foo bar.p6" executes "foo" with @*ARGS[0] eq "bar.p6", 
    9090--   "-E foo bar.p6" executes "foo" and then bar.p6. 
     91-- XXX - Wrong -- Need to preserve environment across -E runs 
    9192run (("-E"):prog:rest)          = run ("-e":prog:[]) >> run rest 
    9293run ("-":args)                  = do doRun "-" args =<< readStdin 
  • src/Pugs/Compile/Pugs.hs

    r5137 r5266  
    7575 
    7676instance 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 
    7879    compile ((_:'=':_), _) = return empty -- XXX - @=POS etc; punt for now 
    7980    compile (n, tvars) = do 
  • src/Pugs/Parser.hs

    r5169 r5266  
    680680 
    681681vcode2initBlock :: Val -> RuleParser Exp 
    682 vcode2initBlock code = vcode2initOrCheckBlock "@?INIT" True code 
     682vcode2initBlock code = vcode2initOrCheckBlock "@*INIT" True code 
    683683 
    684684vcode2checkBlock :: Val -> RuleParser Exp 
    685 vcode2checkBlock code = vcode2initOrCheckBlock "@?CHECK" False code 
     685vcode2checkBlock code = vcode2initOrCheckBlock "@*CHECK" False code 
    686686 
    687687vcode2initOrCheckBlock :: String -> Bool -> Val -> RuleParser Exp 
     
    689689    -- Similar as with FIRST {...}, we transform our input: 
    690690    -- 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)](); 
    692692    -- Or, with CHECK: 
    693693    -- 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)](); 
    695695    -- This is the inner FIRST {...} block we generate. 
    696696    body <- vcode2firstBlock code 
     
    698698                      | otherwise   = checkForIOLeak 
    699699    rv <- unsafeEvalExp $ 
    700         -- BEGIN { push @?INIT, { FIRST {...} } } 
     700        -- BEGIN { push @*INIT, { FIRST {...} } } 
    701701        App (Var "&push") (Just $ Var magicalVar) 
    702702            [ Syn "sub" [ Val $ VCode mkSub { subBody = possiblyCheck body }]] 
     
    704704    let (Val (VInt elems)) = rv 
    705705    -- Finally, we can return the transformed expression. 
    706     -- elems is the new number of elems in @?INIT (as push returns the new 
     706    -- elems is the new number of elems in @*INIT (as push returns the new 
    707707    -- number of elems), but we're interested in the index, so we -1 it. 
    708708    return $ App (Syn "[]" [Var magicalVar, Val . VInt $ elems - 1]) Nothing []