PPPossessiveRepeatingParser.st
author sr
Wed, 04 Jul 2018 15:30:19 +0200
changeset 611 38338f2de417
parent 175 3affa13c4553
child 377 6112a403a52d
permissions -rw-r--r--
build order was wrong
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
175
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser' }"
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
PPRepeatingParser subclass:#PPPossessiveRepeatingParser
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	instanceVariableNames:''
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	classVariableNames:''
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	poolDictionaries:''
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	category:'PetitParser-Parsers'
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
!PPPossessiveRepeatingParser methodsFor:'parsing'!
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
parseOn: aStream
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
	| start element elements |
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	start := aStream position.
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	elements := OrderedCollection new.
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	[ elements size < min ] whileTrue: [
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
		(element := parser parseOn: aStream) isPetitFailure ifTrue: [
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
			aStream position: start.
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
			^ element ].
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
		elements addLast: element ].
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	[ elements size < max ] whileTrue: [
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
	 	(element := parser parseOn: aStream) isPetitFailure
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
			ifTrue: [ ^ elements asArray ].
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
		elements addLast: element ].
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	^ elements asArray
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
! !
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
!PPPossessiveRepeatingParser class methodsFor:'documentation'!
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
version
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPPossessiveRepeatingParser.st,v 1.1 2014-03-04 14:33:19 cg Exp $'
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
!
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
version_CVS
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPPossessiveRepeatingParser.st,v 1.1 2014-03-04 14:33:19 cg Exp $'
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
! !
3affa13c4553 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38