]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/lib/STreeParser.cpp
2 #include "STreeParser.h"
5 MATCH(SORASTBase
*_t
,int tok
)
9 if ( guessing
) _GUESS_FAIL
;
10 else mismatched_token(tok
, _t
);
15 MATCHRANGE(SORASTBase
*_t
,int tok
,int tok2
)
17 if ( _t
->type()<tok
|| _t
->type()>tok2
)
19 if ( guessing
) _GUESS_FAIL
;
20 else mismatched_range(tok
, tok2
, _t
);
25 WILDCARD(SORASTBase
*_t
)
29 if ( guessing
) _GUESS_FAIL
;
30 else missing_wildcard();
35 mismatched_range(int looking_for
, int upper_token
, SORASTBase
*found
)
39 "parse error: expected token range %d..%d found token %d\n",
40 looking_for
, upper_token
,
45 "parse error: expected token range %d..%d found NULL tree\n",
46 looking_for
, upper_token
);
53 fprintf(stderr
, "parse error: expected any token/tree found found NULL tree\n");
57 mismatched_token(int looking_for
, SORASTBase
*found
)
61 "parse error: expected token %d found token %d\n",
67 "parse error: expected token %d found NULL tree\n",
73 no_viable_alt(char *rulename
, SORASTBase
*root
)
77 "parse error: in rule %s, no viable alternative for NULL tree\n",
81 "parse error: in rule %s, no viable alternative for tree\n",
88 fprintf(stderr
, "panic: %s\n", err
);
93 save_state(STreeParser
*buf
)
95 buf
->try_ok
= this->try_ok
;
96 buf
->sjrv
= this->sjrv
;
97 buf
->guessing
= this->guessing
;
98 buf
->startofguess
= this->startofguess
;
102 restore_state(STreeParser
*buf
)
104 this->try_ok
= buf
->try_ok
;
105 this->sjrv
= buf
->sjrv
;
106 this->guessing
= buf
->guessing
;
107 this->startofguess
= buf
->startofguess
;
111 _mkroot(SORASTBase
**r
, SORASTBase
**s
, SORASTBase
**e
, SORASTBase
*t
)
117 _mkchild(SORASTBase
**r
, SORASTBase
**s
, SORASTBase
**e
, SORASTBase
*t
)
119 #ifdef BEFORE_GARYS_FIX
120 /* if no sibling list, must attach to any existing root */
124 /* If r is NULL, then there was no root defined--must be sibling list */
125 if ( *r
==NULL
) *r
= *s
;
126 else (*r
)->setDown(t
);
128 else { (*e
)->setRight(t
); *e
= t
; }
131 should do nothing if asked to add a NULL argument. NULL's come up
132 when a rule wants to return "nothing".
134 /* if no sibling list, must attach to any existing root */
138 // If r is NULL then there was no root defined--must be sibling list
139 if (*r
== NULL
) *r
= *s
;
140 else (*r
)->setDown(t
);
148 while ((*e
)->right() != NULL
) *e
= (SORASTBase
*)(*e
)->right();