User Guide
Unit Implementation

Units handling implementation details. More...

Detailed Description

Units handling implementation details.

Classes

class  nmodl::parser::UnitLexer
 Represent Lexer/Scanner class for Units parsing. More...
 
class  nmodl::parser::UnitDriver
 Class that binds all pieces together for parsing C units. More...
 
class  nmodl::units::Unit
 Class that stores all the data of a Unit. More...
 
class  nmodl::units::Prefix
 Class that stores all the data of a prefix. More...
 
class  nmodl::units::UnitTable
 Class that stores all the units, prefixes and names of base units used. More...
 

Functions

virtual UnitParser::symbol_type nmodl::parser::UnitLexer::next_token ()
 Function for lexer to scan token (replacement for yylex()) More...
 
bool nmodl::parser::UnitDriver::parse_stream (std::istream &in)
 parse Units file provided as istream More...
 
bool nmodl::parser::UnitDriver::parse_string (const std::string &input)
 parser Units provided as string (used for testing) More...
 
bool nmodl::parser::UnitDriver::parse_file (const std::string &filename)
 parse Units file More...
 
void nmodl::parser::UnitDriver::set_verbose (bool b)
 
bool nmodl::parser::UnitDriver::is_verbose () const
 

Variables

location nmodl::parser::UnitLexer::loc
 location of the parsed token More...
 
UnitLexernmodl::parser::UnitDriver::lexer = nullptr
 pointer to the lexer instance being used More...
 
UnitParser * nmodl::parser::UnitDriver::parser = nullptr
 pointer to the parser instance being used More...
 
bool nmodl::parser::UnitDriver::verbose = false
 print messages from lexer/parser More...
 
std::shared_ptr< nmodl::units::UnitTablenmodl::parser::UnitDriver::table = std::make_shared<nmodl::units::UnitTable>()
 shared pointer to the UnitTable that stores all the unit definitions More...
 
std::string nmodl::parser::UnitDriver::stream_name
 file or input stream name (used by scanner for position), see todo More...
 
static constexpr int nmodl::units::MAX_DIMS = 10
 Maximum number of dimensions of units (maximum number of base units) More...
 

Ctor & dtor

 nmodl::parser::UnitLexer::UnitLexer (UnitDriver &, std::istream *in=nullptr, std::ostream *out=nullptr)
 UnitLexer constructor. More...
 
 nmodl::parser::UnitLexer::~UnitLexer () override=default
 

Ctor & dtor

 nmodl::parser::UnitDriver::UnitDriver ()=default
 
 nmodl::parser::UnitDriver::UnitDriver (bool strace, bool ptrace)
 

Function Documentation

◆ is_verbose()

bool nmodl::parser::UnitDriver::is_verbose ( ) const
inline

Definition at line 73 of file unit_driver.hpp.

◆ next_token()

virtual UnitParser::symbol_type nmodl::parser::UnitLexer::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

◆ parse_file()

bool nmodl::parser::UnitDriver::parse_file ( const std::string &  filename)

parse Units file

Definition at line 29 of file unit_driver.cpp.

◆ parse_stream()

bool nmodl::parser::UnitDriver::parse_stream ( std::istream &  in)

parse Units file provided as istream

Definition at line 18 of file unit_driver.cpp.

◆ parse_string()

bool nmodl::parser::UnitDriver::parse_string ( const std::string &  input)

parser Units provided as string (used for testing)

Definition at line 40 of file unit_driver.cpp.

◆ set_verbose()

void nmodl::parser::UnitDriver::set_verbose ( bool  b)
inline

Definition at line 69 of file unit_driver.hpp.

◆ UnitDriver() [1/2]

nmodl::parser::UnitDriver::UnitDriver ( )
default

◆ UnitDriver() [2/2]

nmodl::parser::UnitDriver::UnitDriver ( bool  strace,
bool  ptrace 
)

◆ UnitLexer()

nmodl::parser::UnitLexer::UnitLexer ( UnitDriver ,
std::istream *  in = nullptr,
std::ostream *  out = nullptr 
)
inlineexplicit

UnitLexer constructor.

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

Definition at line 64 of file unit_lexer.hpp.

◆ ~UnitLexer()

nmodl::parser::UnitLexer::~UnitLexer ( )
overridedefault

Variable Documentation

◆ lexer

UnitLexer* nmodl::parser::UnitDriver::lexer = nullptr
private

pointer to the lexer instance being used

Definition at line 42 of file unit_driver.hpp.

◆ loc

location nmodl::parser::UnitLexer::loc

location of the parsed token

Definition at line 52 of file unit_lexer.hpp.

◆ MAX_DIMS

constexpr int nmodl::units::MAX_DIMS = 10
staticconstexpr

Maximum number of dimensions of units (maximum number of base units)

Definition at line 42 of file units.hpp.

◆ parser

UnitParser* nmodl::parser::UnitDriver::parser = nullptr
private

pointer to the parser instance being used

Definition at line 45 of file unit_driver.hpp.

◆ stream_name

std::string nmodl::parser::UnitDriver::stream_name

file or input stream name (used by scanner for position), see todo

Definition at line 55 of file unit_driver.hpp.

◆ table

std::shared_ptr<nmodl::units::UnitTable> nmodl::parser::UnitDriver::table = std::make_shared<nmodl::units::UnitTable>()

shared pointer to the UnitTable that stores all the unit definitions

Definition at line 52 of file unit_driver.hpp.

◆ verbose

bool nmodl::parser::UnitDriver::verbose = false
private

print messages from lexer/parser

Definition at line 48 of file unit_driver.hpp.