PPLazyRepeatingParser.st
author sr
Wed, 04 Jul 2018 15:23:55 +0200
changeset 607 019302eb9dd9
parent 167 f7d5e10c3fe8
child 377 6112a403a52d
permissions -rw-r--r--
build order was wrong

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

PPLimitedRepeatingParser subclass:#PPLazyRepeatingParser
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitParser-Parsers'
!


!PPLazyRepeatingParser methodsFor:'parsing'!

parseOn: aStream
	| start element elements |
	start := aStream position.
	elements := OrderedCollection new.
	[ elements size < min ] whileTrue: [
		(element := parser parseOn: aStream) isPetitFailure ifTrue: [
			aStream position: start.
			^ element ].
		elements addLast: element ].
	[ self matchesLimitOn: aStream ] whileFalse: [
		elements size < max ifFalse: [
			aStream position: start.
			^ PPFailure message: 'overflow' at: start ].
		element := parser parseOn: aStream.
		element isPetitFailure ifTrue: [
			aStream position: start.
			^ element ].
		elements addLast: element ].
	^ elements asArray
! !

!PPLazyRepeatingParser class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLazyRepeatingParser.st,v 1.1 2014-03-04 14:32:47 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLazyRepeatingParser.st,v 1.1 2014-03-04 14:32:47 cg Exp $'
! !