Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/guisupport/anom.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-1999 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * anom.cpp - Anomaly diagnosis module | |
7 */ | |
8 | |
9 #include "anom.h" | |
10 #include "cd.h" | |
11 #include "conflictdc.h" | |
12 #include "conflicttrc.h" | |
13 #include "data.h" | |
14 #include "dc.h" | |
15 #include "nckwtr.h" | |
16 #include "rule.h" | |
17 #include "stacks.h" | |
18 #include "tracedc.h" | |
19 #include "ut.h" | |
20 #include "wm1.h" | |
21 #include "ws.h" | |
22 | |
23 //#define INCLUDE_LOGGING | |
24 #include "log.h" | |
25 | |
26 | |
27 static void find_anomaly(int sn, int tn, int fn) { | |
28 LOGSECTION("find_anomaly"); | |
29 analyze_conflict(sn, tn, fn, 1); | |
30 } | |
31 | |
32 static int anomaly_table_tabs[] = {7,13,15,0}; | |
33 | |
34 anomaly_table_dc::anomaly_table_dc(void) | |
35 : dc("Keyword Anomalies") | |
36 { | |
37 LOGSECTION("anomaly_table_dc::anomaly_table_dc"); | |
38 tab_stops = anomaly_table_tabs; | |
39 des->d_size.y = 2*key_mess->nt; | |
40 //getWidth(); | |
41 //des->c_size = cint(des->d_size.x,1); | |
42 //resize_window(); | |
43 } | |
44 | |
45 dc_ref anomaly_table_dc::anomaly_trace(unsigned ln) { | |
46 LOGSECTION("anomaly_table_dc::anomaly_trace"); | |
47 int sn, tn, fn, rs; | |
48 dc_ref new_window; | |
49 tsd *stack; | |
50 | |
51 xtx(key_mess, ln/2, &sn, &tn, &fn, &rs); | |
52 find_anomaly(sn, tn, fn); | |
53 stack = make_stored_trace(&new_conflict_stack[0], | |
54 new_conflict_stack_depth, conflict_token); | |
55 new_window = dc_ref(new trace_window_dc("Keyword Anomaly Trace", | |
56 stack, sn, tn, fn)); | |
57 delete_tsd(stack); | |
58 return new_window; | |
59 } | |
60 | |
61 dc_ref anomaly_table_dc::derive_rule(unsigned ln) { | |
62 LOGSECTION("anomaly_table_dc::derive_rule"); | |
63 int sn,tn,fn,rs; | |
64 | |
65 ln /= 2; | |
66 xtx(key_mess,ln, &sn, &tn, &fn, &rs); | |
67 find_anomaly(sn, tn, fn); | |
68 return build_rule_derivation(sn, fn); | |
69 } | |
70 | |
71 void anomaly_table_dc::getLine(unsigned ln) const { | |
72 LOGSECTION("anomaly_table_dc::getLine"); | |
73 int sn, tn, fn, rs; | |
74 //unsigned char *ks; | |
75 int parity = ln % 2; | |
76 | |
77 ln /= 2; | |
78 xtx(key_mess, ln, &sn, &tn, &fn, &rs); | |
79 //ks = (unsigned char *) dict_str(key_dict,map_token_number[tn].key); | |
80 //ks = (unsigned char *) Keyword(map_token_number[tn].key)->string.pointer(); | |
81 //ks = (unsigned char *) map_token_number[tn].key->string.pointer(); | |
82 //if (parity == 0) ssprintf("S%03d: T%03d = \"%s\"",sn,tn,ks); | |
83 //if (parity == 0) ssprintf("S%03d:\tT%03d\t=\t\"%s\"",sn,tn,ks); | |
84 if (parity == 0) { | |
85 ssprintf("S%03d:\tT%03d\t=\t", sn, tn); | |
86 atkn(tn); | |
87 } | |
88 else { | |
89 //sss(" "); | |
90 sss("\t"); | |
91 append_item(fn, -1); | |
92 } | |
93 } | |
94 | |
95 //#ifndef OLDUI | |
96 int anomaly_table_dc::reduction_states_ok(unsigned ln) { | |
97 LOGSECTION("anomaly_table_dc::reduction_states_ok"); | |
98 int sn, tn, fn, rs; | |
99 | |
100 ln /= 2; | |
101 xtx(key_mess, ln, &sn, &tn, &fn, &rs); | |
102 return reduction_states_window_ok(fn, Rule(fn)->length()); | |
103 } | |
104 //#endif | |
105 | |
106 dc_ref anomaly_table_dc::reduction_states(unsigned ln) { | |
107 LOGSECTION("anomaly_table_dc::reduction_states"); | |
108 int sn, tn, fn, rs; | |
109 | |
110 ln /= 2; | |
111 xtx(key_mess, ln, &sn, &tn, &fn, &rs); | |
112 return reduction_states_window(sn,fn,Rule(fn)->length()); | |
113 } | |
114 | |
115 dc_ref anomaly_table_dc::reduction_trace(unsigned ln) { | |
116 LOGSECTION("anomaly_table_dc::reduction_trace"); | |
117 int sn, tn, fn, rs; | |
118 | |
119 ln /= 2; | |
120 xtx(key_mess, ln, &sn, &tn, &fn, &rs); | |
121 find_anomaly(sn, tn, fn); | |
122 return build_red_trace(sn, tn, fn); | |
123 } | |
124 | |
125 dc_ref anomaly_table_dc::state_definition(unsigned ln) { | |
126 LOGSECTION("anomaly_table_dc::state_definition"); | |
127 int sn, tn, fn, rs; | |
128 | |
129 ln /= 2; | |
130 xtx(key_mess, ln, &sn, &tn, &fn, &rs); | |
131 return conflict_state_window(sn); | |
132 } | |
133 | |
134 void anomaly_table_dc::synchCursor(unsigned ln) const { | |
135 LOGSECTION("anomaly_table_dc::synch_cursor"); | |
136 int sn, tn, fn, rs; | |
137 xtx(key_mess, ln/2, &sn, &tn, &fn, &rs); | |
138 if (fn) { | |
139 set_rule_line(fn); | |
140 } | |
141 } | |
142 | |
143 | |
144 /* End ANOM.C */ |