mjplusplus
v0.4.1
|
#include <lexer.hpp>
Public Member Functions | |
Lexer (const char *file_name, Stateomat const &stateomat, shptr< ErrorReporter > errorReporter) | |
Token | get_next_token () |
void | unget_token (Token const &t) |
bool | good () const |
std::string | describe (Token::Token_type const &t) const |
Protected Member Functions | |
char | getc () |
void | advancePosition (int nextCharacter) |
Token::Token_type | lex_keyword_or_ident (const char *s) |
Protected Attributes | |
source_position_t | position |
Stateomat | stateomat |
shptr< ErrorReporter > | errorReporter |
std::vector< Token > | token_stack |
int | c |
int | fd |
char | buf [BUF_SIZE] |
size_t | buf_off |
size_t | buf_len |
off_t | line_start |
Static Protected Attributes | |
static Token::Token_type | kw_array [] |
static std::vector< std::pair < const char *, Token::Token_type > > | kw_vector |
static const int | kw_lex_table [][26] |
|
protected |
(partial) state list for keyword checking automaton
lexer::Lexer::Lexer | ( | const char * | file_name, |
Stateomat const & | stateomat, | ||
shptr< ErrorReporter > | errorReporter | ||
) |
Constructor.
Initializes the lexer so that llexing can be started.
file_name | file that will be lexed |
stateomat | stateomat that helds the transitions |
|
protected |
Advance the current position.
If nextCharacter is
the line number in position will be incremented and column is reset to 1. Otherwise column will be incremented.
nextCharacter | the next character |
std::string lexer::Lexer::describe | ( | Token::Token_type const & | t | ) | const |
Returns a description string for the given token
token | to print the description of |
Token lexer::Lexer::get_next_token | ( | ) |
Lexes the next token and returns it.
|
protected |
Reads the next character and returns it.
bool lexer::Lexer::good | ( | ) | const |
Constant true.
|
protected |
void lexer::Lexer::unget_token | ( | Token const & | t | ) |
Puts back a token that was inspected but not yet consumed. This can happen because the grammar is not SLL(1). If there were calls to unget, get_next_token will return them first (LIFO order) before lexing the next token.
t | token to be set back |
|
protected |
|
protected |
|
protected |
|
protected |
currently read char
|
protected |
|
protected |
|
staticprotected |
keyword list to be used as lookup in keyword automaton. used for words that can only be recognised at the end of the string
|
staticprotected |
transition table for keyword automaton
|
staticprotected |
lookup for keyword automaton check used when only one possible keyword remains in the middle of the string
|
protected |
|
protected |
current lexer position in file (line, column)
|
protected |
stateomat holds the transition informations
|
protected |
saves tokens that are put back by unget