BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Public Types | Public Member Functions | Private Attributes | Friends
GMAD::Symtab Class Reference

Common header for the lexer and the parser to share Symbol table for numeric variables, strings, arrays and functions. More...

#include <sym_table.h>

Collaboration diagram for GMAD::Symtab:
Collaboration graph

Public Types

enum class  symtabtype { NUMBER =0 , STRING =1 , ARRAY =2 , FUNCTION =3 }
 
typedef double(* function) (double)
 typedef for function pointer More...
 

Public Member Functions

 Symtab (std::string s)
 Constructor with name. More...
 
void Set (Array *)
 Set to Array value. More...
 
void Set (std::string)
 Set to string. More...
 
void Set (double, bool reserved=false)
 Set to double, optional argument to reserve name (only used for units for now) More...
 
void Set (function)
 Set to function pointer. More...
 
std::string GetName () const
 Get name. More...
 
symtabtype GetType () const
 Get type. More...
 
bool IsReserved () const
 Check if symbol is a reserved name. More...
 
std::list< double > GetArray () const
 Get methods that check on type. More...
 
std::string GetString () const
 Set to string. More...
 
double GetNumber () const
 Set to double. More...
 
function GetFunction () const
 Set to function pointer. More...
 
void Print ()
 Print method. More...
 

Private Attributes

std::string name
 Name of parser symbol. More...
 
bool is_reserved
 Flag is parser symbol is a reserved name. More...
 
symtabtype type
 Enum type. More...
 
function funcptr
 data More...
 
double value
 data More...
 
std::string str
 data More...
 
std::list< double > array
 data More...
 

Friends

class Array
 Symtabs and arrays are kind of interchangeable. More...
 

Detailed Description

Common header for the lexer and the parser to share Symbol table for numeric variables, strings, arrays and functions.

Definition at line 33 of file sym_table.h.

Member Typedef Documentation

◆ function

typedef double(* GMAD::Symtab::function) (double)

typedef for function pointer

Definition at line 45 of file sym_table.h.

Member Enumeration Documentation

◆ symtabtype

enum class GMAD::Symtab::symtabtype
strong

Definition at line 38 of file sym_table.h.

Constructor & Destructor Documentation

◆ Symtab()

Symtab::Symtab ( std::string  s)
explicit

Constructor with name.

Definition at line 28 of file sym_table.cc.

Member Function Documentation

◆ GetArray()

std::list< double > Symtab::GetArray ( ) const

Get methods that check on type.

Definition at line 100 of file sym_table.cc.

References array, and type.

◆ GetFunction()

Symtab::function Symtab::GetFunction ( ) const

Set to function pointer.

Definition at line 110 of file sym_table.cc.

References funcptr, and type.

◆ GetName()

std::string Symtab::GetName ( ) const

Get name.

Definition at line 65 of file sym_table.cc.

References name.

◆ GetNumber()

double Symtab::GetNumber ( ) const

Set to double.

Definition at line 80 of file sym_table.cc.

References type, and value.

◆ GetString()

std::string Symtab::GetString ( ) const

Set to string.

Definition at line 90 of file sym_table.cc.

References str, and type.

◆ GetType()

Symtab::symtabtype Symtab::GetType ( ) const

Get type.

Definition at line 70 of file sym_table.cc.

References type.

◆ IsReserved()

bool Symtab::IsReserved ( ) const

Check if symbol is a reserved name.

Definition at line 75 of file sym_table.cc.

References is_reserved.

◆ Print()

void Symtab::Print ( )

Print method.

Definition at line 120 of file sym_table.cc.

References array, name, str, type, and value.

◆ Set() [1/4]

void Symtab::Set ( Array a)

Set to Array value.

Definition at line 37 of file sym_table.cc.

References array, GMAD::Array::data, and type.

Referenced by GMAD::Parser::add_func().

Here is the caller graph for this function:

◆ Set() [2/4]

void Symtab::Set ( double  a,
bool  reserved = false 
)

Set to double, optional argument to reserve name (only used for units for now)

Definition at line 52 of file sym_table.cc.

References is_reserved, type, and value.

◆ Set() [3/4]

void Symtab::Set ( Symtab::function  a)

Set to function pointer.

Definition at line 59 of file sym_table.cc.

References funcptr, and type.

◆ Set() [4/4]

void Symtab::Set ( std::string  a)

Set to string.

Definition at line 45 of file sym_table.cc.

References str, and type.

Friends And Related Function Documentation

◆ Array

friend class Array
friend

Symtabs and arrays are kind of interchangeable.

Definition at line 36 of file sym_table.h.

Field Documentation

◆ array

std::list<double> GMAD::Symtab::array
private

data

Definition at line 88 of file sym_table.h.

Referenced by GMAD::Array::Array(), GetArray(), Print(), and Set().

◆ funcptr

function GMAD::Symtab::funcptr
private

data

Definition at line 85 of file sym_table.h.

Referenced by GetFunction(), and Set().

◆ is_reserved

bool GMAD::Symtab::is_reserved
private

Flag is parser symbol is a reserved name.

Definition at line 81 of file sym_table.h.

Referenced by IsReserved(), and Set().

◆ name

std::string GMAD::Symtab::name
private

Name of parser symbol.

Definition at line 79 of file sym_table.h.

Referenced by GetName(), and Print().

◆ str

std::string GMAD::Symtab::str
private

data

Definition at line 87 of file sym_table.h.

Referenced by GetString(), Print(), and Set().

◆ type

symtabtype GMAD::Symtab::type
private

Enum type.

Definition at line 83 of file sym_table.h.

Referenced by GetArray(), GetFunction(), GetNumber(), GetString(), GetType(), Print(), and Set().

◆ value

double GMAD::Symtab::value
private

data

Definition at line 86 of file sym_table.h.

Referenced by GetNumber(), Print(), and Set().


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