PPPluggableParser.st
author Claus Gittinger <cg@exept.de>
Fri, 16 Mar 2012 10:02:16 +0100
changeset 7 019b26bd21a8
parent 4 90de244a7fa2
child 55 e84f763c3447
permissions -rw-r--r--
*** empty log message ***

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

PPParser subclass:#PPPluggableParser
	instanceVariableNames:'block'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitParser-Parsers'
!

PPPluggableParser comment:'A pluggable parser that passes the parser stream into a block. This enables users to perform manual parsing or to embed other parser frameworks into PetitParser.
Instance Variables:
	block   <BlockClosure>  The pluggable one-argument block.
'
!


!PPPluggableParser class methodsFor:'instance creation'!

on: aBlock
	^ self new initializeOn: aBlock
! !

!PPPluggableParser methodsFor:'accessing'!

block
	"Answer the pluggable block."

	^ block
! !

!PPPluggableParser methodsFor:'initialization'!

initializeOn: aBlock
	block := aBlock
! !

!PPPluggableParser methodsFor:'parsing'!

parseOn: aStream
	| position result |
	position := aStream position.
	result := block value: aStream.
	result isPetitFailure
		ifTrue: [ aStream position: position ].
	^ result
! !

!PPPluggableParser class methodsFor:'documentation'!

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