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