|
1 "{ Package: 'stx:goodies/petitparser/compiler/tests/extras' }" |
|
2 |
|
3 "{ NameSpace: Smalltalk }" |
|
4 |
|
5 PPCLRPContainedElement subclass:#PPCLRPMachine |
|
6 instanceVariableNames:'initState name body currentState scope triggeredTransition |
|
7 compareStates compareTransitions' |
|
8 classVariableNames:'' |
|
9 poolDictionaries:'' |
|
10 category:'PetitCompiler-Extras-Tests-LRP' |
|
11 ! |
|
12 |
|
13 !PPCLRPMachine class methodsFor:'instance creation'! |
|
14 |
|
15 name: aString body: anArray |
|
16 |retval| |
|
17 retval := self new. |
|
18 retval name: aString. |
|
19 retval body: anArray. |
|
20 ^retval |
|
21 ! ! |
|
22 |
|
23 !PPCLRPMachine methodsFor:'accessing'! |
|
24 |
|
25 allTransitions |
|
26 ^self body select:[:item | item isKindOf: PPCLRPTransition] |
|
27 ! |
|
28 |
|
29 body |
|
30 ^ body |
|
31 ! |
|
32 |
|
33 body: anObject |
|
34 body := anObject. |
|
35 body do: [ :aBodyElement| aBodyElement container: self ]. |
|
36 ! |
|
37 |
|
38 containerMachine |
|
39 self container isNil |
|
40 ifTrue: [ ^nil ] |
|
41 ifFalse: [ ^self container container ] |
|
42 ! |
|
43 |
|
44 eps |
|
45 ^self body select:[:item | item isMemberOf: PPCLRPEpsilonTransition] |
|
46 ! |
|
47 |
|
48 events |
|
49 ^self body select:[:item | item class = PPCLRPEvent] |
|
50 ! |
|
51 |
|
52 machines |
|
53 ^self body select:[:item | item class = PPCLRPMachine] |
|
54 ! |
|
55 |
|
56 myVarsAndParentVars |
|
57 |
|
58 |recblock | |
|
59 recblock := [ ]. |
|
60 recblock := [ :aMachine| |variables| |
|
61 aMachine ifNil:[ |
|
62 OrderedCollection new. |
|
63 ] ifNotNil: [ |
|
64 variables := recblock value: aMachine containerMachine. |
|
65 variables addAll: (aMachine variables collect:[:aVarNode| aVarNode name]). |
|
66 variables |
|
67 ] |
|
68 ]. |
|
69 |
|
70 ^recblock value: self. |
|
71 |
|
72 ! |
|
73 |
|
74 name |
|
75 ^ name |
|
76 ! |
|
77 |
|
78 name: anObject |
|
79 name := anObject |
|
80 ! |
|
81 |
|
82 ontime |
|
83 ^self body select:[:item | item isMemberOf: PPCLRPTimeoutTransition] |
|
84 ! |
|
85 |
|
86 states |
|
87 ^self body select:[:item | item class = PPCLRPState] |
|
88 ! |
|
89 |
|
90 transitions |
|
91 ^self body select:[:item | item isMemberOf: PPCLRPTransition] |
|
92 ! |
|
93 |
|
94 variables |
|
95 ^self body select:[:item | item class = PPCLRPVariable] |
|
96 ! |
|
97 |
|
98 wildtrans |
|
99 ^self body select:[:item | item class = PPCLRPWildcardTransition] |
|
100 ! ! |
|
101 |
|
102 !PPCLRPMachine methodsFor:'error handing'! |
|
103 |
|
104 onErrorNode: aBlock parser: aPPCLRPParser |
|
105 |
|
106 ^body do: [ :aNode| aNode onErrorNode: aBlock parser: aPPCLRPParser] |
|
107 ! ! |
|
108 |
|
109 !PPCLRPMachine methodsFor:'printing'! |
|
110 |
|
111 printOn: aStream |
|
112 aStream nextPutAll: 'PPCLRPMachine '. |
|
113 aStream nextPutAll: self name. |
|
114 aStream nextPutAll: ' : '. |
|
115 aStream nextPutAll: self body asString. |
|
116 |
|
117 ! ! |
|
118 |
|
119 !PPCLRPMachine methodsFor:'visiting'! |
|
120 |
|
121 acceptVisitor: aPPCLRPNodeVisitor |
|
122 aPPCLRPNodeVisitor visitMachineNode: self. |
|
123 ! ! |
|
124 |