User Guide
|
Represent token returned by scanner. More...
Represent token returned by scanner.
Every token returned by lexer is represented by ModToken. Some tokens are also externally defined names like dt
, t
. These names are defined in NEURON and hence we set external property to true. Also, location class represent the position of the token in nmodl file. By default location is initialized to line,column
as 1,1
. Some tokens are explicitly added during compiler passes. Hence we set the position to 0,0
so that we can distinguish them from other tokens produced by lexer.
Definition at line 50 of file modtoken.hpp.
#include <modtoken.hpp>
Public Member Functions | |
ModToken * | clone () const |
Return a new instance of token. More... | |
std::string | text () const |
Return token text from mod file. More... | |
int | type () const |
Return token type from lexer. More... | |
int | start_line () const |
Return line number where token started in the mod file. More... | |
int | start_column () const |
Return start of column number where token appear in the mod file. More... | |
std::string | position () const |
Return position of the token as string. More... | |
Ctor & dtor | |
ModToken () | |
ModToken (bool ext) | |
ModToken (std::string name, int token, LocationType &pos) | |
Private Types | |
using | LocationType = nmodl::parser::location |
Private Attributes | |
std::string | name |
name of the token More... | |
int | token = -1 |
token value returned by lexer More... | |
LocationType | pos |
position of token in the mod file More... | |
bool | external = false |
true if token is externally defined variable (e.g. t , dt in NEURON) More... | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const ModToken &mt) |
Overload << operator to print object. More... | |
ModToken | operator+ (ModToken const &adder1, ModToken const &adder2) |
Overload + operator to create an object whose position starts from the start line and column of the first adder and finishes at the end line and column of the second adder. More... | |
|
private |
Definition at line 51 of file modtoken.hpp.
|
inline |
Definition at line 70 of file modtoken.hpp.
|
inlineexplicit |
Definition at line 73 of file modtoken.hpp.
|
inline |
Definition at line 77 of file modtoken.hpp.
|
inline |
Return a new instance of token.
Definition at line 85 of file modtoken.hpp.
std::string nmodl::ModToken::position | ( | ) | const |
Return position of the token as string.
This is used used by other passes like scope checker to print the location of token in mod files :
[EXTERNAL]
[UNKNOWN]
[line_num.start_column-end_column]
Definition at line 14 of file modtoken.cpp.
|
inline |
Return start of column number where token appear in the mod file.
Definition at line 105 of file modtoken.hpp.
|
inline |
Return line number where token started in the mod file.
Definition at line 100 of file modtoken.hpp.
|
inline |
Return token text from mod file.
Definition at line 90 of file modtoken.hpp.
|
inline |
Return token type from lexer.
Definition at line 95 of file modtoken.hpp.
Overload +
operator to create an object whose position starts from the start line and column of the first adder and finishes at the end line and column of the second adder.
For example:
Output:
Definition at line 32 of file modtoken.cpp.
|
friend |
|
private |
true if token is externally defined variable (e.g. t
, dt
in NEURON)
Definition at line 64 of file modtoken.hpp.
|
private |
name of the token
Definition at line 55 of file modtoken.hpp.
|
private |
position of token in the mod file
Definition at line 61 of file modtoken.hpp.
|
private |
token value returned by lexer
Definition at line 58 of file modtoken.hpp.