PPActionParser.st
author Claus Gittinger <cg@exept.de>
Fri, 13 Jan 2012 12:22:50 +0100
changeset 4 90de244a7fa2
parent 0 739fe9b7253e
child 21 b93d472b6e8c
permissions -rw-r--r--
move to package

"{ Package: 'stx:goodies/petitparser' }"

PPDelegateParser subclass:#PPActionParser
	instanceVariableNames:'block'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitParser-Parsers'
!

PPActionParser comment:'A parser that performs an action block with the successful parse result of the delegate.
Instance Variables:
	block   <BlockClosure>  The action block to be executed.
'
!


!PPActionParser class methodsFor:'instance creation'!

on: aParser block: aBlock
	^ (self on: aParser) setBlock: aBlock
! !

!PPActionParser methodsFor:'accessing'!

block
	"Answer the action block of the receiver."

	^ block
! !

!PPActionParser methodsFor:'initialization'!

setBlock: aBlock
	block := aBlock
! !

!PPActionParser methodsFor:'parsing'!

parseOn: aStream
	| element |
	^ (element := parser parseOn: aStream) isPetitFailure
		ifFalse: [ block value: element ]
		ifTrue: [ element ]
! !

!PPActionParser class methodsFor:'documentation'!

version_SVN
    ^ '$Id: PPActionParser.st,v 1.2 2012-01-13 11:22:50 cg Exp $'
! !