]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/CCode/Source/Pccts/antlr/generic.h
2 * generic.h -- generic include stuff for new PCCTS ANTLR.
6 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
7 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
8 * company may do whatever they wish with source code distributed with
9 * PCCTS or the code generated by PCCTS, including the incorporation of
10 * PCCTS, or its output, into commerical software.
12 * We encourage users to develop software with PCCTS. However, we do ask
13 * that credit is given to us for developing PCCTS. By "credit",
14 * we mean that if you incorporate our source code into one of your
15 * programs (commercial product, research project, or otherwise) that you
16 * acknowledge this fact somewhere in the documentation, research report,
17 * etc... If you like PCCTS and have developed a nice tool with the
18 * output, please mention that you developed it using PCCTS. In
19 * addition, we ask that this header remain intact in our source code.
20 * As long as these guidelines are kept, we expect to continue enhancing
21 * this system and expect to make other tools available as they are
26 * Parr Research Corporation
27 * with Purdue University and AHPCRC, University of Minnesota
33 #define DefaultParserName "zzparser"
35 /* MR9 JVincent@novell.com Allow user to override default ZZLEXBUFSIZE */
36 /* MR11 thm Raise antlr's own default ZZLEXBUFSIZE to 8k */
37 /* MR22 thm Raise antlr's own default ZZLEXBUFSIZE to 32k */
40 #define ZZLEXBUFSIZE 32000
43 /* Tree/FIRST/FOLLOW defines -- valid only after all grammar has been read */
44 #define ALT TokenNum+1
45 #define SET TokenNum+2
46 #define TREE_REF TokenNum+3
48 /* E r r o r M a c r o s */
50 #define fatal(err) fatalFL(err, __FILE__, __LINE__)
51 #define fatal_internal(err) fatal_intern(err, __FILE__, __LINE__)
54 #define eMsg1(s,a) eMsg3(s,a,NULL,NULL)
55 #define eMsg2(s,a,b) eMsg3(s,a,b,NULL)
57 /* S a n i t y C h e c k i n g */
60 #define require(expr, err) {if ( !(expr) ) fatal_internal(err);}
63 /* L i s t N o d e s */
65 typedef struct _ListNode
{
66 void *elem
; /* pointer to any kind of element */
67 struct _ListNode
*next
;
70 /* Define a Cycle node which is used to track lists of cycles for later
71 * reconciliation by ResolveFoCycles().
74 int croot
; /* cycle root */
75 set cyclicDep
; /* cyclic dependents */
76 unsigned deg
; /* degree of FOLLOW set of croot */
80 int tok
; /* error class name == TokenStr[tok] */
81 ListNode
*elist
; /* linked list of elements in error set */
83 int setdeg
; /* how big is the set */
84 int lexclass
; /* which lex class is it in? */
87 typedef struct _TCnode
{
88 int tok
; /* token class name */
89 ListNode
*tlist
; /* linked list of elements in token set */
91 int lexclass
; /* which lex class is it in? */
92 unsigned char dumped
; /* this def has been been dumped */
93 unsigned char dumpedComplement
; /* this def has been been dumped */
94 unsigned setnum
; /* which set number is this guy? (if dumped) */
95 unsigned setnumComplement
; /* MR23 */
96 unsigned setnumErrSet
; /* MR23 which set is this #tokclass error set (if dumped) */
97 unsigned setnumErrSetComplement
; /* MR23 */
101 char *token
; /* id of token type to remap */
102 int tnum
; /* move token type to which token position */
105 typedef struct _ContextGuardPredicates
{ /* MR13 */
106 Predicate
*pred
; /* MR13 */
107 } ContextGuardPredicates
; /* MR13 */
109 #define newListNode (ListNode *) calloc(1, sizeof(ListNode));
110 #define newCycle (Cycle *) calloc(1, sizeof(Cycle));
111 #define newECnode (ECnode *) calloc(1, sizeof(ECnode));
112 #define newTCnode (TCnode *) calloc(1, sizeof(TCnode));
115 /* H a s h T a b l e E n t r i e s */
117 typedef struct _t
{ /* Token name or expression */
120 int token
; /* token number */
121 unsigned char classname
; /* is it a err/tok class name or token */
122 TCnode
*tclass
; /* ptr to token class */
127 typedef struct _r
{ /* Rule name and ptr to start of rule */
130 int rulenum
; /* RulePtr[rulenum]== ptr to RuleBlk junction */
131 unsigned char noAST
;/* gen AST construction code? (def==gen code) */
132 char *egroup
; /* which error group (err reporting stuff) */
134 /* MR27 This appears to never be used. Delete this code later. */
136 ListNode
*el_labels
;/* list of element labels ref in all of rule */
138 ListNode
*ast_labels_in_actions
; /* MR27 */
139 unsigned char has_rule_exception
;
140 char dontComputeErrorSet
; /* MR14 - don't compute error set
141 special for rule in alpha part of
142 (alpha)? beta block */
145 typedef struct _f
{ /* cache Fi/Fo set */
146 char *str
; /* key == (rulename, computation, k) */
148 set fset
; /* First/Follow of rule */
149 set rk
; /* set of k's remaining to be done after ruleref */
150 int incomplete
; /* only w/FOLLOW sets. Use only if complete */
153 typedef struct _LabelEntry
{ /* element labels */
156 Node
*elem
; /* which element does it point to? */
157 ExceptionGroup
*ex_group
;
158 /* Is there an exception attached to label? */
159 ExceptionGroup
*outerEG
; /* MR7 */
160 /* next EG if ex_group doesn't catch it MR7 */
161 struct _LabelEntry
*pendingLink
; /* MR7 */
162 /* too lazy to use ListNode ? MR7 */
163 int curAltNum
; /* MR7 */
166 typedef struct _SignalEntry
{
169 int signum
; /* unique signal number */
172 typedef struct _PredEntry
{ /* MR11 predicate name and ptr to string */
174 struct _PredEntry
*next
;
181 typedef struct _PointerStack
{ /* MR10 */
187 #define newTermEntry(s) (TermEntry *) newEntry(s, sizeof(TermEntry))
188 #define newRuleEntry(s) (RuleEntry *) newEntry(s, sizeof(RuleEntry))
189 #define newCacheEntry(s) (CacheEntry *) newEntry(s, sizeof(CacheEntry))
190 #define newLabelEntry(s) (LabelEntry *) newEntry(s, sizeof(LabelEntry))
191 #define newSignalEntry(s) (SignalEntry *) newEntry(s, sizeof(SignalEntry))
192 #define newPredEntry(s) (PredEntry *) newEntry(s,sizeof(PredEntry))
194 typedef struct _UserAction
{
200 /* L e x i c a l C l a s s */
202 /* to switch lex classes, switch ExprStr and Texpr (hash table) */
204 char *classnum
, **exprs
;
208 typedef struct _exprOrder
{
214 typedef Graph Attrib
;
216 /* M a x i m u m s */
218 /* MR20 Note G. Hobbelt These values are superceded by values in hash.h */
220 #ifndef HashTableSize
221 #define HashTableSize 253
224 #define StrTableSize 15000 /* all tokens, nonterminals, rexprs stored here */
226 #define MaxLexClasses 50 /* how many automatons */
227 /* TokenStart and EofToken are ignored if #tokdefs meta-op is used */
228 #define TokenStart 2 /* MUST be in 1 + EofToken */
229 #define EofToken 1 /* Always predefined to be 1 */
232 #define MaxNumFiles 99
235 /**** MR9 JVincent@novell.com Move to pcctscfg.h */
236 /**** #define MaxFileName 300 ****/ /* MR9 Move to pcctscfg.h */ /* largest file name size */
238 #define MaxRuleName 100 /* largest rule name size */
239 #define TSChunk 100 /* how much to expand TokenStr/ExprStr each time */
240 #define TIChunk TSChunk /* expand TokenInd by same as TokenStr to mirror them */
241 #define FoStackSize 100 /* deepest FOLLOW recursion possible */
243 #define MaxClassDeclStuff 256 /* MR10 */
245 #define NumPredefinedSignals 3
247 /* S t a n d a r d S i g n a l s */
249 #define sigNoSignal 0
250 #define sigMismatchedToken 1
251 #define sigNoViableAlt 2
252 #define sigNoSemViableAlt 3
256 /* AST token types */
260 #define ASTinclude 3 /* include subtree made by rule ref */
263 #define PredictionVariable "zzpr_expr"
264 #define PredictionLexClassSuffix "_zzpred"
266 #define WildCardString "WildCard"
269 /* Removed in version 1.33MR19
270 Don't understand why this never caused problems before
273 /*********************************************************
275 #define ANTLRm(st, f, _m) zzbufsize = ZZLEXBUFSIZE;\
281 *********************************************************/
285 #include "pcctscfg.h" /* MR14 */