]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/DLexer.cpp
5 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
6 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
7 * company may do whatever they wish with source code distributed with
8 * PCCTS or the code generated by PCCTS, including the incorporation of
9 * PCCTS, or its output, into commerical software.
11 * We encourage users to develop software with PCCTS. However, we do ask
12 * that credit is given to us for developing PCCTS. By "credit",
13 * we mean that if you incorporate our source code into one of your
14 * programs (commercial product, research project, or otherwise) that you
15 * acknowledge this fact somewhere in the documentation, research report,
16 * etc... If you like PCCTS and have developed a nice tool with the
17 * output, please mention that you developed it using PCCTS. In
18 * addition, we ask that this header remain intact in our source code.
19 * As long as these guidelines are kept, we expect to continue enhancing
20 * this system and expect to make other tools available as they are
25 * Parr Research Corporation
26 * with Purdue University and AHPCRC, University of Minnesota
30 #define ZZINC {if ( track_columns ) (++_endcol);}
32 #define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}
34 #define ZZNEWSTATE (newstate = dfa[state][cl])
38 /* Truncate matching buffer to size (not an error) */ \
39 if (nextpos < lastpos){ \
49 /* points to base of dfa table */
52 /* have to redo class since using different compression */
55 sprintf((char *)ebuf
,"Invalid automaton mode = %d ",m
);
60 ANTLRTokenType
DLGLexer::
63 register int state
, newstate
;
64 /* last space reserved for the null char */
65 register DLGChar
*lastpos
;
70 lastpos
= &_lextext
[_bufsize
-1];
76 /* interactive version of automaton */
77 /* if there is something in ch, process it */
78 state
= newstate
= dfa_base
[automaton
];
84 while (alternatives
[newstate
]){
91 /* figure out if last character really part of token */
92 if ((state
!= dfa_base
[automaton
]) && (newstate
== DfaStates
)){
100 /* Able to transition out of start state to some non err state?*/
101 if ( state
== dfa_base
[automaton
] ){
102 /* make sure doesn't get stuck */
106 else { /* non-interactive version of automaton */
111 state
= dfa_base
[automaton
];
112 while (ZZNEWSTATE
!= DfaStates
) {
119 if ( state
== dfa_base
[automaton
] ){
120 if (nextpos
< lastpos
){
126 /* make sure doesn't get stuck */
132 if ( track_columns
) _endcol
-= charfull
;
133 _endexpr
= nextpos
-1;
136 tk
= (ANTLRTokenType
)
137 (*actions
[accepts
[state
]])(this); // must pass this manually
138 // actions is not a [] of pointers
139 // to member functions.
141 tk
= (this->*actions
[accepts
[state
]])();
144 // MR1 11-Apr-97 Help for tracking DLG results
149 /* MR1 */ if (debugLexerFlag
) {
150 /* MR1 */ if (parser
!= NULL
) {
151 /* MR1 */ printf("\ntoken name=%s",parser
->parserTokenName(tk
));
153 /* MR1 */ printf("\ntoken nnumber=%d",tk
);
155 /* MR1 */ printf(" lextext=(%s) mode=%d",
156 /* MR1 */ (_lextext
[0]=='\n' && _lextext
[1]==0) ?
157 /* MR1 */ "newline" : _lextext
,
158 /* MR1 */ automaton
);
159 /* MR1 */ if (interactive
&& !charfull
) {
160 /* MR1 */ printf(" char=empty");
162 /* MR1 */ if (ch
=='\n') {
163 /* MR1 */ printf(" char=newline");
165 /* MR1 */ printf(" char=(%c)",ch
);
168 /* MR1 */ printf(" %s\n",
169 /* MR1 */ (add_erase
==1 ? "skip()" :
170 /* MR1 */ add_erase
==2 ? "more()" :
186 if ( input
==NULL
) err_in();
187 ZZGETC
; charfull
= 1; ZZINC
;