--- a/extensions.st Sat Nov 01 00:34:30 2014 +0000
+++ b/extensions.st Mon Nov 03 09:10:56 2014 +0000
@@ -38,16 +38,35 @@
^ PPChoiceParser withAll: (self collect: [ :each | each asParser ])
! !
+!Collection methodsFor:'*petitparser-converting'!
+
+asParser
+ "Create a range of characters between start and stop."
+
+ (self allSatisfy: [ :e | e isCharacter ]) ifTrue: [
+ | charSet |
+ charSet := PPCharSetPredicate on: [ :char | self includes: char ] .
+ ^ PPPredicateObjectParser on: charSet message: 'One of these charactes expected: ', self printString.
+ ].
+
+
+ ^ super asParser
+ "
+ ($a to:$f) asParser parse:'a'
+ ($a to:$f) asParser parse:'g'
+ "
+! !
+
!Collection methodsFor:'*petitparser-core-converting'!
asSequenceParser
^ PPSequenceParser withAll: (self collect: [ :each | each asParser ])
! !
-!Interval methodsFor:'*petitparser-converting'!
+!Interval methodsFor:'*petitparser-core-converting'!
-asParser
- "Create a range of characters between start and stop."
+asParser
+ "Create a range of characters between start and stop."
self assert:start isCharacter.
self assert:stop isCharacter.
@@ -55,9 +74,11 @@
^ PPPredicateObjectParser between: start and: stop
"
- ($a to:$f) asParser parse:'a'
- ($a to:$f) asParser parse:'g'
+ ($a to: $f) asParser parse: 'a'
+ ($a to: $f) asParser parse: 'g'
"
+
+ "Modified (comment): / 01-11-2014 / 13:13:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Object methodsFor:'*petitparser-core-converting'!
@@ -83,14 +104,11 @@
!PositionableStream methodsFor:'*petitparser-core-converting'!
asPetitStream
- "Some of my subclasses do not use the instance-variables collection, position and readLimit but instead have a completely different internal representation. In these cases just use the super implementation that is inefficient but should work in all cases."
+ "Some of my subclasses do not use the instance-variables collection, position and readLimit but instead have a completely different internal representation. In these cases just use the super implementation that is inefficient but should work in all cases."
- ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
- ifFalse: [ PPStream on: collection from: ( position + 1 ) to: readLimit ]
- ifTrue: [ super asPetitStream ]
-
- "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>"
- "Modified: / 04-10-2014 / 23:27:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
+ ifFalse: [ PPStream on: collection from: ( position + 1 ) to: readLimit ]
+ ifTrue: [ super asPetitStream ]
! !
!PositionableStream methodsFor:'*petitparser-core'!
@@ -109,12 +127,6 @@
!SequenceableCollection methodsFor:'*petitparser-core-converting'!
-asParser
- ^ PPSequenceParser withAll: (self collect: [ :each | each asParser ])
-! !
-
-!SequenceableCollection methodsFor:'*petitparser-core-converting'!
-
asPetitStream
^ PPStream on: self
! !