Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/guisupport/symtabdc.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 |
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 * symtabdc.cpp | |
7 */ | |
8 | |
9 #include "csexp.h" | |
10 #include "dc.h" | |
11 #include "items.h" | |
12 #include "stacks.h" | |
13 #include "symbol.h" | |
14 #include "symtabdc.h" | |
15 #include "token.h" | |
16 #include "tree.h" | |
17 #include "ut.h" | |
18 #include "ws.h" | |
19 | |
20 //#define INCLUDE_LOGGING | |
21 #include "log.h" | |
22 | |
23 | |
24 static int symbol_table_tabs[] = {6,0}; | |
25 | |
26 symbol_table_dc::symbol_table_dc(void) | |
27 : dc("Symbol Table") | |
28 { | |
29 LOGSECTION("symbol_table_dc::symbol_table_dc"); | |
30 des->d_size.y = Symbol::count() - 1; | |
31 LOGV(Symbol::count()); | |
32 | |
33 tab_stops = symbol_table_tabs; | |
34 columnHeadTitle = "Token\tSymbol"; | |
35 } | |
36 | |
37 void symbol_table_dc::getLine(unsigned n) const { | |
38 LOGSECTION("symbol_table_dc::getLine"); | |
39 LOGV(n) LCV(Symbol::count()); | |
40 int vptn; | |
41 | |
42 Symbol symbol = Symbol::sorted(n + 1); | |
43 LOGV(symbol) LCV(symbol->string.pointer()); | |
44 ics(); | |
45 Token token = symbol->token_number; | |
46 LOGV(token); | |
47 if (token.isNotNull()) { | |
48 apprintf("T%03d", (int) token); | |
49 } | |
50 acs('\t'); | |
51 ass(symbol->string.pointer()); | |
52 ParseTree parseTree = symbol->parse_tree; | |
53 LOGV(parseTree); | |
54 if (parseTree.isNotNull()) { | |
55 ass( " = "); | |
56 ass(parseTree->expression->asString().pointer()); | |
57 return; | |
58 } | |
59 LOGV(token->vp_prod_number); | |
60 if (token.isNotNull() && (vptn = token->vp_prod_number) != 0) { | |
61 ass( " = "); | |
62 avptkn(vptn); | |
63 return; | |
64 } | |
65 } | |
66 | |
67 unsigned symbol_table_dc::token(unsigned ln) { | |
68 Symbol symbol = Symbol::sorted(ln + 1); | |
69 return symbol->token_number; | |
70 } | |
71 | |
72 int symbol_table_dc::expansion_rules_ok(unsigned ln) { | |
73 return build_item_list_ok(token(ln)); | |
74 } | |
75 | |
76 dc_ref symbol_table_dc::expansion_rules(unsigned ln) { | |
77 return build_item_list(token(ln)); | |
78 } | |
79 | |
80 int symbol_table_dc::productions_ok(unsigned ln) { | |
81 return productions_window_ok(token(ln)); | |
82 } | |
83 | |
84 dc_ref symbol_table_dc::productions(unsigned ln) { | |
85 return productions_window(token(ln)); | |
86 } | |
87 | |
88 int symbol_table_dc::set_elements_ok(unsigned ln) { | |
89 Symbol symbol = Symbol::sorted(ln + 1); | |
90 int pt = symbol->parse_tree; | |
91 | |
92 if (pt) { | |
93 return char_set_window_ok(map_parse_tree[pt].char_set); | |
94 } | |
95 return token_set_window_ok(symbol->token_number); | |
96 } | |
97 | |
98 dc_ref symbol_table_dc::set_elements(unsigned ln) { | |
99 Symbol symbol = Symbol::sorted(ln + 1); | |
100 int pt = symbol->parse_tree; | |
101 | |
102 if (pt) { | |
103 return char_set_window(map_parse_tree[pt].char_set); | |
104 } | |
105 return token_set_window(symbol->token_number); | |
106 } | |
107 | |
108 int symbol_table_dc::usage_ok(unsigned ln) { | |
109 return token_usage_window_ok(token(ln)); | |
110 } | |
111 | |
112 dc_ref symbol_table_dc::usage(unsigned ln) { | |
113 return token_usage_window(token(ln)); | |
114 } |