1
|
1 |
"{ Package: 'stx:goodies/smaCC' }"
|
|
2 |
|
|
3 |
"{ NameSpace: SmaCC }"
|
|
4 |
|
|
5 |
SmaCCRegularExpressionNode subclass:#SmaCCOrRENode
|
|
6 |
instanceVariableNames:'nodes'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'SmaCC-Scanner Generator'
|
|
10 |
!
|
|
11 |
|
|
12 |
SmaCCOrRENode comment:'SmaCCOrRENode is a SmaCCRegularExpressionNode that represents an alternative.
|
|
13 |
|
|
14 |
Instance Variables:
|
|
15 |
nodes <Collection of: SmaCCRegularExpressionNode> our possible choices'
|
|
16 |
!
|
|
17 |
|
|
18 |
|
|
19 |
!SmaCCOrRENode class methodsFor:'instance creation'!
|
|
20 |
|
|
21 |
nodes: aCollection
|
|
22 |
^(self new)
|
|
23 |
nodes: aCollection;
|
|
24 |
yourself
|
|
25 |
! !
|
|
26 |
|
|
27 |
!SmaCCOrRENode methodsFor:'accessing'!
|
|
28 |
|
|
29 |
possibleMatchesSize
|
|
30 |
^nodes inject: 0 into: [:sum :each | sum + each possibleMatchesSize]
|
|
31 |
!
|
|
32 |
|
|
33 |
| aScannerNode
|
|
34 |
self action = aScannerNode action ifFalse: [^super | aScannerNode].
|
|
35 |
nodes add: aScannerNode.
|
|
36 |
^self
|
|
37 |
! !
|
|
38 |
|
|
39 |
!SmaCCOrRENode methodsFor:'copying'!
|
|
40 |
|
|
41 |
postCopy
|
|
42 |
super postCopy.
|
|
43 |
nodes := nodes copy
|
|
44 |
! !
|
|
45 |
|
|
46 |
!SmaCCOrRENode methodsFor:'initialize-release'!
|
|
47 |
|
|
48 |
nodes: aCollection
|
|
49 |
nodes := aCollection
|
|
50 |
! !
|
|
51 |
|
|
52 |
!SmaCCOrRENode methodsFor:'printing'!
|
|
53 |
|
|
54 |
printOn: aStream
|
|
55 |
aStream nextPut: $(.
|
|
56 |
nodes do: [:each | each printOn: aStream]
|
|
57 |
separatedBy: [aStream nextPutAll: ' | '].
|
|
58 |
aStream nextPut: $)
|
|
59 |
! !
|
|
60 |
|
|
61 |
!SmaCCOrRENode methodsFor:'private'!
|
|
62 |
|
|
63 |
asNFAStartingWith: startNode
|
|
64 |
| endNode |
|
|
65 |
endNode := SmaCCNode new.
|
|
66 |
endNode action: action.
|
|
67 |
nodes do:
|
|
68 |
[:each |
|
|
69 |
| componentStart |
|
|
70 |
componentStart := SmaCCNode new.
|
|
71 |
startNode addEdgeTo: componentStart.
|
|
72 |
(each asNFAStartingWith: componentStart) addEdgeTo: endNode].
|
|
73 |
^endNode
|
|
74 |
!
|
|
75 |
|
|
76 |
possibleMatchesDo: aBlock on: aStream
|
|
77 |
nodes do:
|
|
78 |
[:each |
|
|
79 |
| pos |
|
|
80 |
pos := aStream position.
|
|
81 |
each possibleMatchesDo: aBlock on: aStream.
|
|
82 |
aStream position: pos]
|
|
83 |
! !
|
|
84 |
|
|
85 |
!SmaCCOrRENode class methodsFor:'documentation'!
|
|
86 |
|
|
87 |
version
|
|
88 |
^ '$Header: /opt/data/cvs/stx/goodies/smaCC/SmaCC__SmaCCOrRENode.st,v 1.1 2006-02-09 21:16:22 vranyj1 Exp $'
|
15
|
89 |
!
|
|
90 |
|
|
91 |
version_SVN
|
|
92 |
^ '$Id$'
|
1
|
93 |
! !
|