-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyatgFW.h
472 lines (444 loc) · 16.4 KB
/
yatgFW.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
/** \file
* This C header file was generated by $ANTLR version 3.2 Sep 23, 2009 12:02:23
*
* - From the grammar source file : C:\\Zlang\\src\\Zzparser\\Grammar\\yatgFW.g
* - On : 2010-07-07 17:24:44
* - for the tree parser : yatgFWTreeParser *
* Editing it, at least manually, is not wise.
*
* C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
*
*
* The tree parser yatgFW has the callable functions (rules) shown below,
* which will invoke the code for the associated rule in the source grammar
* assuming that the input stream is pointing to a token/text stream that could begin
* this rule.
*
* For instance if you call the first (topmost) rule in a parser grammar, you will
* get the results of a full parse, but calling a rule half way through the grammar will
* allow you to pass part of a full token stream to the parser, such as for syntax checking
* in editors and so on.
*
* The parser entry points are called indirectly (by function pointer to function) via
* a parser context typedef pyatgFW, which is returned from a call to yatgFWNew().
*
* The methods in pyatgFW are as follows:
*
* - void pyatgFW->program(pyatgFW)
* - yatgFW_expr_return pyatgFW->expr(pyatgFW)
* - void pyatgFW->variable_decls(pyatgFW)
* - void pyatgFW->type_decl(pyatgFW)
* - void pyatgFW->decl(pyatgFW)
* - void pyatgFW->if_expr(pyatgFW)
* - void pyatgFW->while_loop(pyatgFW)
* - void pyatgFW->do_loop(pyatgFW)
* - void pyatgFW->for_loop(pyatgFW)
* - yatgFW_source_return pyatgFW->source(pyatgFW)
* - void pyatgFW->loop_exit(pyatgFW)
* - void pyatgFW->loop_continue(pyatgFW)
* - void pyatgFW->case_expr(pyatgFW)
* - void pyatgFW->case_item(pyatgFW)
* - void pyatgFW->struct_def(pyatgFW)
* - void pyatgFW->member(pyatgFW)
* - void pyatgFW->try_expr(pyatgFW)
* - void pyatgFW->function_def(pyatgFW)
* - void pyatgFW->fun(pyatgFW)
* - void pyatgFW->function_return(pyatgFW)
* - void pyatgFW->context_expr(pyatgFW)
* - void pyatgFW->context(pyatgFW)
* - void pyatgFW->set_context(pyatgFW)
* - void pyatgFW->argT(pyatgFW)
* - void pyatgFW->argument_expression_list(pyatgFW)
* - void pyatgFW->unary_expression(pyatgFW)
* - void pyatgFW->operand(pyatgFW)
* - void pyatgFW->operand_op(pyatgFW)
* - void pyatgFW->constant(pyatgFW)
* - void pyatgFW->number(pyatgFW)
* - void pyatgFW->assignment_expression(pyatgFW)
* - yatgFW_cexprx_return pyatgFW->cexprx(pyatgFW)
* - yatgFW_lvalue_return pyatgFW->lvalue(pyatgFW)
* - yatgFW_assignment_operator_return pyatgFW->assignment_operator(pyatgFW)
* - void pyatgFW->expr_seq(pyatgFW)
* - yatgFW_expr_g_return pyatgFW->expr_g(pyatgFW)
* - void pyatgFW->box2(pyatgFW)
* - void pyatgFW->point3(pyatgFW)
* - void pyatgFW->point2(pyatgFW)
* - void pyatgFW->array(pyatgFW)
* - void pyatgFW->bitarray(pyatgFW)
* - void pyatgFW->arrrange(pyatgFW)
* - void pyatgFW->matrix(pyatgFW)
*
*
*
*
* The return type for any particular rule is of course determined by the source
* grammar file.
*/
// [The "BSD licence"]
// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
// http://www.temporal-wave.com
// http://www.linkedin.com/in/jimidle
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _yatgFW_H
#define _yatgFW_H
/* =============================================================================
* Standard antlr3 C runtime definitions
*/
#include <antlr3.h>
/* End of standard antlr 3 runtime definitions
* =============================================================================
*/
#include "stdafx.h"
#ifdef __cplusplus
extern "C" {
#endif
// Forward declare the context typedef so that we can use it before it is
// properly defined. Delegators and delegates (from import statements) are
// interdependent and their context structures contain pointers to each other
// C only allows such things to be declared if you pre-declare the typedef.
//
typedef struct yatgFW_Ctx_struct yatgFW, * pyatgFW;
#ifdef ANTLR3_WINDOWS
// Disable: Unreferenced parameter, - Rules with parameters that are not used
// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
// initialized but unused variable - tree rewrite variables declared but not needed
// Unreferenced local variable - lexer rule declares but does not always use _type
// potentially unitialized variable used - retval always returned from a rule
// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
//
// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
// usually generated when a parser rule is given a parameter that it does not use. Mostly though
// this is a matter of orthogonality hence I disable that one.
//
#pragma warning( disable : 4100 )
#pragma warning( disable : 4101 )
#pragma warning( disable : 4127 )
#pragma warning( disable : 4189 )
#pragma warning( disable : 4505 )
#pragma warning( disable : 4701 )
#endif
/* ========================
* BACKTRACKING IS ENABLED
* ========================
*/
typedef struct yatgFW_expr_return_struct
{
pANTLR3_BASE_TREE start;
pANTLR3_BASE_TREE stop;
}
yatgFW_expr_return;
typedef struct yatgFW_source_return_struct
{
pANTLR3_BASE_TREE start;
pANTLR3_BASE_TREE stop;
}
yatgFW_source_return;
typedef struct yatgFW_cexprx_return_struct
{
pANTLR3_BASE_TREE start;
pANTLR3_BASE_TREE stop;
}
yatgFW_cexprx_return;
typedef struct yatgFW_lvalue_return_struct
{
pANTLR3_BASE_TREE start;
pANTLR3_BASE_TREE stop;
}
yatgFW_lvalue_return;
typedef struct yatgFW_assignment_operator_return_struct
{
pANTLR3_BASE_TREE start;
pANTLR3_BASE_TREE stop;
}
yatgFW_assignment_operator_return;
typedef struct yatgFW_expr_g_return_struct
{
pANTLR3_BASE_TREE start;
pANTLR3_BASE_TREE stop;
}
yatgFW_expr_g_return;
/** Context tracking structure for yatgFW
*/
struct yatgFW_Ctx_struct
{
/** Built in ANTLR3 context tracker contains all the generic elements
* required for context tracking.
*/
pANTLR3_TREE_PARSER pTreeParser;
void (*program) (struct yatgFW_Ctx_struct * ctx);
yatgFW_expr_return (*expr) (struct yatgFW_Ctx_struct * ctx);
void (*variable_decls) (struct yatgFW_Ctx_struct * ctx);
void (*type_decl) (struct yatgFW_Ctx_struct * ctx);
void (*decl) (struct yatgFW_Ctx_struct * ctx);
void (*if_expr) (struct yatgFW_Ctx_struct * ctx);
void (*while_loop) (struct yatgFW_Ctx_struct * ctx);
void (*do_loop) (struct yatgFW_Ctx_struct * ctx);
void (*for_loop) (struct yatgFW_Ctx_struct * ctx);
yatgFW_source_return (*source) (struct yatgFW_Ctx_struct * ctx);
void (*loop_exit) (struct yatgFW_Ctx_struct * ctx);
void (*loop_continue) (struct yatgFW_Ctx_struct * ctx);
void (*case_expr) (struct yatgFW_Ctx_struct * ctx);
void (*case_item) (struct yatgFW_Ctx_struct * ctx);
void (*struct_def) (struct yatgFW_Ctx_struct * ctx);
void (*member) (struct yatgFW_Ctx_struct * ctx);
void (*try_expr) (struct yatgFW_Ctx_struct * ctx);
void (*function_def) (struct yatgFW_Ctx_struct * ctx);
void (*fun) (struct yatgFW_Ctx_struct * ctx);
void (*function_return) (struct yatgFW_Ctx_struct * ctx);
void (*context_expr) (struct yatgFW_Ctx_struct * ctx);
void (*context) (struct yatgFW_Ctx_struct * ctx);
void (*set_context) (struct yatgFW_Ctx_struct * ctx);
void (*argT) (struct yatgFW_Ctx_struct * ctx);
void (*argument_expression_list) (struct yatgFW_Ctx_struct * ctx);
void (*unary_expression) (struct yatgFW_Ctx_struct * ctx);
void (*operand) (struct yatgFW_Ctx_struct * ctx);
void (*operand_op) (struct yatgFW_Ctx_struct * ctx);
void (*constant) (struct yatgFW_Ctx_struct * ctx);
void (*number) (struct yatgFW_Ctx_struct * ctx);
void (*assignment_expression) (struct yatgFW_Ctx_struct * ctx);
yatgFW_cexprx_return (*cexprx) (struct yatgFW_Ctx_struct * ctx);
yatgFW_lvalue_return (*lvalue) (struct yatgFW_Ctx_struct * ctx);
yatgFW_assignment_operator_return (*assignment_operator) (struct yatgFW_Ctx_struct * ctx);
void (*expr_seq) (struct yatgFW_Ctx_struct * ctx);
yatgFW_expr_g_return (*expr_g) (struct yatgFW_Ctx_struct * ctx);
void (*box2) (struct yatgFW_Ctx_struct * ctx);
void (*point3) (struct yatgFW_Ctx_struct * ctx);
void (*point2) (struct yatgFW_Ctx_struct * ctx);
void (*array) (struct yatgFW_Ctx_struct * ctx);
void (*bitarray) (struct yatgFW_Ctx_struct * ctx);
void (*arrrange) (struct yatgFW_Ctx_struct * ctx);
void (*matrix) (struct yatgFW_Ctx_struct * ctx);
ANTLR3_BOOLEAN (*synpred2_yatgFW) (struct yatgFW_Ctx_struct * ctx);
ANTLR3_BOOLEAN (*synpred43_yatgFW) (struct yatgFW_Ctx_struct * ctx);
ANTLR3_BOOLEAN (*synpred94_yatgFW) (struct yatgFW_Ctx_struct * ctx);
// Delegated rules
const char * (*getGrammarFileName)();
void (*free) (struct yatgFW_Ctx_struct * ctx);
};
// Function protoypes for the constructor functions that external translation units
// such as delegators and delegates may wish to call.
//
ANTLR3_API pyatgFW yatgFWNew (pANTLR3_COMMON_TREE_NODE_STREAM instream);
ANTLR3_API pyatgFW yatgFWNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
/** Symbolic definitions of all the tokens that the tree parser will work with.
* \{
*
* Antlr will define EOF, but we can't use that as it it is too common in
* in C header files and that would be confusing. There is no way to filter this out at the moment
* so we just undef it here for now. That isn't the value we get back from C recognizers
* anyway. We are looking for ANTLR3_TOKEN_EOF.
*/
#ifdef EOF
#undef EOF
#endif
#ifdef Tokens
#undef Tokens
#endif
#define PIVOT 60
#define SS_PLUS_EQUAL 148
#define ROW 80
#define SS_D_DOT 160
#define SS_CCBRACKET 159
#define LETTER 164
#define EWHILE_EXP 15
#define SS_FSLASH 128
#define EIF_ELSE 11
#define CASE 39
#define KW_DEFAULT 105
#define ESEQ 7
#define P_P2 30
#define P_P3 31
#define UNDO 69
#define KW_WHERE 96
#define KW_FN 111
#define STRING_LITERIAL 134
#define EOF -1
#define SS_PERCENT 129
#define KW_GLOBAL 83
#define EOL 167
#define EIF_COND 9
#define KW_UNDEFINED 141
#define EWHILE_CON 14
#define KW_LEVEL 115
#define KW_PARENT 119
#define LP_EXIT 36
#define RETURN 49
#define EDO 17
#define LP_EXIT_WITH 37
#define SS_D_BAR 150
#define KW_THEN 87
#define COORDSYS 58
#define SS_LT_EQUAL 156
#define BODY 52
#define KW_COORDSYS 117
#define SS_STAR 127
#define COMMENT 168
#define ARR_BIT 33
#define SS_GT 155
#define KW_EXIT 97
#define SS_COLON 104
#define ABOUT 61
#define KW_FUNCTION 110
#define ESRC_WHERE 28
#define MATRIX 79
#define EDO_CON 18
#define SS_COMMA 81
#define LINE_COMMENT 169
#define SS_DOT 130
#define ECATCH_EXP 48
#define KW_CATCH 108
#define NUMBER 78
#define P_BOX2 29
#define SS_D_EQUAL 152
#define LOCAL 62
#define KW_DO 88
#define SS_MINUS_EQUAL 149
#define SS_STAR_EQUAL 145
#define EWHILE 13
#define KW_ANIMATE 113
#define KW_ABOUT 120
#define EFOR 21
#define FUN_DEF 50
#define PRIM_EXP 77
#define SS_D_AMP 151
#define SS_CBRACKET 132
#define WS 166
#define SS_GT_EQUAL 157
#define SS_MINUS 126
#define LEVEL 65
#define SS_DQUOTE 162
#define KW_TO 94
#define EFOR_END 24
#define KW_BY 95
#define ETRY 46
#define ESRC_START 25
#define FUN 53
#define KW_LOCAL 82
#define EscapeSequence 161
#define SS_EQUAL 85
#define KW_ELSE 89
#define SS_EXC_EQUAL 153
#define MEMBER 45
#define MAPPED 54
#define ID_MORE 75
#define ARR_IND 35
#define SS_OPAREN 102
#define EDO_END 20
#define KW_UNSUPPLIED 142
#define KW_SELECTION 122
#define SS_CPAREN 103
#define KW_TRUE 136
#define HexDigit 165
#define KW_WITH 98
#define KW_PIVOT 121
#define CONTEXT 57
#define SELECTION 59
#define AT 71
#define VDECL 4
#define REF_OP 170
#define TIME 67
#define ECASE_END 43
#define PARENT 64
#define VDEF 5
#define KW_MAPPED 109
#define SS_PLUS 125
#define KW_TIME 116
#define EFOR_SRC 22
#define KW_STRUCT 106
#define EWHILE_END 16
#define VVAL 6
#define KW_FOR 91
#define KW_WHILE 90
#define IDENTIFIER 84
#define DIGIT1 144
#define OPERAND 72
#define LP_CONT 38
#define CASE_Exp 40
#define KW_RETURN 112
#define KW_SET 124
#define EFOR_EXP 23
#define KW_IN 92
#define HEX_LITERAL 133
#define ESRC_BY 27
#define ARR_A 32
#define KW_TRY 107
#define DIGIT 143
#define DOT 73
#define KW_IF 86
#define KW_UNDO 123
#define ARR_BIT_RANGE 34
#define WITH 68
#define ETRY_EXP 47
#define EIF_END 12
#define CASE_Item 41
#define WORLD 63
#define SS_OCBRACKET 158
#define KW_FALSE 137
#define KW_OFF 139
#define DEFAULT 42
#define FUN_NAME 51
#define KW_CONTINUE 99
#define SET 76
#define ARG_EXPR_L 74
#define STRUCT 44
#define SS_LT 154
#define EDO_EXP 19
#define KW_CASE 100
#define FUN_DEF_END 55
#define KW_COLLECT 93
#define EIN 70
#define SS_PERCENT_EQUAL 147
#define EIF 8
#define KW_WORLD 118
#define KW_ON 138
#define SS_HASH 135
#define ESQ_FSLASH_SQUOTE 163
#define KW_OK 140
#define EIF_THEN 10
#define KW_AT 114
#define KW_OF 101
#define SS_OBRACKET 131
#define ANIMATE 66
#define ESRC_TO 26
#define SS_FSLASH_EQUAL 146
#define STRING 56
#ifdef EOF
#undef EOF
#define EOF ANTLR3_TOKEN_EOF
#endif
#ifndef TOKENSOURCE
#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
#endif
/* End of token definitions for yatgFW
* =============================================================================
*/
/** \} */
#ifdef __cplusplus
}
#endif
#endif
/* END - Note:Keep extra line feed to satisfy UNIX systems */