next up previous contents index
Next: Syntax declaration Up: Parser Specification Previous: Parser Specification

Syntax class

A syntax class definition specifies an object class that encapsulates a parser. Its syntax is the same as the usual C++ class definition, except that the prefix syntax is used:

Syntax_Class_Decl ::=syntax class Id  [ : Inherit_List ] { Class_Body } ;

This specification automatically generate a class with the following interface (assuming that the parser class in question is called ParserClass)

public:
   ParserClass();  // constructor
public:
   virtual void parse();

The constructor and the method parse() will be automatically generated later.

A parser class expects the following method to be defined:

   int get_token();
The function of get_token is to return the next token from the lexer stream whenever it is called. It should return EOF if the stream is empty.



Allen Leung
Mon Apr 7 14:33:55 EDT 1997