YooParse usually requires YooLex to function, but it doesn't have to, as long as
int yyLex ();is available.
.l
(YooLex input) file, have the %option
line as:
%option noheader class="DefaultParse" ccfile="DefaultParse_lex.cc"One thing is very important that for both YooParse and YooLex, the default the C++ source file is
DefaultParse.cc
if only the class
option is set. They would overwrite each other generated source code. Thus,
ccfile
is necessary to avoid this conflict. The noheader
option tells YooLex not to generate the C++ header file at all since the one
generated by YooParse is needed.
.y
(YooParse input) file, have a line which
starts w/ %option
and enter configuration parameters. For example:
%option class="DefaultParse" ccfile="DefaultParse_parse.cc"For the above two steps, they both assumed the C++ header file is "
DefaultParse.hh
".
If one wishes to use a different header file for the DefaultParse
class, both the .l
file and the .y
file need to
have the following option:
%option hhfile="DefaultParse_header.hh"YooParse would generate the header file if it did not exist. One can edit this header file to add variables, functions, the constructor for the parser, etc. YooParse will not overwrite this file.
int
data type will usually work, provided that it
is casted to the desired data type. Otherwise, one could specify a different
data type:
%option yyvalue="double"Note:
std::auto_ptr<>
cannot be used as _yyValue data type.
The data type also must have a default constructor.
.y
input file, the C++ header
file specified by the user would be created if it did not exist. Modify this
header file to suit for the need.
bool yyParseError (int yychar);
yychar
is the translated lookahead character. The function returns
true
to terminate yyParse ()
. Please read yooparse.hh
for more details.