The output from yacc is a Limbo module y.tab.b containing the parse function yyparse which must be provided with a YYLEX adt providing the parser access to a lexical analyser routine lex() , an error routine error() , and any other context required.
The options are
"\w'\fL-o output\fLXX'u" -o " output Direct output to the specified file instead of y.tab.b .
-D n Create file y.debug , containing diagnostic messages. To incorporate them in the parser, give an n greater than zero. The amount of diagnostic output from the parser is regulated by value n :
1 Report errors.
2 Also report reductions.
3 Also report the name of each token returned by .LR yylex .
-v Create file y.output , containing a description of the parsing tables and of conflicts arising from ambiguities in the grammar.
-d Create file y.tab.m , containing the module declaration for the parser, along with definitions of the constants that associate yacc -assigned `token codes' with user-declared `token names'. Include it in source files other than y.tab.b to give access to the token codes and the parser module.
-s " stem Change the prefix .L y of the file names y.tab.b , y.tab.m , y.debug , and y.output to stem .
-m Normally yacc defines the type of the y.tab.b module within the text of the module according to the contents of the %module directive. Giving the -m option suppresses this behaviour, leaving the implementation free to define the module's type from an external .m file. The module's type name is still taken from the %module directive.
-n " size Specify the initial size of the token stack created for the parser (default: 200).
Comments follow the Limbo convention (a # symbol gives a comment until the end of the line).
A %module directive is required, which replaces the %union directive. It is of the form:
%module modname {
module types, functions and constants
}
A type YYSTYPE must be defined, giving the type associated with yacc tokens. If the angle bracket construction is used after any of the %token , %left , %right , %nonassoc or %type directives in order to associate a type with a token or production, the word inside the angle brackets refers to a member of an instance of YYSTYPE , which should be an adt.
An adt YYLEX must be defined, providing context to the parser. The definition must consist of at least the following: .EX YYLEX: adt { lval: YYSTYPE; lex: fn(l: self ref YYLEX): int; error: fn(l: self ref YYLEX, msg: string); } Lex should invoke a lexical analyser to return the next token for yacc to analyse. The value of the token should be left in lval . Error will be called when a parse error occurs. Msg is a string describing the error.
Yyparse takes one argument, a reference to the YYLEX adt that will be used to provide it with tokens.
The parser is fully re-entrant; i.e. it does not hold any parse state in any global variables within the module.
y.output
y.tab.b
y.tab.m
y.debug
B. W. Kernighan and Rob Pike, The UNIX Programming Environment, Prentice Hall, 1984