• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<<
2/* parser.dlg -- DLG Description of scanner
3 *
4 * Generated from: dlg_p.g
5 *
6 * Terence Parr, Will Cohen, and Hank Dietz: 1989-2001
7 * Purdue University Electrical Engineering
8 * With AHPCRC, University of Minnesota
9 * ANTLR Version 1.33MR33
10 */
11
12#define ANTLR_VERSION	13333
13#include "pcctscfg.h"
14#include "pccts_stdio.h"
15
16#include <ctype.h>
17#include "dlg.h"
18#include "antlr.h"
19#include "tokens.h"
20#include "dlgdef.h"
21LOOKAHEAD
22
23void
24#ifdef __USE_PROTOS
25zzerraction(void)
26#else
27zzerraction()
28#endif
29{
30	(*zzerr)("invalid token");
31	zzadvance();
32	zzskip();
33}
34>>
35
36<<%%lexaction
37
38int	func_action;		/* should actions be turned into functions?*/
39int	lex_mode_counter = 0;	/* keeps track of the number of %%names */
40/* MR1									    */
41/* MR1  11-Apr-97	Provide mechanism for inserting code into DLG class */
42/* MR1				via <<%%lexmember...>>			    */
43/* MR1									    */
44int	lexMember = 0;		/* <<%%lexmemeber ...>>	   		MR1 */
45int	lexAction = 0;		/* <<%%lexaction ...>>			MR1 */
46int	parserClass = 0;	/* <<%%parserclass ...>>        MR1 */
47int	lexPrefix = 0;		/* <<%%lexprefix ...>>			MR1 */
48char	theClassName[100];						     /* MR11 */
49char	*pClassName=theClassName;					 /* MR11 */
50int	firstLexMember=1;					             /* MR1 */
51
52#ifdef __USE_PROTOS
53void  xxputc(int c) {						/* MR1 */
54#else
55  void xxputc(c)							/* MR1 */
56  int	c;							/* MR1 */
57  {								/* MR1 */
58#endif
59    if (parserClass) {						/* MR1 */
60      *pClassName++=c;						/* MR1 */
61      *pClassName=0;						/* MR1 */
62    } else if (lexMember || lexPrefix) {				/* MR1 */
63      if (class_stream != NULL) fputc(c,class_stream);		/* MR1 */
64    } else {							/* MR1 */
65      fputc(c,OUT);						/* MR1 */
66    };								/* MR1 */
67  }  								/* MR1 */
68
69#ifdef __USE_PROTOS
70  void xxprintf(char *format,char *string) {			/* MR1 */
71#else
72    void xxprintf(format,string) 					/* MR1 */
73    char *format;							/* MR1 */
74    char *string;							/* MR1 */
75    {								/* MR1 */
76#endif
77      if (lexMember || lexPrefix || parserClass) {			/* MR1 */
78        if (class_stream != NULL)					/* MR1 */
79        fprintf(class_stream,format,string);			/* MR1 */
80      } else {							/* MR1 */
81        fprintf(OUT,format,string);					/* MR1 */
82      };								/* MR1 */
83    }  								/* MR1 */
84>>
85
86
87%%START
88
89@
90	<<
91		NLA = 1;
92	>>
93
94[\r\t\ ]+
95	<<
96		NLA = 2;
97    zzskip();
98	>>
99
100\n
101	<<
102		NLA = 3;
103    zzline++; zzskip(); DAWDLE;
104	>>
105
106\@
107	<<
108		NLA = L_EOF;
109	>>
110
111\%\%
112	<<
113		NLA = PER_PER;
114	>>
115
116\%\%[a-zA-Z_][a-zA-Z0-9_]*
117	<<
118		NLA = NAME_PER_PER;
119    p_mode_def(&zzlextext[2],lex_mode_counter++);
120	>>
121
122\<\<\%\%lexmember
123	<<
124		NLA = LEXMEMBER;
125    lexMember=1;					/* MR1 */
126    if (firstLexMember != 0) {			/* MR1 */
127      firstLexMember=0;				/* MR1 */
128      p_class_def1();				/* MR1 */
129    };						/* MR1 */
130    zzmode(ACT);					/* MR1 */
131	>>
132
133\<\<\%\%lexaction
134	<<
135		NLA = LEXACTION;
136    lexAction=1;zzmode(ACT);
137	>>
138
139\<\<\%\%parserclass
140	<<
141		NLA = PARSERCLASS;
142    parserClass=1;				/* MR1 */
143    zzmode(ACT);					/* MR1 */
144	>>
145
146\<\<\%\%lexprefix
147	<<
148		NLA = LEXPREFIX;
149    lexPrefix=1;zzmode(ACT);
150	>>
151
152\<\<
153	<<
154		NLA = ACTION;
155    if (func_action)
156    fprintf(OUT,"\n%s %sact%d()\n{ ",
157    gen_cpp?"ANTLRTokenType":"static void",
158    gen_cpp?ClassName("::"):"", ++action_no);
159    zzmode(ACT); zzskip();
160	>>
161
162\>\>
163	<<
164		NLA = GREAT_GREAT;
165	>>
166
167\{
168	<<
169		NLA = L_BRACE;
170	>>
171
172\}
173	<<
174		NLA = R_BRACE;
175	>>
176
177\(
178	<<
179		NLA = L_PAR;
180	>>
181
182\)
183	<<
184		NLA = R_PAR;
185	>>
186
187\[
188	<<
189		NLA = L_BRACK;
190	>>
191
192\]
193	<<
194		NLA = R_BRACK;
195	>>
196
197\*
198	<<
199		NLA = ZERO_MORE;
200	>>
201
202\+
203	<<
204		NLA = ONE_MORE;
205	>>
206
207\|
208	<<
209		NLA = OR;
210	>>
211
212\-
213	<<
214		NLA = RANGE;
215	>>
216
217\~
218	<<
219		NLA = NOT;
220	>>
221
222\\0[0-7]*
223	<<
224		NLA = OCTAL_VALUE;
225    {int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}
226	>>
227
228\\0[Xx][0-9a-fA-F]+
229	<<
230		NLA = HEX_VALUE;
231    {int t; sscanf(&zzlextext[3],"%x",&t); zzlextext[0] = t;}
232	>>
233
234\\[1-9][0-9]*
235	<<
236		NLA = DEC_VALUE;
237    {int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}
238	>>
239
240\\t
241	<<
242		NLA = TAB;
243    zzlextext[0] = '\t';
244	>>
245
246\\n
247	<<
248		NLA = NL;
249    zzlextext[0] = '\n';
250	>>
251
252\\r
253	<<
254		NLA = CR;
255    zzlextext[0] = '\r';
256	>>
257
258\\b
259	<<
260		NLA = BS;
261    zzlextext[0] = '\b';
262	>>
263
264\\ \n
265	<<
266		NLA = CONTINUATION;
267    zzline++; zzskip();
268	>>
269
270\\~[tnrb]
271	<<
272		NLA = LIT;
273    zzlextext[0] = zzlextext[1];
274	>>
275
276~[\\]
277	<<
278		NLA = REGCHAR;
279	>>
280
281
282%%ACT
283
284@
285	<<
286		NLA = 1;
287    error("unterminated action", zzline); zzmode(START);
288	>>
289
290\>\>
291	<<
292		NLA = ACTION;
293    if (func_action) fprintf(OUT,"}\n\n");
294    zzmode(START);
295    /* MR1									    */
296    /* MR1  11-Apr-97	Provide mechanism for inserting code into DLG class */
297    /* MR1				via <<%%lexmember ...>>			    */
298    /* MR1			This is a consequence of not saving actions         */
299    /* MR1									    */
300    /* MR1 */	   parserClass=0;
301    /* MR1 */	   lexPrefix=0;
302    /* MR1 */	   lexAction=0;
303    /* MR1 */	   lexMember=0;
304	>>
305
306\>
307	<<
308		NLA = 34;
309    xxputc(zzlextext[0]); zzskip();
310	>>
311
312\\\>
313	<<
314		NLA = 35;
315    xxputc('>'); zzskip();
316	>>
317
318\\
319	<<
320		NLA = 36;
321    xxputc('\\'); zzskip();
322	>>
323
324\n
325	<<
326		NLA = 37;
327    xxputc(zzlextext[0]); ++zzline; zzskip();
328	>>
329
330/\*
331	<<
332		NLA = 38;
333    zzmode(ACTION_COMMENTS);			/* MR1 */
334    xxprintf("%s", &(zzlextext[0])); zzskip();	/* MR1 */
335	>>
336
337//
338	<<
339		NLA = 39;
340    zzmode(ACTION_CPP_COMMENTS);			/* MR1 */
341    xxprintf("%s", &(zzlextext[0])); zzskip();	/* MR1 */
342	>>
343
344~[]
345	<<
346		NLA = 40;
347    xxputc(zzlextext[0]); zzskip();
348	>>
349
350
351%%ACTION_COMMENTS
352
353@
354	<<
355		NLA = 1;
356	>>
357
358\*/
359	<<
360		NLA = 41;
361    zzmode(ACT);					/* MR1 */
362    xxprintf("%s", &(zzlextext[0])); zzskip();	/* MR1 */
363	>>
364
365[\n\r]
366	<<
367		NLA = 42;
368    zzline++; xxputc(zzlextext[0]); zzskip();
369	>>
370
371~[]
372	<<
373		NLA = 43;
374    xxputc(zzlextext[0]); zzskip();
375	>>
376
377
378%%ACTION_CPP_COMMENTS
379
380@
381	<<
382		NLA = 1;
383	>>
384
385[\n\r]
386	<<
387		NLA = 44;
388    zzmode(ACT); zzline++;			/* MR1 */
389    xxprintf("%s", &(zzlextext[0])); zzskip();	/* MR1 */
390	>>
391
392~[]
393	<<
394		NLA = 45;
395    xxputc(zzlextext[0]); zzskip();
396	>>
397
398%%
399