islands/PPNonEmptyParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 26 Oct 2014 22:08:41 +0000
changeset 395 c6c712fc15b7
parent 387 e2b2ccaa4de6
child 454 a9cd5ea7cc36
permissions -rw-r--r--
Portability fix in PPCompiler>>cleanGeneratedMethods: Use more portable coding.

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