frostc-1.0.0.0: The Frost Programming Language Compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ast.Parser.State

Synopsis

Documentation

type TypeState = [(String, Type)] Source #

Represents the state of type definitions in the parser.

type VarState = [(String, Type)] Source #

Represents the state of variable definitions in the parser.

data PreProcessorState Source #

Tracks preprocessor-specific information, such as visited imports and import depth.

type DeferState = [[Expr]] Source #

Represents the stack of deferred expressions, grouped by scope.

data ParserState Source #

The complete state of the parser, including types, variables, preprocessor state, and deferred expressions.

Instances

Instances details
Show ParserState Source # 
Instance details

Defined in Ast.Parser.State

Eq ParserState Source # 
Instance details

Defined in Ast.Parser.State

parserState :: ParserState Source #

The initial state of the parser.

insertType :: String -> Type -> ParserState -> ParserState Source #

Inserts a custom type into the environment. If the type already exists, it overwrites it.

lookupType :: String -> ParserState -> Maybe Type Source #

Looks up a custom type in the environment by its name.

insertVar :: String -> Type -> ParserState -> ParserState Source #

Inserts a variable into the environment. If the variable already exists, it overwrites it.

lookupVar :: String -> ParserState -> Maybe Type Source #

Looks up a variable in the environment by its name. Returns Nothing if the variable is not found.

insertImport :: String -> ParserState -> ParserState Source #

Marks an import as visited by adding it to the set of visited imports.

lookupImport :: String -> ParserState -> Bool Source #

Checks if a file has already been imported. Returns True if the file is in the set of visited imports.

setImportDepth :: Int -> ParserState -> ParserState Source #

Sets the depth of nested imports in the preprocessor state.

getImportDepth :: ParserState -> Int Source #

Gets the current depth of nested imports from the preprocessor state.

pushDefered :: Expr -> ParserState -> ParserState Source #

Pushes a deferred expression onto the current defer stack.

pushScope :: ParserState -> ParserState Source #

Pushes a new empty array onto the defer state to represent entering a new scope.

popScope :: ParserState -> ([Expr], ParserState) Source #

Pops the top scope expressions stack. Returns the popped stack and the updated ParserState.