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