![]() |
User Guide
|
Represent Lexer/Scanner class for NMODL language parsing. More...
Represent Lexer/Scanner class for NMODL language parsing.
Lexer defined to add some extra function to the scanner class from flex. Flex itself creates yyFlexLexer class, which we renamed using macros to NmodlFlexLexer. But we change the context of the generated yylex() function because the yylex() defined in NmodlFlexLexer has no parameters. Also, note that implementation of the member functions are in nmodl.l file due to use of macros.
Definition at line 60 of file nmodl_lexer.hpp.
#include <nmodl_lexer.hpp>
Public Member Functions | |
void | reset_end_position () |
Reset the column position of lexer to 0. More... | |
virtual NmodlParser::symbol_type | next_token () |
Function for lexer to scan token (replacement for yylex() ) More... | |
void | scan_unit () |
Scan subsequent text as unit. More... | |
std::string | input_line () |
Input text until end of line. More... | |
ast::String * | get_unit () |
Return last scanned unit as ast::String. More... | |
std::string | get_curr_line () const |
Return current line as string. More... | |
void | set_debug (bool b) |
Enable debug output (via yyout) if compiled into the scanner. More... | |
Ctor & dtor | |
NmodlLexer (NmodlDriver &driver, std::istream *in=nullptr, std::ostream *out=nullptr) | |
NmodlLexer constructor. More... | |
~NmodlLexer () override=default | |
Public Attributes | |
location | loc |
location of the parsed token More... | |
Private Attributes | |
NmodlDriver & | driver |
Reference to driver object where this lexer resides. More... | |
ast::String * | last_unit = nullptr |
Units are stored in the scanner (could be stored in the driver though) More... | |
int | lexical_context = 0 |
Context of the reaction (~ ) token. More... | |
std::string | cur_line |
|
inlineexplicit |
NmodlLexer constructor.
driver | NmodlDriver where this lexer resides |
in | Input stream from where tokens will be read |
out | Output stream where output will be sent |
Definition at line 98 of file nmodl_lexer.hpp.
|
overridedefault |
std::string nmodl::parser::NmodlLexer::get_curr_line | ( | ) | const |
Return current line as string.
ast::String* nmodl::parser::NmodlLexer::get_unit | ( | ) |
Return last scanned unit as ast::String.
std::string nmodl::parser::NmodlLexer::input_line | ( | ) |
Input text until end of line.
For construct like TITLE we have to scan text until end of line
|
virtual |
Function for lexer to scan token (replacement for yylex()
)
This is main lexing function generated by flex
according to the macro declaration YY_DECL
. The generated bison parser then calls this virtual function to fetch new tokens. Note that yylex()
has different declaration and hence can't be used for new lexer.
|
inline |
Reset the column position of lexer to 0.
Due to COPY mode the end position is not accurate. Set column to 0 to avoid confusion (see JIRA issue NOCMODL-25)
Definition at line 114 of file nmodl_lexer.hpp.
void nmodl::parser::NmodlLexer::scan_unit | ( | ) |
Scan subsequent text as unit.
For units we have to consume string until end of closing parenthesis and store it in the scanner. This will be later returned by get_unit().
void nmodl::parser::NmodlLexer::set_debug | ( | bool | b | ) |
Enable debug output (via yyout) if compiled into the scanner.
|
private |
Definition at line 82 of file nmodl_lexer.hpp.
|
private |
Reference to driver object where this lexer resides.
The driver object is used for macro definitions and error checking
Definition at line 66 of file nmodl_lexer.hpp.
|
private |
Units are stored in the scanner (could be stored in the driver though)
Definition at line 69 of file nmodl_lexer.hpp.
|
private |
Context of the reaction (~
) token.
For reaction (~
) we return different token based on one of the following lexical context:
Definition at line 80 of file nmodl_lexer.hpp.
location nmodl::parser::NmodlLexer::loc |
location of the parsed token
Definition at line 86 of file nmodl_lexer.hpp.