PPListParser.st
changeset 421 7e08b31e0dae
parent 169 cba3a51b9704
equal deleted inserted replaced
420:b2f2f15cef26 421:7e08b31e0dae
    17 with: aFirstParser with: aSecondParser
    17 with: aFirstParser with: aSecondParser
    18 	^ self withAll: (Array with: aFirstParser with: aSecondParser)
    18 	^ self withAll: (Array with: aFirstParser with: aSecondParser)
    19 !
    19 !
    20 
    20 
    21 withAll: aCollection
    21 withAll: aCollection
    22 	^ self basicNew setParsers: aCollection
    22 	^ self basicNew initialize;
       
    23 		setParsers: aCollection
    23 ! !
    24 ! !
    24 
    25 
    25 !PPListParser methodsFor:'*petitanalyzer-matching'!
       
    26 
    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 
    27 
    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 
    28 
    54 !PPListParser methodsFor:'accessing'!
    29 !PPListParser methodsFor:'accessing'!
    55 
    30 
    56 children
    31 children
    57 	^ parsers
    32 	^ parsers