Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/agcore/symbol.cpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children | 607e3be6bad8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, A System for Syntax Directed Programming | |
3 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * symbol.cpp | |
7 */ | |
8 | |
9 #include "symbol.h" | |
10 #include "stacks.h" | |
11 | |
12 //#define INCLUDE_LOGGING | |
13 #include "log.h" | |
14 | |
15 | |
16 Symbol::Symbol(unsigned x) : KeyedObjectRegister<SymbolDescriptor>(x) {} | |
17 Symbol::Symbol(const Symbol &t) : KeyedObjectRegister<SymbolDescriptor>(t) {} | |
18 | |
19 Symbol::Symbol(const char *x) | |
20 : KeyedObjectRegister<SymbolDescriptor>(SymbolDescriptor(x)) | |
21 { | |
22 // Nothing to do | |
23 } | |
24 | |
25 void Symbol::reset() { | |
26 LOGSECTION("Symbol::reset"); | |
27 KeyedObjectRegister<SymbolDescriptor>::reset(); | |
28 //descriptorList.push(SymbolDescriptor()); | |
29 Symbol(""); | |
30 LOGV(descriptorList.size()) LCV(Symbol()->string); | |
31 } | |
32 | |
33 Symbol Symbol::sorted(int x) { | |
34 LOGSECTION("Symbol::sorted"); | |
35 LOGV(x); | |
36 Symbol symbol = tree[x]; | |
37 LOGV(symbol) LCV(symbol->string); | |
38 return symbol; | |
39 } | |
40 | |
41 Symbol Symbol::create() { | |
42 LOGSECTION("Symbol::create"); | |
43 tss(); | |
44 LOGV(string_base); | |
45 Symbol symbol(string_base); | |
46 rcs(); | |
47 LOGV(symbol); | |
48 return symbol; | |
49 } | |
50 | |
51 Symbol add_string_dict(const char *s, Symbol::Dict &d) { | |
52 return d.add_string(s); | |
53 } | |
54 | |
55 Symbol::Map map_token_name; | |
56 Symbol::Dict tkn_dict; | |
57 | |
58 SymbolDescriptor &Symbol::Map::operator [] (unsigned x) { | |
59 LOGSECTION("Symbol::Map::operator []"); | |
60 LOGV(x) LCV(descriptorList.size()); | |
61 assert(x < Symbol::descriptorList.size()); | |
62 return Symbol::descriptorList[x]; | |
63 } | |
64 | |
65 Symbol Symbol::Dict::add_string(const char *s) { | |
66 return Symbol(s); | |
67 } | |
68 | |
69 SymbolDescriptor::SymbolDescriptor() | |
70 : token_list_id(0) | |
71 { | |
72 // Nothing to do | |
73 } | |
74 | |
75 SymbolDescriptor::SymbolDescriptor(const char *s) | |
76 : string(s), token_list_id(0) | |
77 { | |
78 // Nothing to do | |
79 } | |
80 | |
81 int SymbolDescriptor::operator < (const SymbolDescriptor &d) const { | |
82 return string < d.string; | |
83 } |