#include <archon/util/lexer.H>
Inheritance diagram for Archon::Utilities::Lexer:
Public Member Functions | |
Lexer (const Engine &e, Ref< Stream::UReader > &r, Context *c=0) | |
Configure a lexer engine with an input character stream and an optional context. | |
void | getNext (Lexeme &) |
Extract the next lexeme from the input. | |
ustring | getText () const |
int | getType () const |
int | getLineNumber () const |
Classes | |
class | Actor |
A object in which context methods may be registered. More... | |
class | ActorBase |
A common base for the Actor class template. More... | |
struct | Context |
An abstract base class for the context of the lexer. More... | |
class | Engine |
The engine that knowns how to match prefixes of the input character stream with the regular expressions of the lexer rules. More... | |
class | RuleSet |
A set of lexer rules. More... |
Lexemes are defined by rules. Each rule is defined by at least a regular expression that define which strings that correspond to that rule. A rule may also specify a terminal type in which case the rule yields lexeme objects of that type. By default the value associated with the lexeme objects are the strings that were matched by the corresponding regular expression. Alternatively an action may be associated with a rule. In that case the action chooses the value of the generated lexeme objects.
A rule may also have an action associated with it but still not generate lexeme objects. This may be use to strip comments for example.
Finally a rule may have no action associated with it and generate no lexeme objects. This could be used for eating whitespace for example.
Definition at line 120 of file lexer.H.
|
Configure a lexer engine with an input character stream and an optional context. The context must only be left out if none of the rules have methods associated with them. The type of the context object is verified against the actor object given at the construction of the lexer engine to ensure that they are compatible. This in general means that the template argument to the Actor template must be the type of the context object passed to this constructor or at least a derivative of it. |
|
Definition at line 412 of file lexer.H. Referenced by Archon::X3D::VRML::Parser::Context::warning(). |
|
Extract the next lexeme from the input.
Definition at line 77 of file lexer.C. References Archon::Utilities::Lexer::Engine::actor, Archon::Utilities::Lexer::Engine::anchorMasks, Archon::Utilities::Lexer::ActorBase::call(), Archon::Utilities::Lexer::Engine::dfa, Archon::Utilities::DFA::State::getFinalValue(), getText(), Archon::Utilities::Lexer::Context::lexerError(), Archon::Utilities::Lexer::Engine::rules, and Archon::Utilities::DFA::State::step(). |
|
Implements Archon::Utilities::LexerBase. Definition at line 394 of file lexer.H. Referenced by getNext(), Archon::X3D::VRML::Parser::Context::lexer_decInt(), Archon::X3D::VRML::Parser::Context::lexer_float(), Archon::X3D::VRML::Parser::Context::lexer_hexInt(), Archon::X3D::VRML::Parser::Context::lexer_id(), Archon::X3D::VRML::Parser::Context::lexer_string(), Archon::X3D::VRML::Parser::Context::lexerError(), and Archon::X3D::VRML::Parser::Context::parserError(). |
|
Implements Archon::Utilities::LexerBase. Definition at line 403 of file lexer.H. Referenced by Archon::X3D::VRML::Parser::Context::parserError(). |