BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
__w
bdsim
bdsim
parser
symbolmap.cc
1
/*
2
Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4
This file is part of BDSIM.
5
6
BDSIM is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published
8
by the Free Software Foundation version 3 of the License.
9
10
BDSIM is distributed in the hope that it will be useful, but
11
WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
#include "symbolmap.h"
19
20
#include "sym_table.h"
21
22
#include <cstdlib>
23
#include <iostream>
24
25
using namespace
GMAD
;
26
27
Symtab
*
SymbolMap::symcreate
(std::string s)
28
{
29
std::map<std::string,Symtab*>::iterator it =
symtab_map
.find(s);
30
if
(it!=
symtab_map
.end())
31
{
32
std::cerr <<
"ERROR Variable "
<< s <<
" is already defined!"
<< std::endl;
33
exit(1);
34
}
35
36
Symtab
* sp =
new
Symtab
(s);
37
std::pair<std::map<std::string,Symtab*>::iterator,
bool
> ret =
symtab_map
.insert(std::make_pair(s,sp));
38
return
(*(ret.first)).second;
39
}
40
41
Symtab
*
SymbolMap::symlook
(std::string s)
42
{
43
std::map<std::string,Symtab*>::iterator it =
symtab_map
.find(s);
44
return
it ==
symtab_map
.end() ? nullptr : (*it).second;
45
}
46
47
void
SymbolMap::clear
()
48
{
49
for
(
auto
& kv :
symtab_map
)
50
{
delete
kv.second;}
51
symtab_map
.clear();
52
}
GMAD::SymbolMap::clear
void clear()
Destructor that clears memory.
Definition
symbolmap.cc:47
GMAD::SymbolMap::symtab_map
std::map< std::string, Symtab * > symtab_map
Parser symbol map.
Definition
symbolmap.h:43
GMAD::SymbolMap::symlook
Symtab * symlook(std::string s)
Look up parser symbol.
Definition
symbolmap.cc:41
GMAD::SymbolMap::symcreate
Symtab * symcreate(std::string s)
Create new parser symbol.
Definition
symbolmap.cc:27
GMAD::Symtab
Common header for the lexer and the parser to share Symbol table for numeric variables,...
Definition
sym_table.h:32
GMAD
Parser namespace for GMAD language. Combination of Geant4 and MAD.
Definition
BDSBeamlineIntegral.hh:26
Generated on Thu Nov 12 2026 21:36:59 for BDSIM by
1.9.8