Portability fixes in PPPredicateTest>>charactersDo: / parsedCharacterSet:
* It is my understanding that charactersDo: should iterate over all signle byte
characters. If so, the method suffer from off-by-one error, it should generate
characters with code points 0..255. 256 is actually a two-byte character.
Method changed accordingly.
* Use Character>>asString instead of `String>>with:` which is safer
w.r.t. multi-byte characters. Under Smalltalk/X, String may contain only
signle byte characters.
"{ Package: 'stx:goodies/petitparser' }"
PPLimitedRepeatingParser subclass:#PPGreedyRepeatingParser
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'PetitParser-Parsers'
!
!PPGreedyRepeatingParser methodsFor:'parsing'!
parseOn: aPPContext
| memento element elements positions |
memento := aPPContext remember.
elements := OrderedCollection new.
[ elements size < min ] whileTrue: [
(element := parser parseOn: aPPContext) isPetitFailure ifTrue: [
aPPContext restore: memento.
^ element ].
elements addLast: element ].
positions := OrderedCollection with: aPPContext remember.
[ elements size < max and: [ (element := parser parseOn: aPPContext) isPetitFailure not ] ] whileTrue: [
elements addLast: element.
positions addLast: aPPContext remember ].
[ positions isEmpty ] whileFalse: [
aPPContext restore: positions last.
element := limit parseOn: aPPContext.
element isPetitFailure ifFalse: [
aPPContext restore: positions last.
^ elements asArray ].
elements isEmpty ifTrue: [
aPPContext restore: memento.
^ element ].
elements removeLast.
positions removeLast ].
aPPContext restore: memento.
^ PPFailure message: 'overflow' context: aPPContext at: memento position
! !
!PPGreedyRepeatingParser class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPGreedyRepeatingParser.st,v 1.1 2014-03-04 14:32:42 cg Exp $'
!
version_CVS
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPGreedyRepeatingParser.st,v 1.1 2014-03-04 14:32:42 cg Exp $'
!
version_HG
^ '$Changeset: <not expanded> $'
! !