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