PPLazyRepeatingParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 23 Nov 2015 11:14:30 +0100
changeset 551 00ebb1b85f53
parent 377 6112a403a52d
permissions -rw-r--r--
Fixed CI scripts on Windows For an unknown reason, unzip on Windows reports status code 50 (presumably "the disk is (or was) full during extraction.") even if there's plenty of space. To workaround this, simply ignore status code 50 on Windows. Sigh.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
167
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser' }"
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
PPLimitedRepeatingParser subclass:#PPLazyRepeatingParser
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	instanceVariableNames:''
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	classVariableNames:''
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	poolDictionaries:''
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	category:'PetitParser-Parsers'
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
!PPLazyRepeatingParser methodsFor:'parsing'!
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
377
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    13
parseOn: aPPContext
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    14
	| memento element elements |
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    15
	memento := aPPContext remember.
167
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	elements := OrderedCollection new.
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	[ elements size < min ] whileTrue: [
377
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    18
		(element := parser parseOn: aPPContext) isPetitFailure ifTrue: [
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    19
			aPPContext restore: memento.
167
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
			^ element ].
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
		elements addLast: element ].
377
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    22
	[ self matchesLimitOn: aPPContext ] whileFalse: [
167
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
		elements size < max ifFalse: [
377
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    24
			aPPContext restore: memento.
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    25
			^ PPFailure message: 'overflow' context: aPPContext at: memento position ].
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    26
		element := parser parseOn: aPPContext.
167
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
		element isPetitFailure ifTrue: [
377
6112a403a52d Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
    28
			aPPContext restore: memento.
167
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
			^ element ].
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
		elements addLast: element ].
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
	^ elements asArray
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
! !
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
!PPLazyRepeatingParser class methodsFor:'documentation'!
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
version
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLazyRepeatingParser.st,v 1.1 2014-03-04 14:32:47 cg Exp $'
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
version_CVS
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLazyRepeatingParser.st,v 1.1 2014-03-04 14:32:47 cg Exp $'
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
! !
f7d5e10c3fe8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43