#include <Lex.hpp>
Public Types | |
enum | Token { Keyword, Operator, Newline, Eof, String, Name, Integer, Double } |
Public Member Functions | |
Lex (Instance *inst) | |
Instance * | instance () const |
void | DefineKeyword (const char *keyword) |
void | DefineOperator (const char *op) |
void | numbers_enabled (bool enabled) |
void | Init (std::istream &in, bool single_line=false) |
void | Close () |
void | DisableNewlineSkipping () |
void | EnableNewlineSkipping () |
bool | IsNext (Token token) |
bool | IsNextKeyword (const char *keyword) |
bool | IsNextOperator (const char *op) |
Token | GetNextToken () |
std::string | GetNextTokenValue () |
void | Accept (Token token) |
void | AcceptKeyword (const char *keyword) |
void | AcceptOperator (const char *op) |
void | AcceptFail () |
No more options for accept are available. This accept always fails. More... | |
std::string | AcceptString () |
std::string | AcceptName () |
int | AcceptInteger () |
double | AcceptDouble () |
void | Recover (Token token) |
void | RecoverKeyword (const char *keyword) |
void | RecoverOperator (const char *op) |
int | GetLine () const |
int | GetColumn () const |
void | LogicFail (const char *message) |
void | ParserFail (const char *prefix=nullptr) |
bool | Failed () |
Public Attributes | |
ClientMarker | cm |
Detailed Description
Member Enumeration Documentation
◆ Token
enum iv::Lex::Token |
Constructor & Destructor Documentation
◆ Lex()
Member Function Documentation
◆ instance()
◆ DefineKeyword()
◆ DefineOperator()
◆ numbers_enabled()
void iv::Lex::numbers_enabled | ( | bool | enabled | ) |
◆ Init()
void iv::Lex::Init | ( | std::istream & | in, |
bool | single_line = false |
||
) |
Starts parsing of given input. First token is retrieved and pointer to stream is saved. Stream is released when Token::Eof is read or when Fail is called. So if we stop parsing before Eof is reached, Fail should be called. Param fileid is only used in error reports to tell user, which file contains given syntactic error.
◆ Close()
◆ DisableNewlineSkipping()
void iv::Lex::DisableNewlineSkipping | ( | ) |
Newline skipping is enabled by default. When newline skipping is enabled, the newlines will be processed (skipped) as whitespaces. Otherwise each newline is considered a specific token Newline and needs to be accepted before processing tokens that follow on next line.
◆ EnableNewlineSkipping()
◆ IsNext()
bool iv::Lex::IsNext | ( | Token | token | ) |
◆ IsNextKeyword()
◆ IsNextOperator()
◆ GetNextToken()
Lex::Token iv::Lex::GetNextToken | ( | ) |
◆ GetNextTokenValue()
◆ Accept()
void iv::Lex::Accept | ( | Token | token | ) |
◆ AcceptKeyword()
◆ AcceptOperator()
◆ AcceptFail()
void iv::Lex::AcceptFail | ( | ) |
◆ AcceptString()
◆ AcceptName()
◆ AcceptInteger()
◆ AcceptDouble()
◆ Recover()
void iv::Lex::Recover | ( | Token | token | ) |
This can be used to recover after a parser or logic fail (will not be effective in case of lexan or input fail). If Lex is not failed, this will do nothing. If Lex is failed, tokens will be read until specified token is found (or Eof occures). This token will be the next token (IsNext, can be Accepted) after recovery. In case of unrecoverable fail (IO or lexan fail), this will also have no effect.
◆ RecoverKeyword()
◆ RecoverOperator()
◆ GetLine()
int iv::Lex::GetLine | ( | ) | const |
◆ GetColumn()
◆ LogicFail()
void iv::Lex::LogicFail | ( | const char * | message | ) |
◆ ParserFail()
◆ Failed()
Member Data Documentation
◆ cm
ClientMarker iv::Lex::cm |
The documentation for this class was generated from the following files: