BNFC-2.9.5: A compiler front-end generator.
Safe HaskellSafe-Inferred
LanguageHaskell2010

BNFC.Backend.Common.NamedVariables

Synopsis

Documentation

type IVar = (String, Int) Source #

type SymEnv = KeywordEnv Source #

A symbol-mapping environment.

type KeywordEnv = [(String, String)] Source #

Map keywords to their token name.

type SymMap = Map SymKey String Source #

Map keywords and user-defined token types to their token name.

data SymKey Source #

Constructors

Keyword String

Keyword like "(", "while", "true", ...

Tokentype String

Token type like Integer, Char, ...

Instances

Instances details
Show SymKey Source # 
Instance details

Defined in BNFC.Backend.Common.NamedVariables

Eq SymKey Source # 
Instance details

Defined in BNFC.Backend.Common.NamedVariables

Methods

(==) :: SymKey -> SymKey -> Bool #

(/=) :: SymKey -> SymKey -> Bool #

Ord SymKey Source # 
Instance details

Defined in BNFC.Backend.Common.NamedVariables

getVars :: [Cat] -> [IVar] Source #

Converts a list of categories into their types to be used as instance variables. If a category appears only once, it is given the number 0, if it appears more than once, its occurrences are numbered from 1. ex:

>>> getVars [Cat "A", Cat "B", Cat "A"]
[("A",1),("B",0),("A",2)]

numVars :: [Either Cat a] -> [Either (Cat, Doc) a] Source #

Anotate the right hand side of a rule with variable names for the non-terminals. >>> numVars [Left (Cat A), Right "+", Left (Cat B)] [Left (A,a_),Right "+",Left (B,b_)] >>> numVars [Left (Cat A), Left (Cat A), Right ";"] [Left (A,a_1),Left (A,a_2),Right ";"]

fixCoercions :: [(Cat, [Rule])] -> [(Cat, [Rule])] Source #