|
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
|
2 |
|
3 PPCDelegateNode subclass:#PPCStarNode |
|
4 instanceVariableNames:'' |
|
5 classVariableNames:'' |
|
6 poolDictionaries:'' |
|
7 category:'PetitCompiler-Nodes' |
|
8 ! |
|
9 |
|
10 PPCStarNode comment:'' |
|
11 ! |
|
12 |
|
13 !PPCStarNode methodsFor:'accessing'! |
|
14 |
|
15 acceptsEpsilon |
|
16 ^ true |
|
17 ! |
|
18 |
|
19 acceptsEpsilonOpenSet: set |
|
20 ^ true |
|
21 ! |
|
22 |
|
23 prefix |
|
24 ^ #star |
|
25 ! |
|
26 |
|
27 rewrite: changeStatus |
|
28 (child isKindOf: PPCMessagePredicateNode) ifTrue: [ |
|
29 changeStatus change. |
|
30 ^ PPCStarMessagePredicateNode new |
|
31 name: name; |
|
32 message: child message; |
|
33 yourself |
|
34 ]. |
|
35 |
|
36 (child isKindOf: PPCAnyNode) ifTrue: [ |
|
37 changeStatus change. |
|
38 ^ PPCStarAnyNode new |
|
39 name: name; |
|
40 yourself |
|
41 ]. |
|
42 |
|
43 (child isKindOf: PPCCharSetPredicateNode) ifTrue: [ |
|
44 changeStatus change. |
|
45 ^ PPCStarCharSetPredicateNode new |
|
46 name: name; |
|
47 predicate: child predicate; |
|
48 yourself |
|
49 ] |
|
50 ! ! |
|
51 |
|
52 !PPCStarNode methodsFor:'as yet unclassified'! |
|
53 |
|
54 compileWith: compiler effect: effect id: id |
|
55 compiler startMethod: id. |
|
56 compiler addVariable: 'retval'. |
|
57 compiler addVariable: 'element'. |
|
58 |
|
59 compiler add: 'retval := OrderedCollection new.'. |
|
60 compiler add: 'element := '. |
|
61 compiler callOnLine: (child compileWith: compiler). |
|
62 compiler add: '[ error ] whileFalse: ['. |
|
63 compiler indent. |
|
64 compiler add: 'retval add: element.'. |
|
65 compiler add: 'element := '. |
|
66 compiler callOnLine: (child compileWith: compiler). |
|
67 compiler dedent. |
|
68 compiler add: '].'. |
|
69 compiler add: 'self clearError.'. |
|
70 compiler add: '^ retval asArray'. |
|
71 ^ compiler stopMethod. |
|
72 ! ! |
|
73 |