7 classVariableNames:'' |
7 classVariableNames:'' |
8 poolDictionaries:'' |
8 poolDictionaries:'' |
9 category:'PetitCompiler-Visitors' |
9 category:'PetitCompiler-Visitors' |
10 ! |
10 ! |
11 |
11 |
12 !PPCTokenDetector methodsFor:'visiting'! |
12 !PPCTokenDetector methodsFor:'as yet unclassified'! |
13 |
13 |
14 visitActionNode: node |
14 visitActionNode: node |
15 (node hasProperty: #trimmingToken) ifTrue: [ |
|
16 | newWs newChild | |
|
17 self change. |
|
18 |
15 |
19 newChild := self visitWithTokenVisitor: node child children second child. "Oups, what a chain" |
16 (node hasProperty: #trimmingToken) ifTrue: [ |
20 newWs := self visitWithTokenVisitor: node child children first. |
17 | child whitespace | |
|
18 self change. |
|
19 child := self visitWithTokenVisitor: node child secondChild. |
|
20 whitespace := self visitWithTokenVisitor: node child firstChild. |
|
21 |
|
22 ^ PPCTrimmingTokenNode new |
|
23 name: node name; |
|
24 child: child; |
|
25 whitespace: whitespace; |
|
26 tokenClass: node child secondChild tokenClass; |
|
27 properties: node properties copy; |
|
28 yourself. |
|
29 ]. |
21 |
30 |
22 ^ PPCTrimmingTokenNode new |
31 ^ super visitActionNode: node |
23 name: node name; |
|
24 child: newChild; |
|
25 tokenClass: node child children second tokenClass; |
|
26 whitespace: newWs; |
|
27 yourself. |
|
28 ]. |
|
29 |
|
30 ^ super visitActionNode: node |
|
31 ! |
32 ! |
32 |
33 |
33 visitNotNode: node |
34 visitTokenNode: node |
34 "We don't need result of the not,..." |
35 | child newChild | |
35 | child newChild | |
36 self change. |
36 self change. |
37 child := node child. |
37 child := node child. |
38 newChild := self visitWithTokenVisitor: node child. |
38 newChild := self visitWithTokenVisitor: child. |
39 node replace: child with: newChild. |
39 node replace: child with: newChild. |
40 |
40 ^ node |
41 ^ node |
41 ! |
42 ! |
42 |
43 |
43 visitTokenNode: node |
44 visitTrimNode: node |
44 | child newChild | |
45 self visitChildren: node. |
45 |
46 |
46 self change. |
47 (node child isKindOf: PPCTokenNode) ifTrue: [ |
47 child := node child. |
48 self change. |
48 newChild := self visitWithTokenVisitor: child. |
49 ^ PPCTrimmingTokenNode new |
49 node replace: child with: newChild. |
50 name: node name; |
50 |
51 child: node child child; |
51 ^ node |
52 tokenClass: node child tokenClass; |
|
53 whitespace: node trimmer; |
|
54 yourself |
|
55 ]. |
|
56 |
|
57 (node child isKindOf: PPCTokenConsumeNode) ifTrue: [ |
|
58 self change. |
|
59 ^ PPCTrimmingTokenNode new |
|
60 name: node name; |
|
61 child: node child; |
|
62 tokenClass: node child child tokenClass; |
|
63 whitespace: node trimmer; |
|
64 yourself |
|
65 ]. |
|
66 |
|
67 |
|
68 ^ node |
52 ! |
69 ! |
53 |
70 |
54 visitWithTokenVisitor: node |
71 visitWithTokenVisitor: node |
55 | retval forbiddenNodes copyVisitor tokenVisitor | |
72 | retval forbiddenNodes copyVisitor tokenVisitor | |
56 |
73 |
57 copyVisitor := PPCCopyVisitor new. |
74 copyVisitor := PPCCopyVisitor new. |
58 tokenVisitor := PPCTokenVisitor new. |
75 tokenVisitor := PPCTokenVisitor new. |
59 |
76 |
60 forbiddenNodes := openSet copy. |
77 forbiddenNodes := openSet copy. |
61 tokenVisitor forbiddenNodes: forbiddenNodes. |
78 tokenVisitor forbiddenNodes: forbiddenNodes. |
62 |
79 |
63 retval := copyVisitor visit: node. |
80 retval := copyVisitor visit: node. |
64 retval := tokenVisitor visit: retval. |
81 retval := tokenVisitor visit: retval. |
65 ^ retval |
82 ^ retval |
66 ! ! |
83 ! ! |
67 |
84 |