summaryrefslogtreecommitdiff
path: root/symtable.cc
blob: e963b64d12bf6a2e5fda5ccc605657f3a940b7a3 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "misc.hh"
#include "dimen.hh"
#include "debug.hh"
#include "real.hh"
#include "symbol.hh"
#include "assoc.hh"
#include "symtable.hh"


Symbol 
Symtable::lookup(String s) const
{
    if (elt_query(s))
	return (*this)[s];
    else {
	error( "Unknown symbol " +s+'\n');
    }
}

Symtable* 
Symtables::operator()(String s) 
{
    return Assoc<String, Symtable*>::operator[](s);
} 

void
Symtables::read(Text_db &symini)
{
     while (!symini.eof()) {
	 Text_record  r(  symini++);
	 if (r[0] == "end" )
	     return;
	 assert (r[0] == "table");
	 
	 String tabnam = r[1];
	 Symtable * sp = new Symtable;
	 while (!symini.eof()){
	     r = symini++;
	     if (r[0] == "end")
		 break;
	     
	     assert(r.sz() == 6);
	     int i=0;
	     String id=r[i++];
	     String tex=r[i++];
	     svec<Real> dims;
	     for (int j=0; j < 4; j++)
		 dims.add( parse_dimen(r[i++]));
	     
	     Symbol s(tex, Box(dims));
	     (*sp)[id] = s;
	 }
	 (*this)[tabnam] = sp;	 	 
     }
}