YACC2LATEX MANUAL
Short Manual
- Version: 3.0-r4dcb390
- Pascal Raymond (Home Page)
Usage
yacc2latex version 3.0-r4dcb390
usage: yacc2latex <option> | yacc2latex -help
-m : print a short manual
-md : same in markdow format
-t <file>: load token def file
-o <file>: set out file (default infile.tex)
-os : write output to stdout
-- : read input from stdin
-main : gen a sample main latex file)
-testl : dump the yacc tokens and stop
-testy : dump the yacc grammar and stop
-testg : dump the ebnf grammar and stop
-version : print version and stop
-v : set verbose mode
-dbg {main}: set debug flag
-help Display this list of options
--help Display this list of options
Tokens file
Must contain one token definition per line:
TOKEN_ID "token value"
The “token value” is the string as it appears in actual programs, e.g.:
TK_WHILE while
TK_OPENPAR (
TK_GTE >=
The default is to treat and display tokens as literal strings. Since version 2.1, it is possible to (re)define tokens that are treated and displayed like non-terminal symbols, e.g.:
TK_IDENT <identifier>
TK_INTEGER <integer constant>
Latex customization
The following commands can be defined:
\newcommand{\bnftoken}[1]{...} token display dflt: {\bfseries tfamily #1}
\newcommand{\bnfleftident}[1]{...} rule (left) dflt: {\itshape #1}
\newcommand{\bnfrightident}[1]{...} rule (right) dflt: {\itshape #1}
\newcommand{\bnfdef}{...} eq symbol dflt: {$::=$}
\newcommand{\bnfor}{...} or symbol dflt: {$|$}
\newcommand{\bnfopt}[1]{...} optional part dflt: \mbox{$\lbrack$} #1 $\rbrack$}
\newcommand{\bnflist}[1]{...} repeated part dflt: \mbox{$\lbrace$} #1 $\rbrace$}
\newcommand{\bnfgroup}[1]{...} grouped part dflt: \mbox{$($} #1 $)$}
Pragmas
The input (yacc) file may contain pragmas:
/* ebnf:<name>=<value> */
Recognized pragmas are:
group
see Output organizationprint
see Pretty print pragmas
Output organization
Single Table
The default is to generate a single table for the whole grammar. This table is not actually printed: the latex command \ebnftable is generated which, when called, prints the table. A typical Latex main program is:
...
\begin{document}
\input{the-latex-code-generated-by-the-tool}
\section{This is my grammar}
...
\ebnftable
...
\end{document}
...
Group tables
If at least one pragma of the form ebnf:group=groupname is encountred,
the generation is made in “group mode”:
- for each
ebnf:group=groupname pragma
, an individual table is defined that contains the definitions of all the left symbols appearing between this group pragma and the next group pragma (or the end of the grammar). - No text is output, instead, a Latex command \groupname is defined that the user may call wherever he/she wants to print the table. A typical Latex main program is:
...
\begin{document}
\input{the-latex-code-generated-by-the-tool}
\section{This is my grammar}
\subsection{This is the group foo}
...
\groupfoo
\subsection{This is the group bar}
...
\groupbar
\end{document}
...
Pretty print pragmas
Pragmas of the form ebnf:print=value modify the way rules are printed. Recognized values are:
short
: the current left symbol definition will be printed on a single line (default is one line per choice)expand
: the current left symbol definition will be inlinedignore
: the current left symbol definition will be ignored