extensions.st
changeset 421 7e08b31e0dae
parent 408 ead04d661728
equal deleted inserted replaced
420:b2f2f15cef26 421:7e08b31e0dae
    54 ! !
    54 ! !
    55 
    55 
    56 !Interval methodsFor:'*petitparser-core-converting'!
    56 !Interval methodsFor:'*petitparser-core-converting'!
    57 
    57 
    58 asParser    
    58 asParser    
    59         "Create a range of characters between start and stop."
    59 	"Create a range of characters between start and stop."
    60 
    60 
    61     self assert:start isCharacter.
    61     self assert:start isCharacter.
    62     self assert:stop isCharacter.
    62     self assert:stop isCharacter.
    63     self assert:step == 1.
    63     self assert:step == 1.
    64     ^ PPPredicateObjectParser between: start and: stop
    64     ^ PPPredicateObjectParser between: start and: stop
    65 
    65 
    66     "
    66     "
    67                 ($a to: $f) asParser parse: 'a'
    67 		($a to: $f) asParser parse: 'a'
    68                 ($a to: $f) asParser parse: 'g'
    68 		($a to: $f) asParser parse: 'g'
    69     "
    69     "
    70 
       
    71     "Modified (comment): / 01-11-2014 / 13:13:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    72 ! !
    70 ! !
    73 
    71 
    74 !Object methodsFor:'*petitparser-core-converting'!
    72 !Object methodsFor:'*petitparser-core-converting'!
    75 
    73 
    76 asParser
    74 asParser
    94 !PositionableStream methodsFor:'*petitparser-core-converting'!
    92 !PositionableStream methodsFor:'*petitparser-core-converting'!
    95 
    93 
    96 asPetitStream
    94 asPetitStream
    97 	"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."
    95 	"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."
    98 
    96 
       
    97 "
       
    98 	Disabled until we agree on some way how to optimize this
       
    99 
    99 	^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
   100 	^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
   100 		ifFalse: [ PPStream on: collection from: ( position + 1 ) to: readLimit ]
   101 		ifFalse: [ PPStream on: collection from: ( position + 1 ) to: readLimit ]
   101       ifTrue: [ super asPetitStream ]
   102       ifTrue: [ super asPetitStream ]
       
   103 "
       
   104 	^ super asPetitStream
   102 ! !
   105 ! !
   103 
   106 
   104 !PositionableStream methodsFor:'*petitparser-core'!
   107 !PositionableStream methodsFor:'*petitparser-core'!
   105 
   108 
   106 peekTwice
   109 peekTwice