islands/PPNonEmptyParser.st
changeset 387 e2b2ccaa4de6
child 454 a9cd5ea7cc36
equal deleted inserted replaced
386:a409905f7f2d 387:e2b2ccaa4de6
       
     1 "{ Package: 'stx:goodies/petitparser/islands' }"
       
     2 
       
     3 PPDelegateParser subclass:#PPNonEmptyParser
       
     4 	instanceVariableNames:''
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitIslands-Parsers'
       
     8 !
       
     9 
       
    10 PPNonEmptyParser comment:'I return failure, if the delegate parser did not consumed any input.'
       
    11 !
       
    12 
       
    13 !PPNonEmptyParser methodsFor:'parsing'!
       
    14 
       
    15 parseOn: aPPContext
       
    16 	| position result |
       
    17 	position := aPPContext position.
       
    18 	result := parser parseOn: aPPContext.
       
    19 	
       
    20 
       
    21 	(((position == aPPContext position) and: [ aPPContext atEnd not ]) and: [ result isPetitFailure not ]) ifTrue: [ 
       
    22 		^ PPFailure message: 'Epsilon parse not allowed' context: aPPContext at: position
       
    23 	].
       
    24 	^ result
       
    25 ! !
       
    26