comparison anagram/guisupport/ruletabdc.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 * ruletabdc.cpp
7 */
8
9 #include "dc.h"
10 #include "items.h"
11 #include "q1a.h"
12 #include "q1glbl.h"
13 #include "ruletabdc.h"
14 #include "stacks.h"
15 #include "token.h"
16 #include "ut.h"
17 #include "wm1.h"
18 #include "ws.h"
19
20 //#define INCLUDE_LOGGING
21 #include "log.h"
22
23
24 rule_table_dc::localize::localize(unsigned ln) {
25 LOGSECTION("rule_table_dc::localize::localize");
26 int rn = 1;
27 unsigned nc = ibnfn[1] + 1;
28 int lc = 0;
29
30 while (nc <= ln) {
31 lc = nc;
32 nc += ibnfn[++rn] + 1;
33 }
34 rule = rn;
35 index = ln-lc;
36 LOGV(ln) LCV(rule) LCV(index) LCV(lc) LCV(nc);
37 }
38
39 int rule_table_dc::expansion_rules_ok(unsigned ln) {
40 localize x(ln);
41 return build_item_list_ok(x.token());
42 }
43
44 dc_ref rule_table_dc::expansion_rules(unsigned ln) {
45 localize x(ln);
46 return build_item_list(x.token());
47 }
48
49
50 int rule_table_dc::productions_ok(unsigned ln) {
51 localize x(ln);
52 return productions_window_ok(x.token());
53 }
54
55 dc_ref rule_table_dc::productions(unsigned ln) {
56 localize x(ln);
57 return productions_window(x.token());
58 }
59
60 int rule_table_dc::usage_ok(unsigned ln) {
61 localize x(ln);
62 return token_usage_window_ok(x.token());
63 }
64
65 dc_ref rule_table_dc::usage(unsigned ln) {
66 localize x(ln);
67 return token_usage_window(x.token());
68 }
69
70 dc_ref rule_table_dc::rule_context(unsigned ln) {
71 localize x(ln);
72 return rule_context_window(x.rule);
73 }
74
75
76 static int rule_table_tabs[] = {7,0};
77
78 void rule_table_dc::getLine(unsigned ln) const {
79 LOGSECTION("rule_table_dc::getLine");
80 localize x(ln);
81 unsigned nt = ibnfn[x.rule];
82 LOGV(ln) LCV(nt);
83 if (x.index < nt) {
84 int tn = ibnfs[ibnfb[x.rule] + x.index];
85 ssprintf("T%03d:\t", tn);
86 atkn(tn);
87 return;
88 }
89 sss("\t -> ");
90 append_item(x.rule, -1);
91 }
92
93 void rule_table_dc::synchCursor(unsigned ln) const {
94 LOGSECTION("rule_table_dc::synchCursor");
95 LOGV(ln);
96 localize x(ln);
97 if (x.rule) {
98 set_rule_line(x.rule);
99 }
100 }
101
102 rule_table_dc::rule_table_dc(void)
103 : dc("Rule Table")
104 {
105 int lc = 0;
106 unsigned fn = 0;
107
108 tab_stops = rule_table_tabs;
109 columnHeadTitle = "Token\tProduction";
110 while (fn++ < nforms) {
111 lc += ibnfn[fn] + 1;
112 }
113 des->d_size.y = lc;
114 des->d_size.x = rule_table_tabs[1] + item_length;
115 }
116