islands/PPNonEmptyParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 20 May 2015 16:47:52 +0100
changeset 463 d4014e0a47a0
parent 454 a9cd5ea7cc36
child 504 0fb1f0799fc1
permissions -rw-r--r--
Small improvement in inlining: inline child of an action node.

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

"{ NameSpace: Smalltalk }"

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