BNFC-2.9.0: A compiler front-end generator.
Safe HaskellNone
LanguageHaskell2010

BNFC.Backend.Common

Description

Functions common to different backends.

Synopsis

Documentation

flexEps :: String Source #

Representation of the empty word as Flex regular expression

renderListSepByPrecedence Source #

Arguments

:: Doc

Name of the coercion level variable

-> (String -> Doc)

render function

-> [(Integer, String)]

separators by precedence

-> Doc 

Helper function for c-like languages that generates the code printing the list separator according to the given precedence level:

>>> let my_render c = "my_render(\"" <> text c <> "\")"
>>> renderListSepByPrecedence "x" my_render []

>>> renderListSepByPrecedence "x" my_render [(0,",")]
my_render(",");
>>> renderListSepByPrecedence "x" my_render [(3,";"), (1, "--")]
switch(x)
{
  case 3: my_render(";"); break;
  default: my_render("--");
}