islands/PPNonEmptyParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 29 Aug 2015 07:56:14 +0100
changeset 534 a949c4fe44df
parent 504 0fb1f0799fc1
permissions -rw-r--r--
PPCConfiguration refactoring: [6/10]: use #runPass: instead of self-sends. ...in PPCConfiguration>>invokePhases. This is a preparation for removing #invokePhases completely and configuring the compilation via list of phases.

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

!PPNonEmptyParser class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !