[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
10.1.4 C++ Parser Interface
The output files ‘output.hh’ and ‘output.cc’
declare and define the parser class in the namespace yy
. The
class name defaults to parser
, but may be changed using
‘%define parser_class_name "name"’. The interface of
this class is detailed below. It can be extended using the
%parse-param
feature: its semantics is slightly changed since
it describes an additional member of the parser class, and an
additional argument for its constructor.
- Type of parser: semantic_value_type
- Type of parser: location_value_type
The types for semantics value and locations.
- Method on parser: parser (type1 arg1, ...)
Build a new parser object. There are no arguments by default, unless ‘%parse-param {type1 arg1}’ was used.
- Method on parser: std::ostream& debug_stream ()
- Method on parser: void set_debug_stream (std::ostream& o)
Get or set the stream used for tracing the parsing. It defaults to
std::cerr
.
- Method on parser: debug_level_type debug_level ()
- Method on parser: void set_debug_level (debug_level l)
Get or set the tracing level. Currently its value is either 0, no trace, or nonzero, full tracing.
- Method on parser: void error (const location_type& l, const std::string& m)
The definition for this member function must be supplied by the user: the parser uses it to report a parser error occurring at l, described by m.