BNFC3-3.0: A compiler front-end generator.
Safe HaskellNone
LanguageHaskell2010

BNFC.Backend.CommonInterface.NamedVariables

Synopsis

Documentation

type IVar = (String, Int) Source #

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 ";"]

showNum :: (Eq a, Num a, Show a) => a -> [Char] Source #