4
|
1 |
"{ Package: 'stx:goodies/petitparser' }"
|
0
|
2 |
|
638
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
0
|
5 |
PPParser subclass:#PPListParser
|
|
6 |
instanceVariableNames:'parsers'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'PetitParser-Parsers'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!PPListParser class methodsFor:'instance creation'!
|
|
14 |
|
|
15 |
with: aParser
|
|
16 |
^ self withAll: (Array with: aParser)
|
|
17 |
!
|
|
18 |
|
|
19 |
with: aFirstParser with: aSecondParser
|
|
20 |
^ self withAll: (Array with: aFirstParser with: aSecondParser)
|
|
21 |
!
|
|
22 |
|
|
23 |
withAll: aCollection
|
|
24 |
^ self basicNew setParsers: aCollection
|
|
25 |
! !
|
|
26 |
|
169
|
27 |
!PPListParser methodsFor:'*petitanalyzer-matching'!
|
|
28 |
|
|
29 |
copyInContext: aDictionary seen: aSeenDictionary
|
|
30 |
| copy copies |
|
|
31 |
aSeenDictionary at: self ifPresent: [ :value | ^ value ].
|
|
32 |
copy := aSeenDictionary at: self put: self copy.
|
|
33 |
copies := OrderedCollection new.
|
|
34 |
parsers do: [ :each |
|
|
35 |
| result |
|
|
36 |
result := each
|
|
37 |
copyInContext: aDictionary
|
|
38 |
seen: aSeenDictionary.
|
|
39 |
result isCollection
|
|
40 |
ifTrue: [ copies addAll: result ]
|
|
41 |
ifFalse: [ copies add: result ] ].
|
|
42 |
^ copy
|
|
43 |
setParsers: copies;
|
|
44 |
yourself
|
|
45 |
! !
|
|
46 |
|
|
47 |
!PPListParser methodsFor:'*petitanalyzer-transforming'!
|
|
48 |
|
|
49 |
replace: aParser with: anotherParser
|
|
50 |
super replace: aParser with: anotherParser.
|
|
51 |
parsers keysAndValuesDo: [ :index :parser |
|
|
52 |
parser == aParser
|
|
53 |
ifTrue: [ parsers at: index put: anotherParser ] ]
|
|
54 |
! !
|
|
55 |
|
0
|
56 |
!PPListParser methodsFor:'accessing'!
|
|
57 |
|
|
58 |
children
|
|
59 |
^ parsers
|
|
60 |
! !
|
|
61 |
|
|
62 |
!PPListParser methodsFor:'copying'!
|
|
63 |
|
|
64 |
copyWith: aParser
|
|
65 |
^ self species withAll: (parsers copyWith: aParser)
|
638
|
66 |
! !
|
|
67 |
|
|
68 |
!PPListParser methodsFor:'copying-private'!
|
0
|
69 |
|
|
70 |
postCopy
|
|
71 |
super postCopy.
|
|
72 |
parsers := parsers copy
|
|
73 |
! !
|
|
74 |
|
|
75 |
!PPListParser methodsFor:'initialization'!
|
|
76 |
|
|
77 |
initialize
|
|
78 |
super initialize.
|
|
79 |
self setParsers: #()
|
|
80 |
!
|
|
81 |
|
|
82 |
setParsers: aCollection
|
|
83 |
parsers := aCollection asArray
|
|
84 |
! !
|
|
85 |
|
|
86 |
!PPListParser class methodsFor:'documentation'!
|
|
87 |
|
56
|
88 |
version
|
638
|
89 |
^ '$Header$'
|
56
|
90 |
!
|
|
91 |
|
|
92 |
version_CVS
|
638
|
93 |
^ '$Header$'
|
56
|
94 |
!
|
|
95 |
|
0
|
96 |
version_SVN
|
638
|
97 |
^ '$Id$'
|
0
|
98 |
! !
|
169
|
99 |
|