extensions.st
changeset 150 24e8d10ff041
parent 58 4af6ce1837b2
child 152 d104f89293e3
equal deleted inserted replaced
149:41efe16c9c70 150:24e8d10ff041
    10 
    10 
    11 asParser
    11 asParser
    12 	^ PPPluggableParser on: self
    12 	^ PPPluggableParser on: self
    13 ! !
    13 ! !
    14 
    14 
    15 !Character methodsFor:'arithmetic'!
       
    16 
       
    17 - aMagnitude
       
    18     "Return the Character that is <aMagnitude> lower than the receiver.
       
    19      Wrap if the resulting value is not a legal Character value. (JS)
       
    20      claus:
       
    21         modified to return the difference as integer, if the argument
       
    22         is another character. If the argument is a number, a character is
       
    23         returned."
       
    24 
       
    25     aMagnitude isCharacter ifTrue:[
       
    26         ^ asciivalue - aMagnitude asInteger
       
    27     ].
       
    28     ^ Character codePoint:((asciivalue - aMagnitude asInteger) \\ 16r3FFFFFFF)
       
    29 
       
    30     "
       
    31      $z - $a
       
    32      $d - 3
       
    33     "
       
    34 
       
    35     "Modified: / 27-06-1996 / 12:35:34 / cg"
       
    36     "Modified: / 19-12-2010 / 18:36:56 / Jan Kurs <kurs.jan@post.cz>"
       
    37 ! !
       
    38 
       
    39 !Character methodsFor:'*petitparser-converting'!
    15 !Character methodsFor:'*petitparser-converting'!
    40 
    16 
    41 asParser
    17 asParser
    42 	^ PPLiteralObjectParser on: self
    18 	^ PPLiteralObjectParser on: self
    43 ! !
    19 ! !
    44 
    20 
    45 !Character methodsFor:'arithmetic'!
    21 !Character methodsFor:'arithmetic'!
    46 
    22 
    47 ppMinus: aCharacter
    23 ppMinus: aCharacter
    48     "Create a range of characters between the receiver and the argument."
    24     "Create a range of characters between the receiver and the argument."
    49     
    25 
    50     ^ PPPredicateObjectParser between: self and: aCharacter
    26     ^ PPPredicateObjectParser between: self and: aCharacter
    51 
    27 
    52     "Created: / 19-12-2010 / 18:13:19 / Jan Kurs <kurs.jan@post.cz>"
    28     "Created: / 19-12-2010 / 18:13:19 / Jan Kurs <kurs.jan@post.cz>"
    53 ! !
    29 ! !
    54 
    30 
    71 ! !
    47 ! !
    72 
    48 
    73 !PositionableStream methodsFor:'*petitparser-core-converting'!
    49 !PositionableStream methodsFor:'*petitparser-core-converting'!
    74 
    50 
    75 asPetitStream
    51 asPetitStream
    76         "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."
    52 	"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."
    77 
    53 
    78         "DUNNO WHY, but on: collection from: position to: last set the start to position -1"
    54 	"DUNNO WHY, but on: collection from: position to: last set the start to position -1"
    79         self breakPoint: #petitparser.
    55 	self breakPoint: #petitparser.
    80 
    56 
    81         ^ (collection isNil or: [ position  isNil or: [ readLimit isNil ] ])
    57 	^ (collection isNil or: [ position  isNil or: [ readLimit isNil ] ])
    82                 ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ]
    58 		ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ]
    83                 ifTrue: [ super asPetitStream ]
    59 		ifTrue: [ super asPetitStream ]
    84 
    60 
    85 
    61 
    86 "/        ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
    62 "/        ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
    87 "/                ifFalse: [ PPStream on: collection from: position to: readLimit ]
    63 "/                ifFalse: [ PPStream on: collection from: position to: readLimit ]
    88 "/                ifTrue: [ super asPetitStream ]
    64 "/                ifTrue: [ super asPetitStream ]
   147 ! !
   123 ! !
   148 
   124 
   149 !stx_goodies_petitparser class methodsFor:'documentation'!
   125 !stx_goodies_petitparser class methodsFor:'documentation'!
   150 
   126 
   151 extensionsVersion_CVS
   127 extensionsVersion_CVS
   152     ^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.4 2012-05-04 22:14:41 vrany Exp $'
   128     ^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.5 2014-02-17 01:30:49 cg Exp $'
   153 ! !
   129 ! !