#include <slexer.hpp>
Collaboration diagram for IntelibSLexAnalyser:
The lexer accepts chars one by one until a whole lexem is ready. The lexer is relatively flexible; it allows to add different keywords, both delimiting or non-delimiting, string literals with any symbol used as quoter, tokens such as #\Newline or the like, and any kind of comments. The lexer is also capable of counting lines on its input.
Definition at line 47 of file slexer.hpp.
Public Types | |
enum | FeedResult { res_empty, res_ready, res_continue, res_eof, res_error } |
The possible results of feeding another character. More... | |
Public Member Functions | |
IntelibSLexAnalyser () | |
The constructor. | |
~IntelibSLexAnalyser () | |
The destructor. | |
bool | AddDelimiter (const char *prefix, const SReference &token) |
Add a delimiter. | |
bool | AddNonDelimiter (const char *prefix, const SReference &token) |
Add a keyword. | |
bool | AddTokenStarter (const char *prefix, SReference(*fun)(const char *str)=0) |
Add a sequence which starts a token. | |
bool | AddStringStarter (const char *prefix, int closer_char, SReference(*fun)(const char *str)=0) |
Add a string literal. | |
bool | AddCommentStarter (const char *prefix, const char *closer="\n") |
Add a comment. | |
FeedResult | FeedChar (int c) |
Give the lexer another character. | |
SReference | Get () const |
Get the lexem when it is ready (FeedChar returned res_ready). | |
int | GetLine () const |
Get the current line number. | |
void | SetLine (int l) |
Set the current line number. | |
const char * | GetErrorMessage () const |
Get the error message in case FeedChar returns res_error. | |
void | Drop () |
Drop and clear all internal data. | |
Classes | |
struct | SpecChar |
|
The possible results of feeding another character.
Definition at line 114 of file slexer.hpp. |
|
The constructor.
Definition at line 28 of file slexer.cpp. |
|
The destructor.
Definition at line 33 of file slexer.cpp. |
|
Add a delimiter.
Definition at line 42 of file slexer.cpp. Referenced by IntelibGenericReader::AddDelimiter(), IntelibGenericReader::AddQuoter(), and IntelibGenericReader::AddSequenceOpener(). |
|
Add a keyword.
Definition at line 52 of file slexer.cpp. Referenced by IntelibGenericReader::AddSequenceOpener(), and IntelibGenericReader::AddToken(). |
|
Add a sequence which starts a token. Token is being read until whitespace or a delimiter Referenced by IntelibGenericReader::AddTokenType(). |
|
Add a string literal.
Referenced by IntelibGenericReader::AddStringLiteral(). |
|
Add a comment.
Definition at line 86 of file slexer.cpp. Referenced by IntelibGenericReader::AddComment(). |
|
Give the lexer another character. See the FeedResult enum explanation for possible results Definition at line 173 of file slexer.cpp. References EOF, res_continue, res_empty, res_eof, res_error, and res_ready. Referenced by IntelibGenericReader::FeedChar(). |
|
Get the lexem when it is ready (FeedChar returned res_ready).
Definition at line 161 of file slexer.cpp. Referenced by IntelibGenericReader::FeedChar(). |
|
Get the current line number.
Definition at line 130 of file slexer.hpp. Referenced by IntelibGenericReader::FeedChar(), and IntelibGenericReader::GetLine(). |
|
Set the current line number.
Definition at line 132 of file slexer.hpp. Referenced by IntelibGenericReader::Read(), and IntelibGenericReader::SetLine(). |
|
Get the error message in case FeedChar returns res_error.
Definition at line 134 of file slexer.hpp. Referenced by IntelibGenericReader::AddDelimiter(), IntelibGenericReader::AddQuoter(), IntelibGenericReader::AddStringLiteral(), IntelibGenericReader::AddToken(), IntelibGenericReader::AddTokenType(), and IntelibGenericReader::FeedChar(). |
|
Drop and clear all internal data.
Definition at line 166 of file slexer.cpp. Referenced by IntelibGenericReader::Drop(). |