]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/CCode/Source/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
33 #define ZZINC {if ( track_columns ) (++_endcol);}
35 #define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}
37 #define ZZNEWSTATE (newstate = dfa[state][cl])
41 /* Truncate matching buffer to size (not an error) */ \
42 if (nextpos < lastpos){ \
52 /* points to base of dfa table */
55 /* have to redo class since using different compression */
58 sprintf((char *)ebuf
,"Invalid automaton mode = %d ",m
);
63 ANTLRTokenType
DLGLexer::
66 register int state
, newstate
;
67 /* last space reserved for the null char */
68 register DLGChar
*lastpos
;
73 lastpos
= &_lextext
[_bufsize
-1];
79 /* interactive version of automaton */
80 /* if there is something in ch, process it */
81 state
= newstate
= dfa_base
[automaton
];
87 while (alternatives
[newstate
]){
94 /* figure out if last character really part of token */
95 if ((state
!= dfa_base
[automaton
]) && (newstate
== DfaStates
)){
103 /* Able to transition out of start state to some non err state?*/
104 if ( state
== dfa_base
[automaton
] ){
105 /* make sure doesn't get stuck */
109 else { /* non-interactive version of automaton */
114 state
= dfa_base
[automaton
];
115 while (ZZNEWSTATE
!= DfaStates
) {
122 if ( state
== dfa_base
[automaton
] ){
123 if (nextpos
< lastpos
){
129 /* make sure doesn't get stuck */
135 if ( track_columns
) _endcol
-= charfull
;
136 _endexpr
= nextpos
-1;
139 tk
= (ANTLRTokenType
)
140 (*actions
[accepts
[state
]])(this); // must pass this manually
141 // actions is not a [] of pointers
142 // to member functions.
144 tk
= (this->*actions
[accepts
[state
]])();
147 // MR1 11-Apr-97 Help for tracking DLG results
152 /* MR1 */ if (debugLexerFlag
) {
153 /* MR1 */ if (parser
!= NULL
) {
154 /* MR1 */ /* MR23 */ printMessage(stdout
, "\ntoken name=%s",parser
->parserTokenName(tk
));
156 /* MR1 */ /* MR23 */ printMessage(stdout
, "\ntoken nnumber=%d",tk
);
158 /* MR1 */ /* MR23 */ printMessage(stdout
, " lextext=(%s) mode=%d",
159 /* MR1 */ (_lextext
[0]=='\n' && _lextext
[1]==0) ?
160 /* MR1 */ "newline" : _lextext
,
161 /* MR1 */ automaton
);
162 /* MR1 */ if (interactive
&& !charfull
) {
163 /* MR1 */ /* MR23 */ printMessage(stdout
, " char=empty");
165 /* MR1 */ if (ch
=='\n') {
166 /* MR1 */ /* MR23 */ printMessage(stdout
, " char=newline");
168 /* MR1 */ /* MR23 */ printMessage(stdout
, " char=(%c)",ch
);
171 /* MR1 */ /* MR23 */ printMessage(stdout
, " %s\n",
172 /* MR1 */ (add_erase
==1 ? "skip()" :
173 /* MR1 */ add_erase
==2 ? "more()" :
189 if ( input
==NULL
) err_in();
190 ZZGETC
; charfull
= 1; ZZINC
;