tock-mirror/fco2/ParseState.hs
2007-04-05 17:37:45 +00:00

26 lines
542 B
Haskell

-- State that is kept while parsing (and compiling) occam.
module ParseState where
import Data.Generics
import qualified AST as A
data ParseState = ParseState {
psLocalNames :: [(String, A.Name)],
psNames :: [(String, A.NameDef)],
psNameCounter :: Int
}
deriving (Show, Eq, Typeable, Data)
emptyState :: ParseState
emptyState = ParseState {
psLocalNames = [],
psNames = [],
psNameCounter = 0
}
psLookupName :: ParseState -> A.Name -> Maybe A.NameDef
psLookupName ps n = lookup (A.nameName n) (psNames ps)