Updated to latest version from Moose repository.
Name: PetitParser-JanKurs.250
Author: JanKurs
Time: 01-10-2014, 04:44:04 AM
UUID: c46eea20-51a0-4deb-8fd5-8cb99810a8b4
Repository: http://smalltalkhub.com/mc/Moose/PetitParser/main
Name: PetitTests-JanKurs.60
Author: JanKurs
Time: 29-09-2014, 11:48:10 AM
UUID: 28fd2e65-c287-4f73-b71e-5b6bb25bebaa
Repository: http://smalltalkhub.com/mc/Moose/PetitParser/main
"{ Package: 'stx:goodies/petitparser/analyzer' }"
PPProcessor subclass:#PPSearcher
instanceVariableNames:'answer'
classVariableNames:''
poolDictionaries:''
category:'PetitAnalyzer-Core'
!
!PPSearcher methodsFor:'initialization'!
setAnswer: anObject
answer := anObject
! !
!PPSearcher methodsFor:'private'!
answer
^ answer
! !
!PPSearcher methodsFor:'public'!
execute: aParser
"Perform the search rules of the receiver on aParser. Answer the result of the search."
^ self execute: aParser initialAnswer: nil
!
execute: aParser initialAnswer: anObject
"Perform the search rules of the receiver on aParser. Inject anObject into the matches and answer the result."
| previous |
previous := context.
answer := anObject.
context := Dictionary new.
aParser allParsersDo: [ :each |
self performRulesOn: each ].
context := previous.
^ answer
! !
!PPSearcher methodsFor:'rules'!
matches: aParser do: anAnswerBlock
"Add a search expression aParser, evaluate anAnswerBlock with the matched node and the previous answer."
self addRule: (PPSearchRule searchFor: aParser thenDo: anAnswerBlock)
!
matchesAnyOf: aCollectionOfParsers do: anAnswerBlock
"Add a collection of search expressions aCollectionOfParsers, evaluate anAnswerBlock with the matched node and the previous answer."
aCollectionOfParsers
do: [ :each | self matches: each do: anAnswerBlock ]
! !
!PPSearcher class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/goodies/petitparser/analyzer/PPSearcher.st,v 1.2 2014-03-04 20:27:52 cg Exp $'
!
version_CVS
^ '$Header: /cvs/stx/stx/goodies/petitparser/analyzer/PPSearcher.st,v 1.2 2014-03-04 20:27:52 cg Exp $'
! !