PPActionParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 05 May 2012 00:00:04 +0200
changeset 16 3b8de4bf5696
parent 4 90de244a7fa2
child 21 b93d472b6e8c
permissions -rw-r--r--
Checkin from browser

"{ 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 $'
! !