yay sourcefile Parser=outfile [option]*
(+|-)LR2 (-) (+|-)Verbose (-) (+|-)Warnings (+) Description=file Language=B|C|C++ (C) Manifests=file Parser=file
yay cgram.y parse=/myparse.c c /myparse.c
yay bgram.y lang=b +verb pars=myfile.b b myfile.b
yay ccgram.y lang=c++ pars=/myparse.cc
YAY converts your context-free grammar into a C, B, or C++ program that is written to the file specified by the Parser= option.
If you use the Description= option, YAY writes a full description of the grammar to the specified file. YAY only displays a brief message on the standard output, summarizing conflicts (and other information if you specify +Verbose). On the other hand, if you do not use the Description= option, YAY writes more information to standard output, including descriptions of the states where conflicts occur. In this case, YAY actually provides additional information to help you identify the source of the conflicts; if you ask for a description file, YAY outputs less information when reporting the conflicts because it assumes you can track down additional information by looking at the description file. For this reason, you can sometimes get a quicker idea of what has gone wrong if you do not ask for a description file.
In general, you only need to use Language=C++ if you intend YYSTYPE to contain a C++ object with constructors. If you intend to compile the parser with C++ but the %union statement does not have any elements that need constructors, it's best to use Language=C to get more efficient C code.
If YYSTYPE does contain elements that need constructors, you need to define an appropriate constructor-like function for the YYSTYPE type. This function should have the prototype
void name(YYSTYPE *p)
where "name" can be any valid name. In the declarations section of the grammar, you must then add the statement
#define YYSTYPE_INIT name
where "name" is the name of the constructor-like function.
With Language=C++, the %union statement generates a structure type rather than a union, since C++ does not allow objects with constructors to belong to unions.
In many cases, the same grammar may be processed with either Language=C or Language=C++.
If you define YYALLOC, the parser allocates its state and value stacks dynamically via malloc and free. This shrinks your parser and helps prevent stack overflows.
fc*yt, fc*ya -- temporary work files
uw_tools/rfw1.3/aux/yyparse.c -- C parser
uw_tools/rfw1.3/aux/yyparse.b -- B parser
uw_tools/rfw1.3/aux/yyparse.cc -- C++ parser
Copyright © 1996, Thinkage Ltd.