--- a/extensions.st Mon Feb 17 15:35:54 2014 +0100
+++ b/extensions.st Mon Feb 17 16:08:10 2014 +0100
@@ -12,47 +12,20 @@
^ PPPluggableParser on: self
! !
-!Character methodsFor:'arithmetic'!
-
--converting'
-! !
-
!Character methodsFor:'*petitparser-converting'!
-e 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."
-
- "DUNNO WHY, but on: collection from: position to: last set the start to position -1"
- self breakPoint: #petitparser.
-
- ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
- ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ]
- ifTrue: [ super asPetitStream ]
-
-
-"/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
-"/ ifFalse: [ PPStream on: collection from: position to: readLimit ]
-"/ ifTrue: [ super asPetitStream ]
-
- "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>"
+asParser
+ ^ PPLiteralObjectParser on: self
! !
!Character methodsFor:'arithmetic'!
-different internal representation. In these cases just use the super implementation that is inefficient but should work in all cases."
-
- "DUNNO WHY, but on: collection from: position to: last set the start to position -1"
- self breakPoint: #petitparser.
+ppMinus: aCharacter
+ "Create a range of characters between the receiver and the argument."
- ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
- ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ]
- ifTrue: [ super asPetitStream ]
-
+ ^ PPPredicateObjectParser between: self and: aCharacter
-"/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
-"/ ifFalse: [ PPStream on: collection from: position to: readLimit ]
-"/ ifTrue: [ super asPetitStream ]
-
- "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>"
+ "Created: / 19-12-2010 / 18:13:19 / Jan Kurs <kurs.jan@post.cz>"
! !
!Interval methodsFor:'*petitparser-converting'!
@@ -73,7 +46,31 @@
!Object methodsFor:'*petitparser-core-converting'!
-ition isNil or: [ readLimit isNil ] ])
+asParser
+ ^ PPPredicateObjectParser expect: self
+! !
+
+!Object methodsFor:'*petitparser-core-testing'!
+
+isPetitFailure
+ ^ false
+! !
+
+!Object methodsFor:'*petitparser-core-testing'!
+
+isPetitParser
+ ^ false
+! !
+
+!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."
+
+ "DUNNO WHY, but on: collection from: position to: last set the start to position -1"
+ self breakPoint: #petitparser.
+
+ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ]
ifTrue: [ super asPetitStream ]
@@ -85,83 +82,80 @@
"Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>"
! !
-!Object methodsFor:'*petitparser-core-testing'!
-
-adLimit ]
- ifTrue: [ super asPetitStream ]
-
-
-"/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
-"/ ifFalse: [ PPStream on: collection from: position to: readLimit ]
-"/ ifTrue: [ super asPetitStream ]
-
- "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>"
-! !
-
-!Object methodsFor:'*petitparser-core-testing'!
-
-: [ position isNil or: [ readLimit isNil ] ])
-"/ ifFalse: [ PPStream on: collection from: position to: readLimit ]
-"/ ifTrue: [ super asPetitStream ]
-
- "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>"
-! !
-
-!PositionableStream methodsFor:'*petitparser-core-converting'!
-
-ection from: position to: readLimit ]
-"/ ifTrue: [ super asPetitStream ]
-
- "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>"
-! !
-
!SequenceableCollection methodsFor:'*petitparser-core-converting'!
asParser
- ^ PPSequenceParser withAll: (self collect: [ :each | each asParser ] as:Array)
+ ^ PPSequenceParser withAll: (self collect: [ :each | each asParser ])
! !
!SequenceableCollection methodsFor:'*petitparser-core-converting'!
-f
+asPetitStream
+ ^ PPStream on: self
+! !
+
+!Interval methodsFor:'*petitparser-core-converting'!
+
+asParser
+ "Create a parser for any in a range of characters between start and stop."
+
+ self assert:start isCharacter.
+ self assert:stop isCharacter.
+ self assert:step == 1.
+ ^ PPPredicateObjectParser between: start and: stop
+
+ "
+ ($a to:$f) asParser parse:'a'
+ ($a to:$f) asParser parse:'g'
+ "
! !
!Set methodsFor:'*petitparser-core-converting'!
-arser perform: self
+asParser
+ ^ PPChoiceParser withAll: (self collect: [ :each | each asParser ])
! !
!Stream methodsFor:'*petitparser-core-converting'!
-2-2010 / 16:47:22 / Jan Kurs <kurs.jan@post.cz>"
+asPetitStream
+ ^ self contents asPetitStream
! !
!String methodsFor:'*petitparser-core-converting'!
-ream
- ^ string asPetitStream
+asParser
+ ^ PPLiteralSequenceParser on: self
! !
!Symbol methodsFor:'*petitparser-core-converting'!
-PPEpsilonParser new
+asParser
+ ^ PPPredicateObjectParser perform: self
! !
!Symbol methodsFor:'Compatibility-Squeak'!
-ion_CVS
- ^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.7 2014-02-17 14:35:54 cg Exp $'
+value:anObject
+ ^ anObject perform: self.
+
+ "Created: / 18-12-2010 / 16:47:22 / Jan Kurs <kurs.jan@post.cz>"
! !
!Text methodsFor:'*petitparser-core'!
+asPetitStream
+ ^ string asPetitStream
! !
!UndefinedObject methodsFor:'*petitparser-converting'!
+asParser
+ ^ PPEpsilonParser new
! !
!stx_goodies_petitparser class methodsFor:'documentation'!
+extensionsVersion_CVS
+ ^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.8 2014-02-17 15:08:10 cg Exp $'
! !
-