1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
2 |
2 |
3 "{ NameSpace: Smalltalk }" |
3 "{ NameSpace: Smalltalk }" |
4 |
4 |
5 PPCAbstractCharacterNode subclass:#PPCCharacterNode |
5 PPCNode subclass:#PPCCharacterNode |
6 instanceVariableNames:'' |
6 instanceVariableNames:'character' |
7 classVariableNames:'' |
7 classVariableNames:'' |
8 poolDictionaries:'' |
8 poolDictionaries:'' |
9 category:'PetitCompiler-Nodes' |
9 category:'PetitCompiler-Nodes' |
10 ! |
10 ! |
11 |
11 |
12 !PPCCharacterNode methodsFor:'as yet unclassified'! |
12 !PPCCharacterNode methodsFor:'accessing'! |
13 |
13 |
14 start: compiler id: id |
14 character |
15 compiler startMethod: id. |
15 ^ character |
16 compiler add: '^ '. |
|
17 ! |
16 ! |
18 |
17 |
19 stop: compiler |
18 character: char |
20 ^ compiler stopMethod |
19 character := char |
|
20 ! |
|
21 |
|
22 prefix |
|
23 ^ #char |
|
24 ! ! |
|
25 |
|
26 !PPCCharacterNode methodsFor:'analysis'! |
|
27 |
|
28 acceptsEpsilon |
|
29 ^ false |
|
30 ! |
|
31 |
|
32 firstCharSet |
|
33 ^ PPCharSetPredicate on: [:e | e = character ] |
|
34 ! |
|
35 |
|
36 recognizedSentencesPrim |
|
37 ^ Array with: character asString |
|
38 ! ! |
|
39 |
|
40 !PPCCharacterNode methodsFor:'comparison'! |
|
41 |
|
42 = anotherNode |
|
43 super = anotherNode ifFalse: [ ^ false ]. |
|
44 ^ character = anotherNode character. |
|
45 ! |
|
46 |
|
47 hash |
|
48 ^ super hash bitXor: character hash |
|
49 ! ! |
|
50 |
|
51 !PPCCharacterNode methodsFor:'printing'! |
|
52 |
|
53 printNameOn: aStream |
|
54 super printNameOn: aStream. |
|
55 |
|
56 character = $" ifTrue: [ |
|
57 "this is hack to allow for printing '' in comments..." |
|
58 aStream nextPutAll: ', '; nextPutAll: '$'''''. |
|
59 ^ self |
|
60 ]. |
|
61 |
|
62 aStream nextPutAll: ', not('; print: character; nextPutAll: ')' |
21 ! ! |
63 ! ! |
22 |
64 |
23 !PPCCharacterNode methodsFor:'visiting'! |
65 !PPCCharacterNode methodsFor:'visiting'! |
24 |
66 |
25 accept: visitor |
67 accept: visitor |