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/AST/Internals.hs

    r6934 r7035  
    99    Val(..),   -- uses V.* (which ones?) 
    1010    Value(..), -- uses Val, Eval 
     11    InitDat(..), 
    1112 
    1213    EvalT(..), ContT(..), 
     
    7980 
    8081import Pugs.Parser.Number 
     82import Pugs.AST.Prag 
    8183import Pugs.AST.Pos 
    8284import Pugs.AST.Scope 
     
    862864    | Cxt !Cxt !Exp                     -- ^ Context 
    863865    | Pos !Pos !Exp                     -- ^ Position 
     866    | Prag !Pragmas !Exp                -- ^ Lexical pragmas 
    864867    | Pad !Scope !Pad !Exp              -- ^ Lexical pad 
    865868    | Sym !Scope !Var !Exp              -- ^ Symbol declaration 
     
    904907    unwrap (Cxt _ exp)      = unwrap exp 
    905908    unwrap (Pos _ exp)      = unwrap exp 
     909    unwrap (Prag _ exp)     = unwrap exp 
    906910    unwrap (Pad _ _ exp)    = unwrap exp 
    907911    unwrap (Sym _ _ exp)    = unwrap exp 
     
    954958    | otherwise 
    955959    = (Var name, vs) 
     960extract (Prag prag ex) vs = ((Prag prag ex'), vs') 
     961    where 
     962    (ex', vs') = extract ex vs 
    956963extract (Pos pos ex) vs = ((Pos pos ex'), vs') 
    957964    where 
     
    10431050    , envDebug   :: !DebugInfo           -- ^ Debug info map 
    10441051    , envPos     :: !Pos                 -- ^ Source position range 
     1052    , envPragmas :: !Pragmas             -- ^ List of pragmas in effect 
     1053    , envInitDat :: !(TVar InitDat)      -- ^ BEGIN result information 
     1054    } deriving (Show, Eq, Ord, Typeable) 
     1055 
     1056{-| 
     1057Module initialization information. 
     1058 
     1059When a module is loaded and initialized (i.e., its &import routine is 
     1060called), it may need to communicate information back to the parser.  
     1061This information is held in a TVar to which the parser has access. 
     1062Currently we use this for keeping track of lexical pragma change 
     1063requests, but the possiblyExit mechanism may be refactored to use 
     1064this as well. 
     1065-} 
     1066data InitDat = MkInitDat 
     1067    { initPragmas :: [Pragma]            -- ^ Pragma values being installed 
    10451068    } deriving (Show, Eq, Ord, Typeable) 
    10461069