Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/agcore/data.h @ 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 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * data.h | |
7 */ | |
8 | |
9 #ifndef DATA_H | |
10 #define DATA_H | |
11 | |
12 #include <stdio.h> | |
13 #include "port.h" | |
14 | |
15 struct list_dict; // from dict.h | |
16 struct tuple_dict; // from dict.h | |
17 struct tsd; // from tsd.h | |
18 #include "agstack.h" | |
19 | |
20 | |
21 enum syntax_states { | |
22 syntax_reset, | |
23 syntax_loaded, | |
24 syntax_error, | |
25 syntax_parsed, | |
26 syntax_analyzed, | |
27 engine_built | |
28 }; | |
29 | |
30 struct conflict_type { | |
31 tsd *ct; | |
32 int *pv; | |
33 int ns; | |
34 }; | |
35 | |
36 class Problem { | |
37 public: | |
38 char *msg; | |
39 Problem(char *m) : msg(m) {} | |
40 Problem(const Problem &problem) : msg(problem.msg) {} | |
41 }; | |
42 | |
43 | |
44 template <class T> | |
45 struct Triple { | |
46 T x, y, z; | |
47 public: | |
48 Triple() : x(0), y(0), z(0) {} | |
49 Triple(const T x_, const T y_, const T z_) : x(x_), y(y_), z(z_) {} | |
50 Triple<T> &values(T &rx, T &ry, T&rz) { rx=x, ry=y, rz=z; return *this; } | |
51 int operator < (const Triple<T> &t) const; | |
52 }; | |
53 | |
54 template <class T> | |
55 int Triple<T>::operator < (const Triple<T> &t) const { | |
56 if (x < t.x) return 1; | |
57 if (t.x < x) return 0; | |
58 if (y < t.y) return 1; | |
59 if (t.y < y) return 0; | |
60 return z < t.z; | |
61 } | |
62 | |
63 | |
64 template <class T> | |
65 struct OrderedPair { | |
66 T x, y; | |
67 public: | |
68 OrderedPair() : x(0), y(0) {} | |
69 OrderedPair(const T x_, const T y_) : x(x_), y(y_) {} | |
70 OrderedPair<T> &values(T &rx, T &ry) { rx=x, ry=y; return *this; } | |
71 int operator < (const OrderedPair<T> &t) const; | |
72 }; | |
73 | |
74 template <class T> | |
75 int OrderedPair<T>::operator < (const OrderedPair<T> &t) const { | |
76 if (x < t.x) return 1; | |
77 if (t.x < x) return 0; | |
78 return y < t.y; | |
79 } | |
80 | |
81 //////////////////////////////////////////////////////////// | |
82 | |
83 extern tuple_dict *frss_dict; | |
84 | |
85 extern tsd *unres_con; | |
86 extern tsd *res_con; | |
87 extern int precedence_level; | |
88 extern int enum_base; | |
89 | |
90 extern tsd *prr; | |
91 extern tsd *key_mess; | |
92 extern tsd *rename_macro_list; | |
93 | |
94 extern int void_token_type; | |
95 extern int int_token_type; | |
96 extern int long_token_type; | |
97 extern unsigned nprods; | |
98 | |
99 extern syntax_states syntax_state; | |
100 | |
101 extern const char *syntaxStateString[]; | |
102 | |
103 struct char_set_map { | |
104 unsigned part_index; | |
105 int nparts; | |
106 int parse_tree; | |
107 }; | |
108 | |
109 extern char_set_map *map_char_set; | |
110 extern unsigned *part_list; | |
111 extern unsigned *chars_list; | |
112 | |
113 extern list_dict *char_set_dict; | |
114 extern list_dict *key_list_dict; | |
115 extern list_dict *part_dict; | |
116 extern list_dict *prod_dict; | |
117 extern list_dict *vp_prod_dict; | |
118 | |
119 struct vp_prod_number_map { | |
120 int token_number; | |
121 }; | |
122 | |
123 extern vp_prod_number_map *map_vp_prod_number; | |
124 | |
125 extern unsigned *previous_states_list; | |
126 extern unsigned *completed_forms_list; | |
127 extern unsigned *gotos_list; | |
128 extern unsigned *reductions_list; | |
129 extern unsigned *a_actions_list; | |
130 extern unsigned *t_actions_list; | |
131 extern unsigned *p_actions_list; | |
132 extern unsigned *completions_list; | |
133 extern unsigned *chain_completions_list; | |
134 extern unsigned *chain_gotos_list; | |
135 extern unsigned *reduction_states_list; | |
136 extern unsigned nstates; | |
137 | |
138 struct part_number_map { | |
139 unsigned chars_index; | |
140 int size; | |
141 unsigned token_number; | |
142 }; | |
143 | |
144 extern part_number_map *map_part_number; | |
145 | |
146 struct char_number_map { | |
147 unsigned token_number; | |
148 unsigned part_number; | |
149 unsigned token_name; | |
150 }; | |
151 | |
152 extern char_number_map *map_char_number; | |
153 extern int max_char_number; | |
154 extern int min_char_number; | |
155 extern unsigned n_chars; | |
156 | |
157 /* flags */ | |
158 | |
159 extern FILE *h_file; | |
160 extern FILE *pe_file; | |
161 | |
162 extern char *key_ends; | |
163 extern tsd *key_table; | |
164 extern unsigned n_key_ends; | |
165 extern int max_key_length; | |
166 | |
167 extern int character_seen; | |
168 | |
169 extern AgStack<int> distinguishSets; | |
170 | |
171 void init_data(void); | |
172 void reset_summary_data(void); | |
173 void reset_result_data(void); | |
174 | |
175 | |
176 #endif /* DATA_H */ |