amath
1.8.5
Simple command line calculator
|
Encapsulates an lexical analyzer. Provides token for the parser. More...
#include <lexer.h>
Public Member Functions | |
Lexer (const char *input) | |
~Lexer () | |
void | Tokenize () |
Token * | GetFirstToken () const |
char * | GetInput () const |
Static Public Member Functions | |
static char * | FindKeyword (Symbol symbol) |
Private Member Functions | |
void | GetNextToken () |
bool | GetOperator () |
bool | GetQuotedIdent () |
bool | GetLiteral () |
bool | GetDigitValue () |
Static Private Member Functions | |
static bool | ShouldSkip (char character) |
static Symbol | FindKeyword (const char *ident) |
Private Attributes | |
char * | input |
char * | str |
unsigned int | pos |
Token * | first |
Token * | current |
Encapsulates an lexical analyzer. Provides token for the parser.
More info on lexical analysis is available at Wikipedia: https://wikipedia.org/wiki/Lexical_analysis
|
explicit |
Definition at line 38 of file lexer.cpp.
References AllocAndCopy(), current, first, input, pos, and str.
Referenced by Parser::Parser().
|
static |
Definition at line 248 of file lexer.cpp.
References operatordef::chr, keywords, keyworddef::name, operators, operatordef::symbol, and keyworddef::symbol.
Referenced by PreferencesBase::GetDescription().
|
staticprivate |
Definition at line 243 of file lexer.cpp.
References Language::FindKeyword().
Referenced by GetLiteral().
|
private |
Definition at line 216 of file lexer.cpp.
References current, Program::Input, MemCopy(), NumeralSystem::Parse(), pos, str, symnumber, and Token::Token().
Referenced by GetNextToken().
Token * Lexer::GetFirstToken | ( | ) | const |
Definition at line 62 of file lexer.cpp.
References first.
Referenced by Parser::GetToken(), and Parser::Peek().
char * Lexer::GetInput | ( | ) | const |
Definition at line 57 of file lexer.cpp.
References input.
Referenced by Parser::Parse(), Parser::ParseDigistStatement(), Parser::ParseFileStatement(), Parser::ParseFunctionDef(), Parser::ParseIdent(), Parser::ParseNumeralStatement(), and Parser::TryParseStatement().
|
private |
Definition at line 166 of file lexer.cpp.
References Language::CharIsAlpha(), Language::CharIsDigit(), current, FindKeyword(), MemCopy(), pos, str, symident, and Token::Token().
Referenced by GetNextToken().
|
private |
Definition at line 86 of file lexer.cpp.
References Language::CharIsSpace(), current, GetDigitValue(), GetLiteral(), GetOperator(), GetQuotedIdent(), pos, ShouldSkip(), str, symend, symunknown, and Token::Token().
Referenced by Tokenize().
|
private |
Definition at line 112 of file lexer.cpp.
References operatordef::chr, current, operators, pos, str, operatordef::symbol, and Token::Token().
Referenced by GetNextToken().
|
private |
Definition at line 129 of file lexer.cpp.
References Language::CharIsCntrl(), current, MemCopy(), pos, str, symqident, and Token::Token().
Referenced by GetNextToken().
|
staticprivate |
Definition at line 271 of file lexer.cpp.
References Language::CharIsCntrl(), and Language::CharIsSpace().
Referenced by GetNextToken().
void Lexer::Tokenize | ( | ) |
Definition at line 67 of file lexer.cpp.
References current, first, GetNextToken(), input, Token::next, pos, str, Token::symbol, and symend.
Referenced by Parser::Parse().
|
private |
Definition at line 64 of file lexer.h.
Referenced by GetDigitValue(), GetLiteral(), GetNextToken(), GetOperator(), GetQuotedIdent(), Lexer(), and Tokenize().
|
private |
Definition at line 63 of file lexer.h.
Referenced by GetFirstToken(), Lexer(), Tokenize(), and ~Lexer().
|
private |
Definition at line 60 of file lexer.h.
Referenced by GetInput(), Lexer(), Tokenize(), and ~Lexer().
|
private |
Definition at line 62 of file lexer.h.
Referenced by GetDigitValue(), GetLiteral(), GetNextToken(), GetOperator(), GetQuotedIdent(), Lexer(), and Tokenize().
|
private |
Definition at line 61 of file lexer.h.
Referenced by GetDigitValue(), GetLiteral(), GetNextToken(), GetOperator(), GetQuotedIdent(), Lexer(), and Tokenize().