# HG changeset patch # User Claus Gittinger # Date 1392647754 -3600 # Node ID 43cdafa051d5590d5cfc6888e05652c576ba6f4e # Parent d104f89293e3694140ca26687e0fc3d320e705f6 added Interval asParser e.g. ( to:) asParser parse:'a' diff -r d104f89293e3 -r 43cdafa051d5 extensions.st --- a/extensions.st Mon Feb 17 02:33:27 2014 +0100 +++ b/extensions.st Mon Feb 17 15:35:54 2014 +0100 @@ -12,44 +12,33 @@ ^ PPPluggableParser on: self ! ! +!Character methodsFor:'arithmetic'! + +-converting' +! ! + !Character methodsFor:'*petitparser-converting'! -asParser - ^ PPLiteralObjectParser on: self +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 " ! ! !Character methodsFor:'arithmetic'! -ppMinus: aCharacter - "Create a range of characters between the receiver and the argument." - - ^ PPPredicateObjectParser between: self and: aCharacter - - "Created: / 19-12-2010 / 18:13:19 / Jan Kurs " -! ! - -!Object methodsFor:'*petitparser-core-converting'! - -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." +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. @@ -66,22 +55,10 @@ "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs " ! ! -!SequenceableCollection methodsFor:'*petitparser-core-converting'! +!Interval methodsFor:'*petitparser-converting'! asParser - ^ PPSequenceParser withAll: (self collect: [ :each | each asParser ]) -! ! - -!SequenceableCollection methodsFor:'*petitparser-core-converting'! - -asPetitStream - ^ PPStream on: self -! ! - -!Interval methodsFor:'*petitparser-core-converting'! - -asParser - "Create a parser for any in a range of characters between start and stop." + "Create a range of characters between start and stop." self assert:start isCharacter. self assert:stop isCharacter. @@ -94,52 +71,97 @@ " ! ! +!Object methodsFor:'*petitparser-core-converting'! + +ition 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 " +! ! + +!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 " +! ! + +!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 " +! ! + +!PositionableStream methodsFor:'*petitparser-core-converting'! + +ection from: position to: readLimit ] +"/ ifTrue: [ super asPetitStream ] + + "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs " +! ! + +!SequenceableCollection methodsFor:'*petitparser-core-converting'! + +asParser + ^ PPSequenceParser withAll: (self collect: [ :each | each asParser ] as:Array) +! ! + +!SequenceableCollection methodsFor:'*petitparser-core-converting'! + +f +! ! + !Set methodsFor:'*petitparser-core-converting'! -asParser - ^ PPChoiceParser withAll: (self collect: [ :each | each asParser ]) +arser perform: self ! ! !Stream methodsFor:'*petitparser-core-converting'! -asPetitStream - ^ self contents asPetitStream +2-2010 / 16:47:22 / Jan Kurs " ! ! !String methodsFor:'*petitparser-core-converting'! -asParser - ^ PPLiteralSequenceParser on: self +ream + ^ string asPetitStream ! ! !Symbol methodsFor:'*petitparser-core-converting'! -asParser - ^ PPPredicateObjectParser perform: self +PPEpsilonParser new ! ! !Symbol methodsFor:'Compatibility-Squeak'! -value:anObject - ^ anObject perform: self. - - "Created: / 18-12-2010 / 16:47:22 / Jan Kurs " +ion_CVS + ^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.7 2014-02-17 14:35:54 cg Exp $' ! ! !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.6 2014-02-17 01:33:27 cg Exp $' ! ! +