9 #ifndef _STRUS_BASE_PROGRAM_LEXER_HPP_INCLUDED
10 #define _STRUS_BASE_PROGRAM_LEXER_HPP_INCLUDED
19 class ErrorBufferInterface;
32 int id()
const {
return m_id;}
33 const std::string&
value()
const {
return m_value;}
36 :m_type(type_),m_id(-1),m_value(){}
38 :m_type(o.m_type),m_id(o.m_id),m_value(o.m_value){}
40 :m_type(type_),m_id(id_),m_value(value_){}
41 operator bool()
const {
return !
end();}
44 bool isToken(
int id_)
const {
return m_type ==
Token && m_id == id_;}
100 const char*
pos()
const {
return m_src;}
103 std::size_t
len()
const {
return m_end - m_src;}
125 #if __cplusplus >= 201103L
134 ErrorBufferInterface* m_errhnd;
135 const char* m_eolncomment;
136 std::vector<strus::RegexSearch*> m_lexems;
137 std::vector<strus::RegexSearch*> m_errlexems;
141 char const* m_prevsrc;
142 ProgramLexem m_lexem;
Class for a lexer used for implementing domain specific languages of strus.
Definition: programLexer.hpp:58
ProgramLexem(Type type_, int id_, const std::string &value_)
Definition: programLexer.hpp:39
ProgramLexem(const ProgramLexem &o)
Definition: programLexer.hpp:37
const char * pos() const
Get the current source pointer.
Definition: programLexer.hpp:100
int checkKeyword(int nn,...) const
Definition: programLexer.hpp:88
const ProgramLexem & rescanCurrent()
Rescan the current lexem (with different options)
int id() const
Definition: programLexer.hpp:32
bool setOption(Option opt_, bool value)
Switch lexer option on/off.
Definition: programLexer.hpp:30
const std::string & value() const
Definition: programLexer.hpp:33
const char * nextpos()
Get the start of the next token.
const ProgramLexem & next()
Get the next lexem.
bool isString() const
Definition: programLexer.hpp:46
std::string currentLocationString(int posincr, int size, const char *marker) const
Get an excerpt of the current source location starting from a position with a marker inserted...
Class for a lexem in a domain specific programming language with the following properties.
Definition: programLexer.hpp:27
Definition: programLexer.hpp:30
Definition: programLexer.hpp:30
int lineno() const
Get the current line number.
Interface for reporting and catching errors in modules.
Definition: errorBufferInterface.hpp:24
ProgramLexem(Type type_=Error)
Definition: programLexer.hpp:35
Definition: programLexer.hpp:30
bool isToken() const
Definition: programLexer.hpp:45
bool isError() const
Definition: programLexer.hpp:47
Type type() const
Definition: programLexer.hpp:31
Type
Definition: programLexer.hpp:30
bool isToken(int id_) const
Definition: programLexer.hpp:44
bool end() const
Definition: programLexer.hpp:43
const ProgramLexem & current()
Get the current lexem.
Definition: programLexer.hpp:73
bool isEof() const
Definition: programLexer.hpp:48
bool consumeToken(int tokid)
Skip to next and return true if the current lexem is a token with a defined id.
Definition: programLexer.hpp:78
bool skipto(char const *pos)
Skip to a defined position is the parsed source and scan the next token.
Option
Definition: programLexer.hpp:88
ProgramLexer(const char *src, const char *eolncomment_, const char **tokens, const char **errtokens, ErrorBufferInterface *errhnd_)
Constructor.
Definition: programLexer.hpp:30
std::size_t len() const
Get the rest length to parse.
Definition: programLexer.hpp:103
const char * currentpos()
Get the start of the current token.