Lexer class.
More...
#include <lexer.hpp>
|
| | Lexer (std::string src, std::string fn, bool id) |
| std::vector< Token > | tokenize () |
| | Method for tokenizing source code.
|
Lexer class.
Definition at line 15 of file lexer.hpp.
◆ Lexer()
| Lexer::Lexer |
( |
std::string | src, |
|
|
std::string | fn, |
|
|
bool | id ) |
|
inline |
◆ advance()
| const char Lexer::advance |
( |
| ) |
|
|
private |
Method for skipping current character from source code and returns it.
This method caching current character from source code, skip it, changing lexer's pos, line and column and return cached character
- Returns
- Skipped character
Definition at line 324 of file lexer.cpp.
◆ get_escape_sequence()
| const char Lexer::get_escape_sequence |
( |
| ) |
|
|
private |
Method for getting escape-sequence in string or character literal.
This method getting escape-sequence character and returns it If method does not recognized escape-sequence, than throwing exception
- Returns
- Escape-sequence character
Definition at line 283 of file lexer.cpp.
◆ peek()
| const char Lexer::peek |
( |
int32_t | rpos = 0 | ) |
const |
|
private |
Method for getting character from source code by lexer pos and passed offset.
This method getting character from source code by lexer pos and passed offset If pos + offset out of bounds of range source code, then throwing exception
- Parameters
-
- Returns
- Character from source code
Definition at line 315 of file lexer.cpp.
◆ skip_comments()
| void Lexer::skip_comments |
( |
| ) |
|
|
private |
Method for skipping comments.
This method skipping comments (single-line yet)
Definition at line 275 of file lexer.cpp.
◆ tokenize()
| std::vector< Token > Lexer::tokenize |
( |
| ) |
|
Method for tokenizing source code.
This method tokenizing source code into vector of tokens and returns it
- Returns
- Vector of tokens after tokenizing
Definition at line 10 of file lexer.cpp.
◆ tokenize_character_lit()
| Token Lexer::tokenize_character_lit |
( |
| ) |
|
|
private |
Method for tokenizing character literal.
This method tokenizing character literal token and returns it If literal contains escape-sequence, then it handling If length of literal not equal 1, then throwing exception
- Returns
- Character literal token
Definition at line 138 of file lexer.cpp.
◆ tokenize_id()
| Token Lexer::tokenize_id |
( |
| ) |
|
|
private |
Method for tokenizing identifier token.
This method tokenizing identifier token and returns it If token value matches a keyword from the table, the keyword token is returned If token value matches a 'true' or 'false', the boolean literal token is returned
- Returns
- Token as identifier, keyword or boolean literal
Definition at line 46 of file lexer.cpp.
◆ tokenize_number_lit()
| Token Lexer::tokenize_number_lit |
( |
| ) |
|
|
private |
Method for tokenizing number literal.
This method tokenizing number literal token and returns it If literal contains a suffix, the literal corresponding to the suffix is returned Otherwise returns double literal if contains dot and integer literal otherwise
- Returns
- Number literal token
Definition at line 64 of file lexer.cpp.
◆ tokenize_op()
| Token Lexer::tokenize_op |
( |
| ) |
|
|
private |
Method for tokenizing operator.
This method tokenizing operator token and returns it If method does not recognized operator, then throwing exception
- Returns
- Operator token
Definition at line 162 of file lexer.cpp.
◆ tokenize_string_lit()
| Token Lexer::tokenize_string_lit |
( |
| ) |
|
|
private |
Method for tokenizing string literal.
This method tokenizing string literal token and returns it If literal contains escape-sequence, then it handling
- Returns
- String literal token
Definition at line 117 of file lexer.cpp.
◆ column
Column coordinate
Definition at line 22 of file lexer.hpp.
◆ file_name
| std::string Lexer::file_name |
|
private |
Name of the file containing the token
Definition at line 17 of file lexer.hpp.
◆ is_debug
Flag for debug exception
Definition at line 50 of file lexer.hpp.
◆ keywords
| std::map<std::string, TokenType> Lexer::keywords |
|
private |
Initial value:Keywords table
Definition at line 23 of file lexer.hpp.
◆ line
Line coordinate
Definition at line 21 of file lexer.hpp.
◆ pos
Position index into source code
Definition at line 20 of file lexer.hpp.
◆ source
| std::string Lexer::source |
|
private |
Source code on Topaz
Definition at line 18 of file lexer.hpp.
◆ source_len
Length of source code (optimization)
Definition at line 19 of file lexer.hpp.
The documentation for this class was generated from the following files:
- /mnt/disk_ext4_0/topazlang/include/lexer/lexer.hpp
- /mnt/disk_ext4_0/topazlang/src/lexer/lexer.cpp