]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/VfrCompile/Pccts/h/DLexer.h
1 /* DLexer.h (formerly DLexer.cpp)
3 * This was renamed because the use of the .cpp extension caused problems
8 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
9 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
10 * company may do whatever they wish with source code distributed with
11 * PCCTS or the code generated by PCCTS, including the incorporation of
12 * PCCTS, or its output, into commerical software.
14 * We encourage users to develop software with PCCTS. However, we do ask
15 * that credit is given to us for developing PCCTS. By "credit",
16 * we mean that if you incorporate our source code into one of your
17 * programs (commercial product, research project, or otherwise) that you
18 * acknowledge this fact somewhere in the documentation, research report,
19 * etc... If you like PCCTS and have developed a nice tool with the
20 * output, please mention that you developed it using PCCTS. In
21 * addition, we ask that this header remain intact in our source code.
22 * As long as these guidelines are kept, we expect to continue enhancing
23 * this system and expect to make other tools available as they are
28 * Parr Research Corporation
29 * with Purdue University and AHPCRC, University of Minnesota
35 #define ZZINC {if ( track_columns ) (++_endcol);}
37 #define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}
39 #define ZZNEWSTATE (newstate = dfa[state][cl])
43 /* Truncate matching buffer to size (not an error) */ \
44 if (nextpos < lastpos){ \
54 /* points to base of dfa table */
57 /* have to redo class since using different compression */
60 sprintf((char *)ebuf
,"Invalid automaton mode = %d ",m
);
65 ANTLRTokenType
DLGLexer::
68 register int state
, newstate
;
69 /* last space reserved for the null char */
70 register DLGChar
*lastpos
;
75 lastpos
= &_lextext
[_bufsize
-1];
81 /* interactive version of automaton */
82 /* if there is something in ch, process it */
83 state
= newstate
= dfa_base
[automaton
];
89 while (alternatives
[newstate
]){
96 /* figure out if last character really part of token */
97 if ((state
!= dfa_base
[automaton
]) && (newstate
== DfaStates
)){
105 /* Able to transition out of start state to some non err state?*/
106 if ( state
== dfa_base
[automaton
] ){
107 /* make sure doesn't get stuck */
111 else { /* non-interactive version of automaton */
116 state
= dfa_base
[automaton
];
117 while (ZZNEWSTATE
!= DfaStates
) {
119 assert(state
<= sizeof(dfa
)/sizeof(dfa
[0]));
125 if ( state
== dfa_base
[automaton
] ){
126 if (nextpos
< lastpos
){
132 /* make sure doesn't get stuck */
138 if ( track_columns
) _endcol
-= charfull
;
139 _endexpr
= nextpos
-1;
142 tk
= (ANTLRTokenType
)
143 (*actions
[accepts
[state
]])(this); // must pass this manually
144 // actions is not a [] of pointers
145 // to member functions.
147 tk
= (this->*actions
[accepts
[state
]])();
150 // MR1 11-Apr-97 Help for tracking DLG results
155 /* MR1 */ if (debugLexerFlag
) {
156 /* MR1 */ if (parser
!= NULL
) {
157 /* MR1 */ /* MR23 */ printMessage(stdout
, "\ntoken name=%s",parser
->parserTokenName(tk
));
159 /* MR1 */ /* MR23 */ printMessage(stdout
, "\ntoken nnumber=%d",tk
);
161 /* MR1 */ /* MR23 */ printMessage(stdout
, " lextext=(%s) mode=%d",
162 /* MR1 */ (_lextext
[0]=='\n' && _lextext
[1]==0) ?
163 /* MR1 */ "newline" : _lextext
,
164 /* MR1 */ automaton
);
165 /* MR1 */ if (interactive
&& !charfull
) {
166 /* MR1 */ /* MR23 */ printMessage(stdout
, " char=empty");
168 /* MR1 */ if (ch
=='\n') {
169 /* MR1 */ /* MR23 */ printMessage(stdout
, " char=newline");
171 /* MR1 */ /* MR23 */ printMessage(stdout
, " char=(%c)",ch
);
174 /* MR1 */ /* MR23 */ printMessage(stdout
, " %s\n",
175 /* MR1 */ (add_erase
==1 ? "skip()" :
176 /* MR1 */ add_erase
==2 ? "more()" :
192 if ( input
==NULL
) err_in();
193 ZZGETC
; charfull
= 1; ZZINC
;