islands/PPNonEmptyParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 24 Nov 2014 11:38:11 +0000
changeset 423 f3b99c7c1b20
parent 387 e2b2ccaa4de6
child 454 a9cd5ea7cc36
permissions -rw-r--r--
Added benchmark package to set of exported .mcz

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

PPDelegateParser subclass:#PPNonEmptyParser
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitIslands-Parsers'
!

PPNonEmptyParser comment:'I return failure, if the delegate parser did not consumed any input.'
!

!PPNonEmptyParser methodsFor:'parsing'!

parseOn: aPPContext
	| position result |
	position := aPPContext position.
	result := parser parseOn: aPPContext.
	

	(((position == aPPContext position) and: [ aPPContext atEnd not ]) and: [ result isPetitFailure not ]) ifTrue: [ 
		^ PPFailure message: 'Epsilon parse not allowed' context: aPPContext at: position
	].
	^ result
! !