gfy-cpp
|
A class to read tokens from a source file. More...
#include <lexer.hpp>
Public Member Functions | |
Lexer (const char *filename) | |
Construct a new Lexer object. | |
Lexer (const string &filename) | |
Construct a new Lexer object. | |
~Lexer () | |
Destroy the Lexer object. | |
Token | next_token () |
Get the next token from the source file. | |
Private Member Functions | |
char | skip_blanks () |
Skip blanks in the line buffer. | |
char | pop_char () |
Pop the first character from the line buffer. | |
bool | is_import_line () |
Check if the current line is an import line. | |
Type | get_type (const string &identifier) |
Return the type of a given identifier. | |
Private Attributes | |
ifstream | source |
string | filename |
string | line_buff |
size_t | line |
size_t | column |
Static Private Attributes | |
static locale | loc = locale(locale(), new codecvt_utf8<wchar_t>) |
A class to read tokens from a source file.
The lexer reads tokens from a source file and returns them one by one. It also keeps track of the current line and column in the source file.
Lexer::Lexer | ( | const char * | filename | ) |
Construct a new Lexer object.
filename | The name of the file to read from |
Lexer::Lexer | ( | const string & | filename | ) |
Construct a new Lexer object.
filename | The name of the file to read from |
Lexer::~Lexer | ( | ) |
Destroy the Lexer object.
|
private |
Return the type of a given identifier.
identifier | The identifier to check |
|
private |
Check if the current line is an import line.
Token Lexer::next_token | ( | ) |
Get the next token from the source file.
|
private |
Pop the first character from the line buffer.
|
private |
Skip blanks in the line buffer.
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |