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

BNFC.Backend.Haskell.Utilities.Parser

Synopsis

Documentation

generatePatterns :: Bool -> RHS -> (String, [String]) Source #

Generate patterns and a set of metavariables (de Bruijn indices) indicating where in the pattern the non-terminals are locate.

>>> generatePatterns False [ NTerminal (Cat' (BaseCat 'E':|"xp")), Terminal (Keyword ('+':|[])), NTerminal (Cat' (BaseCat 'E':|"xp")) ]
("Exp '+' Exp",["$1","$3"])
>>> generatePatterns True [ NTerminal (Cat' (BaseCat 'E':|"xp")), Terminal (Keyword ('+':|[])), NTerminal (Cat' (BaseCat 'E':|"xp")) ]
("Exp '+' Exp",["(snd $1)","(snd $3)"])