islands/PPNonEmptyParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 08 Oct 2014 00:33:44 +0100
changeset 387 e2b2ccaa4de6
child 454 a9cd5ea7cc36
permissions -rw-r--r--
Commited a island parser support (MC package PetitIslands) Name: PetitIslands-JanKurs.10 Author: JanKurs Time: 06-10-2014, 11:50:57 AM UUID: 19560ad2-4899-43d5-8c69-cf7274ad4f04 Repository: http://smalltalkhub.com/mc/Moose/PetitParser/main

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