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

BNFC.Backend.CPP.STL.CFtoBisonSTL

Synopsis

Documentation

union :: Maybe String -> [Cat] -> Doc Source #

The union declaration is special to Bison/Yacc and gives the type of yylval. For efficiency, we may want to only include used categories here.

>>> let foo = Cat "Foo"
>>> union Nothing [foo, ListCat foo]
%union
{
  int    _int;
  char   _char;
  double _double;
  char*  _string;
  Foo* foo_;
  ListFoo* listfoo_;
}

If the given list of categories is contains coerced categories, those should be normalized and duplicate removed E.g. if there is both [Foo] and [Foo2] we should only print one pointer: ListFoo* listfoo_;

>>> let foo2 = CoercCat "Foo" 2
>>> union Nothing [foo, ListCat foo, foo2, ListCat foo2]
%union
{
  int    _int;
  char   _char;
  double _double;
  char*  _string;
  Foo* foo_;
  ListFoo* listfoo_;
}