-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathLGParser.h
124 lines (110 loc) · 4.33 KB
/
LGParser.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
#pragma once
/////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// LGParser.h
/* Generated by: LRSTAR 6.5.019
Grammar: LG.grm
Skeleton: LGParser.h.skl
Output: LGParser.h
*/
#include "LGLexer.h"
#define TOKEN_ACTIONS
#define PARSE_ACTIONS
// Defined constants ...
#undef T_ERROR
#undef T_ALPHA
#undef T_LEXICAL
#undef T_IGNORE
#undef T_ESCAPE
#undef T_LITERAL
#undef T_STRING
#undef T_INTEGER
#undef T_EOF
#undef T_ARROW
#undef T_RETURN
#undef T_LEFTP
#undef T_RIGHTP
#undef T_PLUS
#undef T_STAR
#undef T_QUEST
#undef T_DOTS
#undef T_BAR
#undef T_DASH
#undef T_LCB
#undef T_RCB
#undef T_SEMI
#undef T_PERCENT
#define T_ERROR 0 //
#define T_ALPHA 1 //
#define T_LEXICAL 2 //
#define T_IGNORE 3 //
#define T_ESCAPE 4 //
#define T_LITERAL 5 //
#define T_STRING 6 //
#define T_INTEGER 7 //
#define T_EOF 8 //
#define T_ARROW 9 //
#define T_RETURN 10 //
#define T_LEFTP 11 //
#define T_RIGHTP 12 //
#define T_PLUS 13 //
#define T_STAR 14 //
#define T_QUEST 15 //
#define T_DOTS 16 //
#define T_BAR 17 //
#define T_DASH 18 //
#define T_LCB 19 //
#define T_RCB 20 //
#define T_SEMI 21 //
#define T_PERCENT 22 //
class LGParser : public LGLexer
{
public:
// Functions ...
static void initialize (int);
static int Parse ();
static int parse ();
static void terminate ();
static void syntax_error (int);
// Variables ...
static PStack* PS; // Parse Stack pointer.
static PStack* PS_end; // Parse Stack end.
static char pact_arg[]; // Parse-action argument index (for first arg).
static char nact_arg[]; // Node-action argument index (for first arg).
static uchar arg_numb[]; // Argument numbers.
static char* arg_text[]; // Argument text (for string arguments).
static uchar f_prod[];
static uchar f_tail[];
static char* T_start;
static char* T_end;
static int T_line;
private:
// Functions ...
static int nd_parse (int*, int*, int*, int x, int t, int a);
static int apply (int p);
static int linkup (int p);
static void rebuild ();
static short err_rec (short, short);
static short lookahead (short t, short x);
static void get_list (short);
static void prt_token (short);
static void prt_prod (short);
static void prt_stack ();
static void expecting ();
static void restore ();
static void collect (int x);
static void reduce (int p, int x);
static void prt_list (int t);
static char* prt_line (char* ls, int ln);
static void prt_pointer (char* ls, int ln, char* token);
// Variables ...
static int max_errs; // Maximum allowable errors.
static RStack* RS; // Reduction Stack pointer.
static char* T_list; // Terminal symbol list (0 or 1).
static char* H_list; // Head symbol list (0 or 1).
static int* P_list; // Production list.
static RStack R_stack[]; // Reduction stack.
static PStack P_stack[]; // Parser stack.
static PStack* PStop; // Top pointer for Parser stack.
static int topstate; // Top state (before reductions start).
};