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

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