User Guide
nmodl::parser::CLexer Class Reference

Represent Lexer/Scanner class for C (11) language parsing. More...

Detailed Description

Represent Lexer/Scanner class for C (11) 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 50 of file c11_lexer.hpp.

#include <c11_lexer.hpp>

Inheritance diagram for nmodl::parser::CLexer:

Public Member Functions

virtual CParser::symbol_type next_token ()
 Function for lexer to scan token (replacement for yylex()) More...
 
CParser::symbol_type get_token_type ()
 Get the type of token just parsed. More...
 
Ctor & dtor
 CLexer (CDriver &driver, std::istream *in=nullptr, std::ostream *out=nullptr)
 CLexer constructor. More...
 
 ~CLexer () override=default
 

Public Attributes

CDriverdriver
 Reference to driver object which contains this lexer instance. More...
 
location loc
 location of the parsed token More...
 

Constructor & Destructor Documentation

◆ CLexer()

nmodl::parser::CLexer::CLexer ( CDriver driver,
std::istream *  in = nullptr,
std::ostream *  out = nullptr 
)
inlineexplicit

CLexer constructor.

Parameters
driverCDriver where this lexer resides
inInput stream from where tokens will be read
outOutput stream where output will be sent

Definition at line 77 of file c11_lexer.hpp.

◆ ~CLexer()

nmodl::parser::CLexer::~CLexer ( )
overridedefault

Member Function Documentation

◆ get_token_type()

CParser::symbol_type nmodl::parser::CLexer::get_token_type ( )

Get the type of token just parsed.

Check if parsed token is either enum, typedef or identifier.

Attention
Not needed anymore and could be removed?
Returns
Symbol encapsulating parsed token

◆ next_token()

virtual CParser::symbol_type nmodl::parser::CLexer::next_token ( )
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.

Returns
Symbol encapsulating parsed token

Member Data Documentation

◆ driver

CDriver& nmodl::parser::CLexer::driver

Reference to driver object which contains this lexer instance.

This is used for error reporting and checking macro definitions.

Reference to driver object where this lexer resides

The driver object can be used from lexer to store/retrieve some global information. Currently this is used for storing all token encountered during lexing.

Definition at line 62 of file c11_lexer.hpp.

◆ loc

location nmodl::parser::CLexer::loc

location of the parsed token

Definition at line 65 of file c11_lexer.hpp.


The documentation for this class was generated from the following file: