GSC Interpreter
A Turing-complete interpreter developed for a compiler course
|
Lexical analyzer for the GSC programming language. More...
#include <scanner.hpp>
Public Member Functions | |
Scanner (std::string_view program) | |
Constructs a Scanner object. | |
void | scanTokens () |
Scans the entire source code and generates a list of tokens. | |
std::vector< Token > | getTokens () const |
Private Member Functions | |
void | addToken (TokenType type) |
void | addToken (TokenType type, std::any literal) |
void | scanToken () |
void | identifier () |
void | number () |
void | string () |
bool | match (const char &expected) |
char | peek () const |
char | peekNext () const |
bool | isAtEnd () const |
char | advance () |
Private Attributes | |
std::string_view | program |
std::vector< Token > | tokens |
int | start = 0 |
int | current = 0 |
int | line = 1 |
Lexical analyzer for the GSC programming language.
The Scanner class is responsible for tokenizing the input source code. It reads the source code character by character and generates a list of tokens that represent the structure of the code.
Definition at line 23 of file scanner.hpp.
Scanner::Scanner | ( | std::string_view | program | ) |
Constructs a Scanner object.
program | The source code to be scanned. |
Definition at line 167 of file scanner.cpp.
|
private |
Definition at line 12 of file scanner.cpp.
|
private |
Definition at line 14 of file scanner.cpp.
|
private |
Definition at line 165 of file scanner.cpp.
std::vector< Token > Scanner::getTokens | ( | ) | const |
Definition at line 180 of file scanner.cpp.
|
private |
Definition at line 98 of file scanner.cpp.
|
private |
Definition at line 161 of file scanner.cpp.
|
private |
Definition at line 138 of file scanner.cpp.
|
private |
Definition at line 109 of file scanner.cpp.
|
private |
Definition at line 147 of file scanner.cpp.
|
private |
|
private |
Definition at line 19 of file scanner.cpp.
void Scanner::scanTokens | ( | ) |
Scans the entire source code and generates a list of tokens.
Definition at line 171 of file scanner.cpp.
|
private |
Definition at line 119 of file scanner.cpp.
|
private |
Definition at line 28 of file scanner.hpp.
|
private |
Definition at line 29 of file scanner.hpp.
|
private |
Definition at line 25 of file scanner.hpp.
|
private |
Definition at line 27 of file scanner.hpp.
|
private |
Definition at line 26 of file scanner.hpp.