PPLimitedRepeatingParser.st
author sr
Thu, 05 Jul 2018 09:23:25 +0200
changeset 626 5159b1039a8f
parent 168 9fa394e40830
child 377 6112a403a52d
permissions -rw-r--r--
order
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
168
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser' }"
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
PPRepeatingParser subclass:#PPLimitedRepeatingParser
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	instanceVariableNames:'limit'
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	classVariableNames:''
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	poolDictionaries:''
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	category:'PetitParser-Parsers'
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
!PPLimitedRepeatingParser class methodsFor:'instance creation'!
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
on: aParser limit: aLimitParser
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
	^ (self on: aParser) setLimit: aLimitParser
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
! !
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
!PPLimitedRepeatingParser methodsFor:'accessing'!
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
children
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	^ Array with: parser with: limit
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
limit
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
	"Answer the parser that limits (or ends) this repetition."
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
	
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	^ limit
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
! !
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
!PPLimitedRepeatingParser methodsFor:'initialization'!
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
setLimit: aParser
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	limit := aParser
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
! !
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!PPLimitedRepeatingParser methodsFor:'private'!
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
matchesLimitOn: aStream
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
	| element position |
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
	position := aStream position.
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
	element := limit parseOn: aStream.
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
	aStream position: position.
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
	^ element isPetitFailure not
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
! !
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
!PPLimitedRepeatingParser class methodsFor:'documentation'!
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
version
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLimitedRepeatingParser.st,v 1.1 2014-03-04 14:32:55 cg Exp $'
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
!
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
version_CVS
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLimitedRepeatingParser.st,v 1.1 2014-03-04 14:32:55 cg Exp $'
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
! !
9fa394e40830 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54