|
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
|
2 |
|
3 PPCDelegateNode subclass:#PPCNotNode |
|
4 instanceVariableNames:'' |
|
5 classVariableNames:'' |
|
6 poolDictionaries:'' |
|
7 category:'PetitCompiler-Nodes' |
|
8 ! |
|
9 |
|
10 PPCNotNode comment:'' |
|
11 ! |
|
12 |
|
13 !PPCNotNode methodsFor:'accessing'! |
|
14 |
|
15 prefix |
|
16 ^ #not |
|
17 ! ! |
|
18 |
|
19 !PPCNotNode methodsFor:'analysis'! |
|
20 |
|
21 isFirstSetTerminal |
|
22 ^ false |
|
23 ! ! |
|
24 |
|
25 !PPCNotNode methodsFor:'compiling'! |
|
26 |
|
27 compileWith: compiler effect: effect id: id |
|
28 |
|
29 compiler startMethod: id. |
|
30 compiler addVariable: 'memento'. |
|
31 compiler add: (compiler smartRemember: child). |
|
32 |
|
33 compiler startTokenMode. |
|
34 compiler call: (child compileWith: compiler). |
|
35 compiler stopTokenMode. |
|
36 compiler add: (compiler smartRestore: child). |
|
37 |
|
38 compiler add: '^ error ifFalse: [ self error ] ifTrue: [ self clearError. nil ]'. |
|
39 ^ compiler stopMethod. |
|
40 ! ! |
|
41 |
|
42 !PPCNotNode methodsFor:'optimizing'! |
|
43 |
|
44 optimize: params |
|
45 (self rewrite: params) ifTrue: [ |
|
46 ^ true. |
|
47 ]. |
|
48 ^ super optimize: params. |
|
49 ! |
|
50 |
|
51 rewrite: changeStatus |
|
52 (child isKindOf: PPCAbstractLiteralNode) ifTrue: [ |
|
53 changeStatus change. |
|
54 ^ PPCNotLiteralNode new |
|
55 name: self name; |
|
56 literal: self child literal; |
|
57 yourself |
|
58 ]. |
|
59 |
|
60 (child isKindOf: PPCMessagePredicateNode) ifTrue: [ |
|
61 changeStatus change. |
|
62 ^ PPCNotMessagePredicateNode new |
|
63 name: self name; |
|
64 message: child message; |
|
65 yourself |
|
66 ]. |
|
67 |
|
68 (child isKindOf: PPCCharSetPredicateNode) ifTrue: [ |
|
69 changeStatus change. |
|
70 ^ PPCNotCharSetPredicateNode new |
|
71 name: self name; |
|
72 predicate: child predicate; |
|
73 yourself |
|
74 ] |
|
75 ! ! |
|
76 |