htcc-0.0.0.1: The full scratch implementation of tiny C compiler (x86_64)
Copyright(c) roki 2019
LicenseMIT
Maintainerfalgon53@yahoo.co.jp
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Htcc.Parser.ConstructionData.Core

Description

Data types and type synonyms used during AST construction

Synopsis

Main type

data ConstructionData i Source #

ConstructionData is a set of "things" used during the construction of the AST. Contains error messages and scope information.

Constructors

ConstructionData

The constructor of ConstructionData

Fields

Instances

Instances details
Show i => Show (ConstructionData i) Source # 
Instance details

Defined in Htcc.Parser.ConstructionData.Core

type Warnings i = Seq (Text, TokenLC i) Source #

The warning messages type

Adding funcitons

addLVar :: (Integral i, Bits i) => StorageClass i -> TokenLC i -> ConstructionData i -> Either (ASTError i) (ATree i, ConstructionData i) Source #

Shortcut to function addLVar for variable x of type ConstructionData. This function is equivalent to

>>> second (\x -> y { scope = x }) <$> Htcc.Parser.AST.Scope.addLVar ty tkn (scope x)

addGVar :: (Integral i, Bits i) => StorageClass i -> TokenLC i -> ConstructionData i -> Either (ASTError i) (ATree i, ConstructionData i) Source #

Shortcut to function addGVar for variable x of type ConstructionData. This function is equivalent to

>>> second (\x -> y { scope = x }) <$> Htcc.Parser.AST.Scope.addGVar ty tkn (scope x)

addGVarWith :: (Integral i, Bits i) => StorageClass i -> TokenLC i -> GVarInitWith i -> ConstructionData i -> Either (ASTError i) (ATree i, ConstructionData i) Source #

Shortcut to function addGVarWith for variable x of tye ConstructionData.

addLiteral :: (Integral i, Bits i) => StorageClass i -> TokenLC i -> ConstructionData i -> Either (ASTError i) (ATree i, ConstructionData i) Source #

Shortcut to function addLiteral for variable x of type ConstructionData. This function is equivalent to

>>> second (\x -> y { scope = x }) <$> Htcc.Parser.AST.Scope.addLiteral ty tkn (scope x)

addTag :: Num i => StorageClass i -> TokenLC i -> ConstructionData i -> Either (ASTError i) (ConstructionData i) Source #

Shortcut to function addTag for variable x of type ConstructionData. This function is equivalent to

>>> (\y -> x { scope = y }) <$> Htcc.Parser.AST.Scope.addTag ty tkn (scope x)

addTypedef :: (Eq i, Num i) => StorageClass i -> TokenLC i -> ConstructionData i -> Either (ASTError i) (ConstructionData i) Source #

Shortcut to function addTypedef for variable x of type ConstructionData. This function is equivalent to

>>> (\y -> x { scope = y }) <$> Htcc.Parser.AST.Scope.addTypedef ty tkn (scope x)

addFunction :: Num i => Bool -> StorageClass i -> TokenLC i -> ConstructionData i -> Either (ASTError i) (ConstructionData i) Source #

Shortcut to function addFunction for variable x of type ConstructionData. This function is equivalent to

>>> (\y -> x { scope = y }) <$> Htcc.Parser.AST.Scope.addFunction ty tkn (scope x)

addEnumerator :: Num i => StorageClass i -> TokenLC i -> i -> ConstructionData i -> Either (ASTError i) (ConstructionData i) Source #

Shortcut to function addEnumerator for variable x of type ConstructionData. This function is equivalent to

>>> (\y -> x { scope = y }) <$> Htcc.Parser.AST.Scope.addEnumerator ty tkn (scope x)

Searching function

lookupLVar :: Text -> ConstructionData i -> Maybe (LVar i) Source #

Shortcut to function lookupLVar for variable x of type ConstructionData. This function is equivalent to

>>> Htcc.Parser.AST.Scope.lookupLVar s $ scope x

lookupGVar :: Text -> ConstructionData i -> Maybe (GVar i) Source #

Shortcut to function lookupGVar for variable x of type ConstructionData. This function is equivalent to

>>> Htcc.Parser.AST.Scope.lookupGVar s $ scope x

lookupVar :: Text -> ConstructionData i -> LookupVarResult i Source #

Shortcut to function lookupVar for variable x of type ConstructionData. This function is equivalent to

>>> Htcc.Parser.AST.Scope.lookupVar s $ scope x

lookupTag :: Text -> ConstructionData i -> Maybe (Tag i) Source #

Shortcut to function lookupTag for variable x of type ConstructionData. This function is equivalent to

>>> Htcc.Parser.AST.Scope.lookupTag s $ scope x

lookupTypedef :: Text -> ConstructionData i -> Maybe (Typedef i) Source #

Shortcut to function lookupTypedef for variable x of type ConstructionData. This function is equivalent to

>>> Htcc.Parser.AST.Scope.lookupTypedef s $ scope x

lookupFunction :: Text -> ConstructionData i -> Maybe (Function i) Source #

Shortcut to function lookupFunction for variable x of type ConstructionData. This function is equivalent to

>>> Htcc.Parser.AST.Scope.lookupFunction s $ scope x

lookupEnumerator :: Text -> ConstructionData i -> Maybe (Enumerator i) Source #

Shortcut to function lookupEnumerator for variable x of type ConstructionData. This function is equivalent to

>>> Htcc.Parser.AST.Scope.lookupEnumerator s $ scope x

Other utilities

succNest :: ConstructionData i -> ConstructionData i Source #

Shortcut to function succNest for variable x of type ConstructionData. This function is equivalent to

>>> x { scope = Htcc.Parser.AST.Scope.succNest (scope x) }

fallBack :: ConstructionData i -> ConstructionData i -> ConstructionData i Source #

Shortcut to function fallBack for variable x of type ConstructionData. This function is equivalent to

>>> post { scope = Htcc.Parser.AST.Scope.fallBack (scope pre) (scope post) }

initConstructionData :: ConstructionData i Source #

Shortcut to the initial state of ConstructionData.

resetLocal :: ConstructionData i -> ConstructionData i Source #

Shortcut to function resetLocal for variable x of type ConstructionData. This function is equivalent to

>>> x { scope = Htcc.Parser.AST.Scope.resetLocal (scope x) }

pushWarn :: Text -> TokenLC i -> ConstructionData i -> ConstructionData i Source #

Function to add warning text.

incomplete :: StorageClass i -> ConstructionData i -> Maybe (StorageClass i) Source #

Returns Nothing if incomplete, otherwise StorageClass.