not needed
[prop.git] / prop-src / parser.h
blob03745aa6f03e467dc27baf87d062e40f5f89d4ad
1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.6),
3 // last updated on Nov 2, 1999.
4 // The original source file is "parser.ph".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_PARSER_USED
8 #include <propdefs.h>
9 #line 1 "parser.ph"
10 ///////////////////////////////////////////////////////////////////////////////
12 // Definition of the Prop parser.
14 ///////////////////////////////////////////////////////////////////////////////
15 #ifndef prop_parser_interface_h
16 #define prop_parser_interface_h
18 #include <iostream>
19 #include <AD/automata/iolexerstack.h>
20 #include "ir.h"
21 #include "ast.h"
22 #include "patenv.h"
23 #include "textbuf.h"
25 class Compiler;
26 class GraphTypeDef;
28 ///////////////////////////////////////////////////////////////////////////////
30 // Lexical contexts
32 ///////////////////////////////////////////////////////////////////////////////
33 #line 24 "parser.ph"
34 #line 24 "parser.ph"
35 enum LexicalContext {
36 NONE = 0, C = 1, PROP = 2,
37 COMMENT = 3, QUOTE = 4, ANTIQUOTE = 5
43 #line 24 "parser.ph"
44 #line 24 "parser.ph"
47 ///////////////////////////////////////////////////////////////////////////////
49 // The syntax class PropParser describe the interface to the
50 // parsing/lexing front end.
52 ///////////////////////////////////////////////////////////////////////////////
53 #line 32 "parser.ph"
54 #line 185 "parser.ph"
55 class PropParser : public LR1Parser {
56 public:
57 ////////////////////////////////////////////////////////////////////////////
58 // Parser table type definitions
59 ////////////////////////////////////////////////////////////////////////////
60 typedef LR1Parser Super;
61 typedef Super::Offset Offset;
62 typedef Super::State State;
63 typedef Super::Rule Rule;
64 typedef Super::Symbol Symbol;
65 typedef Super::ProductionLength ProductionLength;
66 typedef Super::ShortSymbol ShortSymbol;
67 typedef Super::EquivMap EquivMap;
68 enum { INITIAL_STACK_SIZE_ = 256,
69 MAX_STACK_SIZE_ = 8192
71 protected:
72 ////////////////////////////////////////////////////////////////////////////
73 // Semantic value stack
74 ////////////////////////////////////////////////////////////////////////////
75 union PropParser_semantic_stack_type * t__, * bot__;
76 int stack_size__;
77 int heap_allocated__;
78 public:
79 ////////////////////////////////////////////////////////////////////////////
80 // Constructor and parsing method
81 ////////////////////////////////////////////////////////////////////////////
82 PropParser();
83 virtual void parse();
84 void action_driver(const Rule);
85 private:
86 void adjust_stack(int);
87 void grow_semantic_stack();
88 #line 33 "parser.ph"
89 PropParser(const PropParser&);
90 void operator = (const PropParser&);
91 private:
92 enum { MAX_LEXICAL_DEPTH = 256,
93 MAX_ARITY = 256,
94 MAX_INCLUDE_FILES = 256
97 ////////////////////////////////////////////////////////////////////////////
98 // Lexical buffer
99 ////////////////////////////////////////////////////////////////////////////
100 IOLexerStack lexbuf;
102 ////////////////////////////////////////////////////////////////////////////
103 // Lexical context stack. This is used to keep track of the
104 // current lexical context.
105 ////////////////////////////////////////////////////////////////////////////
106 LexicalContext SCs[MAX_LEXICAL_DEPTH];
107 int SCs_top;
108 int levels[MAX_LEXICAL_DEPTH];
109 int levels_top;
110 Decls code_stack[MAX_LEXICAL_DEPTH];
111 int code_top;
112 void start_sc (LexicalContext); // enter a new lexical context
113 void end_sc (); // leave the current lexical context
115 ////////////////////////////////////////////////////////////////////////////
116 // Quoting stack
117 ////////////////////////////////////////////////////////////////////////////
118 struct Quote {
119 const char * file_name;
120 int line_number;
121 char open, close;
122 Quote() {}
123 Quote(const char * file, int line, char a, char b)
124 : file_name(file), line_number(line), open(a), close(b) {}
126 Quote quote_stack[MAX_LEXICAL_DEPTH];
127 int quote_top;
128 void start_quote(char, char);
129 char end_quote (char);
130 void start_statement ();
131 void end_statement ();
133 ////////////////////////////////////////////////////////////////////////////
134 // Internal code and documentation buffer.
135 ////////////////////////////////////////////////////////////////////////////
136 Bool emit_code;
137 TextBuffer scan;
138 TextBuffer doc;
139 TextBuffer meta;
140 void emit ();
141 void emit (char);
142 void emit (const char *, long = -1);
143 void emit (Exp);
144 void emit_cons (Id cons_name);
145 void emit_doc ();
146 void emit_meta ();
147 void emit_header ();
148 void count_lines ();
150 ////////////////////////////////////////////////////////////////////////////
151 // Pattern variable environment and match expression stack
152 ////////////////////////////////////////////////////////////////////////////
153 PatternVarEnv pv_env; // pattern variable environment
154 MatchExps me_stack[MAX_LEXICAL_DEPTH]; // match expression stack
155 MatchOptions match_kind[MAX_LEXICAL_DEPTH]; // kind of match construct
156 int me_top; // top of me stack
158 ////////////////////////////////////////////////////////////////////////////
159 // Variable binding stack
160 ////////////////////////////////////////////////////////////////////////////
161 Id var_stack[MAX_ARITY];
162 Pat pat_stack[MAX_ARITY];
163 int var_top;
165 ////////////////////////////////////////////////////////////////////////////
166 // Include file stack
167 ////////////////////////////////////////////////////////////////////////////
168 struct IncludeFile
169 { int line;
170 int first_line;
171 const char * file;
172 std::istream * file_stream;
173 TextBuffer scan;
174 TextBuffer doc;
175 TextBuffer meta;
177 IncludeFile includes[MAX_INCLUDE_FILES];
178 int includes_top;
179 const char * included_files[MAX_INCLUDE_FILES];
180 int included_count;
182 ////////////////////////////////////////////////////////////////////////////
183 // Miscellaneous flags and counters
184 ////////////////////////////////////////////////////////////////////////////
185 int antecedent_count; // number of antecedents in an inference rule
186 Bool in_rewrite; // are we in rewriting?
187 int rule_count; // number of rules
188 int is_view_def; // are we in a view definition?
189 int symbol_count; // number of symbols in a production
190 int item_count; // number of items in a production
191 int nonterm_count; // number of non-terminals in a production
192 int match_rule;
193 int constraint_rule;
195 struct rewrite_info
196 { MatchRuleInfo::RewritingMode mode; // current rewrite mode
197 MatchRuleInfo::RewritingOption option;
198 TyQual qual;
199 } rw_stack[MAX_LEXICAL_DEPTH]; // kind of rewriting mode
200 int rw_top; // top of rw stack
201 void push_rw_stack();
202 void pop_rw_stack();
204 ////////////////////////////////////////////////////////////////////////////
205 // The program being constructed.
206 ////////////////////////////////////////////////////////////////////////////
207 Cons my_cons;
208 Exp my_exp;
209 Compiler * compiler; // the current compiler
210 GraphTypeDef * graphtype_def; // the current graph type definition
212 public:
213 ////////////////////////////////////////////////////////////////////////////
214 // The public interface
215 ////////////////////////////////////////////////////////////////////////////
216 virtual ~PropParser();
218 int get_token (); // method to retrieve a token
219 int get_token2 (); // method to retrieve a token
220 ErrorAction error_report (const char *); // error reporting.
221 void initialize (Compiler&);
222 void initialize_lexer (const char * file_name);
223 void cleanup_lexer();
224 void print_header(Compiler&);
225 Decls program;
227 private:
228 void open_include_file (const char *); // open a new include file
229 void close_include_file (); // close include file
231 Decls mkcode (Decls);
232 Pat mkconspat (Cons);
233 Exp lookup_exp (Id);
234 Ty lookup_tyvar (Id);
235 Pat lookup_patvar (Id);
236 void add_parse_stack_binding (int,int,int);
238 // For error explanation
239 void print_user_symbol (std::ostream&, Symbol);
240 void explain_error();
241 #line 185 "parser.ph"
243 #line 185 "parser.ph"
244 #line 185 "parser.ph"
247 #endif
248 #line 188 "parser.ph"
250 ------------------------------- Statistics -------------------------------
251 Merge matching rules = yes
252 Number of DFA nodes merged = 0
253 Number of ifs generated = 0
254 Number of switches generated = 0
255 Number of labels = 0
256 Number of gotos = 0
257 Adaptive matching = enabled
258 Fast string matching = disabled
259 Inline downcasts = enabled
260 --------------------------------------------------------------------------