1
|
1 |
"{ Package: 'stx:goodies/smaCC' }"
|
|
2 |
|
|
3 |
"{ NameSpace: SmaCC }"
|
|
4 |
|
|
5 |
SmaCCScanner subclass:#CScanner
|
|
6 |
instanceVariableNames:'typeNames'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'SmaCC-Example Parsers'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!CScanner class methodsFor:'generated-comments'!
|
|
14 |
|
|
15 |
scannerDefinitionComment
|
|
16 |
|
5
|
17 |
"<H>: [a-fA-F0-9] ;
|
|
18 |
<IS>: [uUlL] ;
|
|
19 |
<D>: [0-9] ;
|
|
20 |
<E>: [Ee][\+\-]?<D>+ ;
|
|
21 |
<FS>: [fFlL] ;
|
1
|
22 |
<ELLIPSIS> : \.\.\. ;
|
5
|
23 |
<comment>: \/ \* ;
|
1
|
24 |
<LETTER> : [a-zA-Z_] ;
|
|
25 |
<DIGIT> : [0-9] ;
|
5
|
26 |
<IDENTIFIER>: <LETTER> (<LETTER>|<DIGIT>)* ;
|
1
|
27 |
<CONSTANT>: (0[xX]<H>+<IS>?) |
|
5
|
28 |
(<D>+<IS>?) |
|
|
29 |
(<D>+<E><FS>?) |
|
|
30 |
<D>*\.<D>+<E>?<FS>? |
|
|
31 |
(L? \' ( (\\ .) | ([^\\\""]) )+ \') ;
|
|
32 |
|
|
33 |
<STRING_LITERAL>: L? \"" ( (\\ .) | ([^\\\""]) )* \"" ;
|
1
|
34 |
|
5
|
35 |
<LEFT_BLOCK>: \[ | (\< \:) ;
|
|
36 |
<RIGHT_BLOCK>: \] | (\: \>) ;
|
|
37 |
<LEFT_BRACE>: \{ | (\< \%) ;
|
|
38 |
<RIGHT_BRACE>: \} | (\% \>) ;
|
1
|
39 |
|
5
|
40 |
<whitespace>: \s+ ;
|
|
41 |
"
|
1
|
42 |
|
5
|
43 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
44 |
! !
|
|
45 |
|
|
46 |
!CScanner class methodsFor:'generated-initialization'!
|
|
47 |
|
|
48 |
initializeKeywordMap
|
5
|
49 |
keywordMap := Dictionary new.
|
|
50 |
#( #(IDENTIFIER 'auto' 65)
|
|
51 |
#(IDENTIFIER 'break' 48)
|
|
52 |
#(IDENTIFIER 'case' 38)
|
|
53 |
#(IDENTIFIER 'char' 73)
|
|
54 |
#(IDENTIFIER 'const' 40)
|
|
55 |
#(IDENTIFIER 'continue' 47)
|
|
56 |
#(IDENTIFIER 'default' 39)
|
|
57 |
#(IDENTIFIER 'do' 54)
|
|
58 |
#(IDENTIFIER 'double' 70)
|
|
59 |
#(IDENTIFIER 'else' 46)
|
|
60 |
#(IDENTIFIER 'enum' 45)
|
|
61 |
#(IDENTIFIER 'extern' 58)
|
|
62 |
#(IDENTIFIER 'float' 67)
|
|
63 |
#(IDENTIFIER 'for' 49)
|
|
64 |
#(IDENTIFIER 'goto' 50)
|
|
65 |
#(IDENTIFIER 'if' 42)
|
|
66 |
#(IDENTIFIER 'int' 69)
|
|
67 |
#(IDENTIFIER 'long' 66)
|
|
68 |
#(IDENTIFIER 'register' 71)
|
|
69 |
#(IDENTIFIER 'return' 56)
|
|
70 |
#(IDENTIFIER 'short' 68)
|
|
71 |
#(IDENTIFIER 'signed' 51)
|
|
72 |
#(IDENTIFIER 'sizeof' 24)
|
|
73 |
#(IDENTIFIER 'static' 61)
|
|
74 |
#(IDENTIFIER 'struct' 43)
|
|
75 |
#(IDENTIFIER 'switch' 52)
|
|
76 |
#(IDENTIFIER 'typedef' 57)
|
|
77 |
#(IDENTIFIER 'union' 44)
|
|
78 |
#(IDENTIFIER 'unsigned' 55)
|
|
79 |
#(IDENTIFIER 'void' 72)
|
|
80 |
#(IDENTIFIER 'volatile' 41)
|
|
81 |
#(IDENTIFIER 'while' 53) )
|
|
82 |
do:[:each |
|
|
83 |
(keywordMap at:each first ifAbsentPut:[ Dictionary new ]) at:(each at:2)
|
|
84 |
put:each last
|
|
85 |
].
|
|
86 |
^ keywordMap
|
|
87 |
|
|
88 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
89 |
! !
|
|
90 |
|
|
91 |
!CScanner class methodsFor:'public'!
|
|
92 |
|
|
93 |
needsLineNumbers
|
|
94 |
^true
|
|
95 |
! !
|
|
96 |
|
|
97 |
!CScanner methodsFor:'default token handling'!
|
|
98 |
|
|
99 |
comment
|
|
100 |
| char |
|
|
101 |
|
|
102 |
[[(char := stream next) isNil or: [char == $*]] whileFalse.
|
|
103 |
stream atEnd ifTrue: [self scannerError].
|
|
104 |
stream peekFor: $/]
|
|
105 |
whileFalse.
|
|
106 |
^self whitespace
|
|
107 |
! !
|
|
108 |
|
|
109 |
!CScanner methodsFor:'generated-scanner'!
|
|
110 |
|
|
111 |
scan1
|
5
|
112 |
[
|
|
113 |
self recordMatch:#( 77 ).
|
|
114 |
self step.
|
|
115 |
(currentCharacter isXMLDigit)
|
|
116 |
] whileTrue.
|
|
117 |
(currentCharacter == $F
|
|
118 |
or:[
|
|
119 |
currentCharacter == $L
|
|
120 |
or:[ currentCharacter == $f or:[ currentCharacter == $l ] ]
|
|
121 |
])
|
|
122 |
ifTrue:[ ^ self recordAndReportMatch:#( 77 ). ].
|
|
123 |
^ self reportLastMatch
|
|
124 |
|
|
125 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
126 |
!
|
|
127 |
|
|
128 |
scan2
|
5
|
129 |
self step.
|
|
130 |
(currentCharacter isXMLDigit) ifTrue:[
|
|
131 |
^ self scan3
|
|
132 |
].
|
|
133 |
^ self reportLastMatch
|
|
134 |
|
|
135 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
136 |
!
|
|
137 |
|
|
138 |
scan3
|
5
|
139 |
[
|
|
140 |
self recordMatch:#( 77 ).
|
|
141 |
self step.
|
|
142 |
(currentCharacter isXMLDigit)
|
|
143 |
] whileTrue.
|
|
144 |
(currentCharacter == $F
|
|
145 |
or:[
|
|
146 |
currentCharacter == $L
|
|
147 |
or:[ currentCharacter == $f or:[ currentCharacter == $l ] ]
|
|
148 |
])
|
|
149 |
ifTrue:[ ^ self recordAndReportMatch:#( 77 ). ].
|
|
150 |
(currentCharacter == $E or:[ currentCharacter == $e ]) ifTrue:[
|
|
151 |
^ self scan4
|
|
152 |
].
|
|
153 |
^ self reportLastMatch
|
|
154 |
|
|
155 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
156 |
!
|
|
157 |
|
|
158 |
scan4
|
5
|
159 |
self step.
|
|
160 |
(currentCharacter isXMLDigit) ifTrue:[
|
|
161 |
^ self scan1
|
|
162 |
].
|
|
163 |
(currentCharacter == $+ or:[ currentCharacter == $- ]) ifTrue:[
|
|
164 |
self step.
|
|
165 |
(currentCharacter isXMLDigit) ifTrue:[
|
|
166 |
^ self scan1
|
|
167 |
].
|
|
168 |
^ self reportLastMatch
|
|
169 |
].
|
|
170 |
^ self reportLastMatch
|
|
171 |
|
|
172 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
173 |
!
|
|
174 |
|
|
175 |
scan5
|
5
|
176 |
self step.
|
|
177 |
(currentCharacter <= $!!
|
|
178 |
or:[ (currentCharacter between:$# and:$[) or:[ currentCharacter >= $] ] ])
|
|
179 |
ifTrue:[ ^ self scan6 ].
|
|
180 |
(currentCharacter == $\) ifTrue:[
|
|
181 |
^ self scan7
|
|
182 |
].
|
|
183 |
^ self reportLastMatch
|
|
184 |
|
|
185 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
186 |
!
|
|
187 |
|
|
188 |
scan6
|
5
|
189 |
[
|
|
190 |
self step.
|
|
191 |
(currentCharacter <= $!!
|
|
192 |
or:[
|
|
193 |
(currentCharacter between:$# and:$&)
|
|
194 |
or:[ (currentCharacter between:$( and:$[) or:[ currentCharacter >= $] ] ]
|
|
195 |
])
|
|
196 |
] whileTrue.
|
|
197 |
(currentCharacter == $') ifTrue:[
|
|
198 |
[
|
|
199 |
self recordMatch:#( 77 ).
|
|
200 |
self step.
|
|
201 |
(currentCharacter <= $!!
|
|
202 |
or:[
|
|
203 |
(currentCharacter between:$# and:$&)
|
|
204 |
or:[ (currentCharacter between:$( and:$[) or:[ currentCharacter >= $] ] ]
|
|
205 |
])
|
|
206 |
ifTrue:[ ^ self scan6 ].
|
|
207 |
(currentCharacter == $')
|
|
208 |
] whileTrue.
|
|
209 |
(currentCharacter == $\) ifTrue:[
|
|
210 |
^ self scan7
|
|
211 |
].
|
|
212 |
^ self reportLastMatch
|
|
213 |
].
|
|
214 |
(currentCharacter == $\) ifTrue:[
|
|
215 |
^ self scan7
|
|
216 |
].
|
|
217 |
^ self reportLastMatch
|
|
218 |
|
|
219 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
220 |
!
|
|
221 |
|
|
222 |
scan7
|
5
|
223 |
self step.
|
|
224 |
(currentCharacter isImmediate) ifTrue:[
|
|
225 |
^ self scan6
|
|
226 |
].
|
|
227 |
^ self reportLastMatch
|
|
228 |
|
|
229 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
230 |
!
|
|
231 |
|
|
232 |
scan8
|
5
|
233 |
[
|
|
234 |
self step.
|
|
235 |
(currentCharacter <= $!!
|
|
236 |
or:[ (currentCharacter between:$# and:$[) or:[ currentCharacter >= $] ] ])
|
|
237 |
] whileTrue.
|
|
238 |
(currentCharacter == $") ifTrue:[
|
|
239 |
^ self recordAndReportMatch:#( 78 ).
|
|
240 |
].
|
|
241 |
(currentCharacter == $\) ifTrue:[
|
|
242 |
self step.
|
|
243 |
(currentCharacter isImmediate) ifTrue:[
|
|
244 |
^ self scan8
|
|
245 |
].
|
|
246 |
^ self reportLastMatch
|
|
247 |
].
|
|
248 |
^ self reportLastMatch
|
|
249 |
|
|
250 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
251 |
!
|
|
252 |
|
|
253 |
scan9
|
5
|
254 |
[
|
|
255 |
self recordMatch:#( 77 ).
|
|
256 |
self step.
|
|
257 |
(currentCharacter isXMLDigit)
|
|
258 |
] whileTrue.
|
|
259 |
(currentCharacter == $L
|
|
260 |
or:[
|
|
261 |
currentCharacter == $U
|
|
262 |
or:[ currentCharacter == $l or:[ currentCharacter == $u ] ]
|
|
263 |
])
|
|
264 |
ifTrue:[ ^ self recordAndReportMatch:#( 77 ). ].
|
|
265 |
(currentCharacter == $E or:[ currentCharacter == $e ]) ifTrue:[
|
|
266 |
^ self scan4
|
|
267 |
].
|
|
268 |
(currentCharacter == $.) ifTrue:[
|
|
269 |
^ self scan2
|
|
270 |
].
|
|
271 |
^ self reportLastMatch
|
|
272 |
|
|
273 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
274 |
!
|
|
275 |
|
|
276 |
scanForToken
|
5
|
277 |
self step.
|
|
278 |
((currentCharacter between:$A and:$K)
|
|
279 |
or:[
|
|
280 |
(currentCharacter between:$M and:$Z)
|
|
281 |
or:[ currentCharacter == $_ or:[ (currentCharacter between:$a and:$z) ] ]
|
|
282 |
])
|
|
283 |
ifTrue:[
|
|
284 |
[
|
|
285 |
self recordMatch:#IDENTIFIER.
|
|
286 |
self step.
|
|
287 |
(currentCharacter isLetterOrDigit or:[ currentCharacter == $_ ])
|
|
288 |
] whileTrue.
|
|
289 |
^ self reportLastMatch
|
|
290 |
].
|
|
291 |
(currentCharacter between:$1 and:$9) ifTrue:[
|
|
292 |
^ self scan9
|
|
293 |
].
|
|
294 |
(currentCharacter isSeparator
|
|
295 |
or:[ currentCharacter == (Character codePoint:16rB) ])
|
|
296 |
ifTrue:[
|
|
297 |
[
|
|
298 |
self recordMatch:#whitespace.
|
|
299 |
self step.
|
|
300 |
(currentCharacter isSeparator
|
|
301 |
or:[ currentCharacter == (Character codePoint:16rB) ])
|
|
302 |
] whileTrue.
|
|
303 |
^ self reportLastMatch
|
|
304 |
].
|
|
305 |
(currentCharacter == $!!) ifTrue:[
|
|
306 |
self recordMatch:#( 32 ).
|
|
307 |
self step.
|
|
308 |
(currentCharacter == $=) ifTrue:[
|
|
309 |
^ self recordAndReportMatch:#( 4 ).
|
|
310 |
].
|
|
311 |
^ self reportLastMatch
|
|
312 |
].
|
|
313 |
(currentCharacter == $") ifTrue:[
|
|
314 |
^ self scan8
|
|
315 |
].
|
|
316 |
(currentCharacter == $%) ifTrue:[
|
|
317 |
self recordMatch:#( 30 ).
|
|
318 |
self step.
|
|
319 |
(currentCharacter == $=) ifTrue:[
|
|
320 |
^ self recordAndReportMatch:#( 10 ).
|
|
321 |
].
|
|
322 |
(currentCharacter == $>) ifTrue:[
|
|
323 |
^ self recordAndReportMatch:#( 82 ).
|
|
324 |
].
|
|
325 |
^ self reportLastMatch
|
|
326 |
].
|
|
327 |
(currentCharacter == $&) ifTrue:[
|
|
328 |
self recordMatch:#( 28 ).
|
|
329 |
self step.
|
|
330 |
(currentCharacter == $&) ifTrue:[
|
|
331 |
^ self recordAndReportMatch:#( 5 ).
|
|
332 |
].
|
|
333 |
(currentCharacter == $=) ifTrue:[
|
|
334 |
^ self recordAndReportMatch:#( 63 ).
|
|
335 |
].
|
|
336 |
^ self reportLastMatch
|
|
337 |
].
|
|
338 |
(currentCharacter == $') ifTrue:[
|
|
339 |
^ self scan5
|
|
340 |
].
|
|
341 |
(currentCharacter == $() ifTrue:[
|
|
342 |
^ self recordAndReportMatch:#( 25 ).
|
|
343 |
].
|
|
344 |
(currentCharacter == $)) ifTrue:[
|
|
345 |
^ self recordAndReportMatch:#( 26 ).
|
|
346 |
].
|
|
347 |
(currentCharacter == $*) ifTrue:[
|
|
348 |
self recordMatch:#( 34 ).
|
|
349 |
self step.
|
|
350 |
(currentCharacter == $=) ifTrue:[
|
|
351 |
^ self recordAndReportMatch:#( 12 ).
|
|
352 |
].
|
|
353 |
^ self reportLastMatch
|
|
354 |
].
|
|
355 |
(currentCharacter == $+) ifTrue:[
|
|
356 |
self recordMatch:#( 35 ).
|
|
357 |
self step.
|
|
358 |
(currentCharacter == $+) ifTrue:[
|
|
359 |
^ self recordAndReportMatch:#( 23 ).
|
|
360 |
].
|
|
361 |
(currentCharacter == $=) ifTrue:[
|
|
362 |
^ self recordAndReportMatch:#( 11 ).
|
|
363 |
].
|
|
364 |
^ self reportLastMatch
|
|
365 |
].
|
|
366 |
(currentCharacter == $,) ifTrue:[
|
|
367 |
^ self recordAndReportMatch:#( 21 ).
|
|
368 |
].
|
|
369 |
(currentCharacter == $-) ifTrue:[
|
|
370 |
self recordMatch:#( 36 ).
|
|
371 |
self step.
|
|
372 |
(currentCharacter == $-) ifTrue:[
|
|
373 |
^ self recordAndReportMatch:#( 20 ).
|
|
374 |
].
|
|
375 |
(currentCharacter == $=) ifTrue:[
|
|
376 |
^ self recordAndReportMatch:#( 19 ).
|
|
377 |
].
|
|
378 |
(currentCharacter == $>) ifTrue:[
|
|
379 |
^ self recordAndReportMatch:#( 22 ).
|
|
380 |
].
|
|
381 |
^ self reportLastMatch
|
|
382 |
].
|
|
383 |
(currentCharacter == $.) ifTrue:[
|
|
384 |
self recordMatch:#( 27 ).
|
|
385 |
self step.
|
|
386 |
(currentCharacter isXMLDigit) ifTrue:[
|
|
387 |
^ self scan3
|
|
388 |
].
|
|
389 |
(currentCharacter == $.) ifTrue:[
|
|
390 |
self step.
|
|
391 |
(currentCharacter == $.) ifTrue:[
|
|
392 |
^ self recordAndReportMatch:#( 74 ).
|
|
393 |
].
|
|
394 |
^ self reportLastMatch
|
|
395 |
].
|
|
396 |
^ self reportLastMatch
|
|
397 |
].
|
|
398 |
(currentCharacter == $/) ifTrue:[
|
|
399 |
self recordMatch:#( 29 ).
|
|
400 |
self step.
|
|
401 |
(currentCharacter == $*) ifTrue:[
|
|
402 |
^ self recordAndReportMatch:#comment.
|
|
403 |
].
|
|
404 |
(currentCharacter == $=) ifTrue:[
|
|
405 |
^ self recordAndReportMatch:#( 13 ).
|
|
406 |
].
|
|
407 |
^ self reportLastMatch
|
|
408 |
].
|
|
409 |
(currentCharacter == $0) ifTrue:[
|
|
410 |
self recordMatch:#( 77 ).
|
|
411 |
self step.
|
|
412 |
(currentCharacter isXMLDigit) ifTrue:[
|
|
413 |
^ self scan9
|
|
414 |
].
|
|
415 |
(currentCharacter == $L
|
|
416 |
or:[
|
|
417 |
currentCharacter == $U
|
|
418 |
or:[ currentCharacter == $l or:[ currentCharacter == $u ] ]
|
|
419 |
])
|
|
420 |
ifTrue:[ ^ self recordAndReportMatch:#( 77 ). ].
|
|
421 |
(currentCharacter == $E or:[ currentCharacter == $e ]) ifTrue:[
|
|
422 |
^ self scan4
|
|
423 |
].
|
|
424 |
(currentCharacter == $X or:[ currentCharacter == $x ]) ifTrue:[
|
|
425 |
self step.
|
|
426 |
(currentCharacter isXMLDigit
|
|
427 |
or:[
|
|
428 |
(currentCharacter between:$A and:$F)
|
|
429 |
or:[ (currentCharacter between:$a and:$f) ]
|
|
430 |
])
|
|
431 |
ifTrue:[
|
|
432 |
[
|
|
433 |
self recordMatch:#( 77 ).
|
|
434 |
self step.
|
|
435 |
(currentCharacter isXMLDigit
|
|
436 |
or:[
|
|
437 |
(currentCharacter between:$A and:$F)
|
|
438 |
or:[ (currentCharacter between:$a and:$f) ]
|
|
439 |
])
|
|
440 |
] whileTrue.
|
|
441 |
(currentCharacter == $L
|
|
442 |
or:[
|
|
443 |
currentCharacter == $U
|
|
444 |
or:[ currentCharacter == $l or:[ currentCharacter == $u ] ]
|
|
445 |
])
|
|
446 |
ifTrue:[ ^ self recordAndReportMatch:#( 77 ). ].
|
|
447 |
^ self reportLastMatch
|
|
448 |
].
|
|
449 |
^ self reportLastMatch
|
|
450 |
].
|
|
451 |
(currentCharacter == $.) ifTrue:[
|
|
452 |
^ self scan2
|
|
453 |
].
|
|
454 |
^ self reportLastMatch
|
|
455 |
].
|
|
456 |
(currentCharacter == $:) ifTrue:[
|
|
457 |
self recordMatch:#( 16 ).
|
|
458 |
self step.
|
|
459 |
(currentCharacter == $>) ifTrue:[
|
|
460 |
^ self recordAndReportMatch:#( 80 ).
|
|
461 |
].
|
|
462 |
^ self reportLastMatch
|
|
463 |
].
|
|
464 |
(currentCharacter == $;) ifTrue:[
|
|
465 |
^ self recordAndReportMatch:#( 60 ).
|
|
466 |
].
|
|
467 |
(currentCharacter == $<) ifTrue:[
|
|
468 |
self recordMatch:#( 18 ).
|
|
469 |
self step.
|
|
470 |
(currentCharacter == $%) ifTrue:[
|
|
471 |
^ self recordAndReportMatch:#( 81 ).
|
|
472 |
].
|
|
473 |
(currentCharacter == $:) ifTrue:[
|
|
474 |
^ self recordAndReportMatch:#( 79 ).
|
|
475 |
].
|
|
476 |
(currentCharacter == $<) ifTrue:[
|
|
477 |
self recordMatch:#( 33 ).
|
|
478 |
self step.
|
|
479 |
(currentCharacter == $=) ifTrue:[
|
|
480 |
^ self recordAndReportMatch:#( 37 ).
|
|
481 |
].
|
|
482 |
^ self reportLastMatch
|
|
483 |
].
|
|
484 |
(currentCharacter == $=) ifTrue:[
|
|
485 |
^ self recordAndReportMatch:#( 7 ).
|
|
486 |
].
|
|
487 |
^ self reportLastMatch
|
|
488 |
].
|
|
489 |
(currentCharacter == $=) ifTrue:[
|
|
490 |
self recordMatch:#( 17 ).
|
|
491 |
self step.
|
|
492 |
(currentCharacter == $=) ifTrue:[
|
|
493 |
^ self recordAndReportMatch:#( 3 ).
|
|
494 |
].
|
|
495 |
^ self reportLastMatch
|
|
496 |
].
|
|
497 |
(currentCharacter == $>) ifTrue:[
|
|
498 |
self recordMatch:#( 6 ).
|
|
499 |
self step.
|
|
500 |
(currentCharacter == $=) ifTrue:[
|
|
501 |
^ self recordAndReportMatch:#( 8 ).
|
|
502 |
].
|
|
503 |
(currentCharacter == $>) ifTrue:[
|
|
504 |
self recordMatch:#( 14 ).
|
|
505 |
self step.
|
|
506 |
(currentCharacter == $=) ifTrue:[
|
|
507 |
^ self recordAndReportMatch:#( 62 ).
|
|
508 |
].
|
|
509 |
^ self reportLastMatch
|
|
510 |
].
|
|
511 |
^ self reportLastMatch
|
|
512 |
].
|
|
513 |
(currentCharacter == $?) ifTrue:[
|
|
514 |
^ self recordAndReportMatch:#( 15 ).
|
|
515 |
].
|
|
516 |
(currentCharacter == $L) ifTrue:[
|
|
517 |
self recordMatch:#IDENTIFIER.
|
|
518 |
self step.
|
|
519 |
(currentCharacter isLetterOrDigit or:[ currentCharacter == $_ ]) ifTrue:[
|
|
520 |
[
|
|
521 |
self recordMatch:#IDENTIFIER.
|
|
522 |
self step.
|
|
523 |
(currentCharacter isLetterOrDigit or:[ currentCharacter == $_ ])
|
|
524 |
] whileTrue.
|
|
525 |
^ self reportLastMatch
|
|
526 |
].
|
|
527 |
(currentCharacter == $") ifTrue:[
|
|
528 |
^ self scan8
|
|
529 |
].
|
|
530 |
(currentCharacter == $') ifTrue:[
|
|
531 |
^ self scan5
|
|
532 |
].
|
|
533 |
^ self reportLastMatch
|
|
534 |
].
|
|
535 |
(currentCharacter == $[) ifTrue:[
|
|
536 |
^ self recordAndReportMatch:#( 79 ).
|
|
537 |
].
|
|
538 |
(currentCharacter == $]) ifTrue:[
|
|
539 |
^ self recordAndReportMatch:#( 80 ).
|
|
540 |
].
|
|
541 |
(currentCharacter == $^) ifTrue:[
|
|
542 |
self recordMatch:#( 1 ).
|
|
543 |
self step.
|
|
544 |
(currentCharacter == $=) ifTrue:[
|
|
545 |
^ self recordAndReportMatch:#( 64 ).
|
|
546 |
].
|
|
547 |
^ self reportLastMatch
|
|
548 |
].
|
|
549 |
(currentCharacter == ${) ifTrue:[
|
|
550 |
^ self recordAndReportMatch:#( 81 ).
|
|
551 |
].
|
|
552 |
(currentCharacter == $|) ifTrue:[
|
|
553 |
self recordMatch:#( 2 ).
|
|
554 |
self step.
|
|
555 |
(currentCharacter == $=) ifTrue:[
|
|
556 |
^ self recordAndReportMatch:#( 59 ).
|
|
557 |
].
|
|
558 |
(currentCharacter == $|) ifTrue:[
|
|
559 |
^ self recordAndReportMatch:#( 9 ).
|
|
560 |
].
|
|
561 |
^ self reportLastMatch
|
|
562 |
].
|
|
563 |
(currentCharacter == $}) ifTrue:[
|
|
564 |
^ self recordAndReportMatch:#( 82 ).
|
|
565 |
].
|
|
566 |
(currentCharacter == $~) ifTrue:[
|
|
567 |
^ self recordAndReportMatch:#( 31 ).
|
|
568 |
].
|
|
569 |
^ self reportLastMatch
|
|
570 |
|
|
571 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
572 |
! !
|
|
573 |
|
|
574 |
!CScanner methodsFor:'generated-tokens'!
|
|
575 |
|
|
576 |
CONSTANTId
|
|
577 |
^77
|
5
|
578 |
|
|
579 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
580 |
!
|
|
581 |
|
|
582 |
IDENTIFIERId
|
|
583 |
^76
|
5
|
584 |
|
|
585 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
586 |
!
|
|
587 |
|
|
588 |
TYPE_NAMEId
|
5
|
589 |
^132
|
|
590 |
|
|
591 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
592 |
!
|
|
593 |
|
|
594 |
emptySymbolTokenId
|
5
|
595 |
^147
|
|
596 |
|
|
597 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
598 |
!
|
|
599 |
|
|
600 |
errorTokenId
|
5
|
601 |
^148
|
|
602 |
|
|
603 |
"Modified: / 18-11-2008 / 13:47:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
1
|
604 |
! !
|
|
605 |
|
|
606 |
!CScanner methodsFor:'initialize-release'!
|
|
607 |
|
|
608 |
initialize
|
|
609 |
super initialize.
|
|
610 |
typeNames := Set new
|
|
611 |
! !
|
|
612 |
|
|
613 |
!CScanner methodsFor:'public'!
|
|
614 |
|
|
615 |
IDENTIFIER
|
|
616 |
| name token |
|
|
617 |
name := outputStream contents.
|
|
618 |
matchActions := (typeNames includes: name)
|
|
619 |
ifTrue: [Array with: self TYPE_NAMEId]
|
|
620 |
ifFalse: [Array with: self IDENTIFIERId].
|
|
621 |
outputStream reset.
|
|
622 |
token := SmaCCToken
|
|
623 |
value: name
|
|
624 |
start: start
|
|
625 |
id: matchActions.
|
|
626 |
matchActions := nil.
|
|
627 |
returnMatchBlock value: token
|
|
628 |
!
|
|
629 |
|
|
630 |
addTypeName: aString
|
|
631 |
typeNames add: aString
|
|
632 |
! !
|
|
633 |
|
|
634 |
!CScanner class methodsFor:'documentation'!
|
|
635 |
|
|
636 |
version
|
|
637 |
^ '$Header: /opt/data/cvs/stx/goodies/smaCC/SmaCC__CScanner.st,v 1.1 2006-02-09 21:13:27 vranyj1 Exp $'
|
|
638 |
! !
|