Changeset 7035 for src/Pugs/Parser.hs

Show
Ignore:
Timestamp:
09/17/05 22:55:58 (3 years ago)
Author:
gaal
Message:

Lexical pragmas (WIP). See Pugs.AST.Prag. Dominus++.
This doesn't work yet, my pragmas got lost somewhere between the parser
and the evaluator.
TODO after it's fixed:
- throw away the cons list in favor of a primitive [] - it's enough
- figure out how to install other kinds of pragma data, not just Int

And, the fun part:
- use fatal
- use sort 'mergesort'
- no strict :-)
- other ideas from http://perl.plover.com/TPF/Pragmas/PROPOSAL

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Parser.hs

    r7033 r7035  
    898898        "BEGIN" -> do 
    899899            -- We've to exit if the user has written code like BEGIN { exit }. 
    900             possiblyExit =<< unsafeEvalExp (checkForIOLeak fun) 
     900            val <- possiblyExit =<< unsafeEvalExp (checkForIOLeak fun) 
     901            -- And install any pragmas they've requested. 
     902            env <- getRuleEnv 
     903            let idat = unsafePerformIO $ liftSTM $ readTVar $ envInitDat env 
     904            install $ initPragmas idat 
     905            return val 
    901906        "CHECK" -> vcode2checkBlock code 
    902907        "INIT"  -> vcode2initBlock code 
    903908        "FIRST" -> vcode2firstBlock code 
    904909        _       -> fail "" 
     910    where 
     911        install [] = return () 
     912        install (x:xs) = do 
     913            env' <- getRuleEnv 
     914            let env'' = envCaller env'  -- not sure about this. 
     915            case env'' of 
     916                Just target -> do 
     917                    putRuleEnv target { envPragmas = 
     918                        PrPrags{ pragma  = x 
     919                               , pragmas = envPragmas target} } 
     920                    install xs 
     921                _ -> fail "no caller env to install pragma in" 
    905922 
    906923{-| Wraps a call to @&Pugs::Internals::check_for_io_leak@ around the input