4
|
1 |
"{ Package: 'stx:goodies/petitparser' }"!
|
0
|
2 |
|
|
3 |
!Block methodsFor:'*petitparser-core-converting'!
|
|
4 |
|
|
5 |
asParser
|
|
6 |
^ PPPluggableParser on: self
|
|
7 |
! !
|
3
|
8 |
|
0
|
9 |
!BlockContext methodsFor:'*petitparser-core-converting'!
|
|
10 |
|
|
11 |
asParser
|
|
12 |
^ PPPluggableParser on: self
|
|
13 |
! !
|
3
|
14 |
|
0
|
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:
|
58
|
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."
|
0
|
24 |
|
|
25 |
aMagnitude isCharacter ifTrue:[
|
58
|
26 |
^ asciivalue - aMagnitude asInteger
|
0
|
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 |
! !
|
3
|
38 |
|
0
|
39 |
!Character methodsFor:'*petitparser-converting'!
|
|
40 |
|
|
41 |
asParser
|
|
42 |
^ PPLiteralObjectParser on: self
|
|
43 |
! !
|
3
|
44 |
|
0
|
45 |
!Character methodsFor:'arithmetic'!
|
|
46 |
|
|
47 |
ppMinus: aCharacter
|
|
48 |
"Create a range of characters between the receiver and the argument."
|
58
|
49 |
|
0
|
50 |
^ PPPredicateObjectParser between: self and: aCharacter
|
|
51 |
|
|
52 |
"Created: / 19-12-2010 / 18:13:19 / Jan Kurs <kurs.jan@post.cz>"
|
|
53 |
! !
|
3
|
54 |
|
0
|
55 |
!Object methodsFor:'*petitparser-core-converting'!
|
|
56 |
|
|
57 |
asParser
|
|
58 |
^ PPPredicateObjectParser expect: self
|
|
59 |
! !
|
3
|
60 |
|
0
|
61 |
!Object methodsFor:'*petitparser-core-testing'!
|
|
62 |
|
|
63 |
isPetitFailure
|
|
64 |
^ false
|
|
65 |
! !
|
3
|
66 |
|
0
|
67 |
!Object methodsFor:'*petitparser-core-testing'!
|
|
68 |
|
|
69 |
isPetitParser
|
|
70 |
^ false
|
|
71 |
! !
|
3
|
72 |
|
0
|
73 |
!PositionableStream methodsFor:'*petitparser-core-converting'!
|
|
74 |
|
|
75 |
asPetitStream
|
58
|
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."
|
0
|
77 |
|
58
|
78 |
"DUNNO WHY, but on: collection from: position to: last set the start to position -1"
|
|
79 |
self breakPoint: #petitparser.
|
0
|
80 |
|
58
|
81 |
^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
|
|
82 |
ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ]
|
|
83 |
ifTrue: [ super asPetitStream ]
|
0
|
84 |
|
|
85 |
|
|
86 |
"/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ])
|
|
87 |
"/ ifFalse: [ PPStream on: collection from: position to: readLimit ]
|
|
88 |
"/ ifTrue: [ super asPetitStream ]
|
|
89 |
|
|
90 |
"Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>"
|
|
91 |
! !
|
3
|
92 |
|
0
|
93 |
!SequenceableCollection methodsFor:'*petitparser-core-converting'!
|
|
94 |
|
|
95 |
asParser
|
|
96 |
^ PPSequenceParser withAll: (self collect: [ :each | each asParser ])
|
|
97 |
! !
|
3
|
98 |
|
0
|
99 |
!SequenceableCollection methodsFor:'*petitparser-core-converting'!
|
|
100 |
|
|
101 |
asPetitStream
|
|
102 |
^ PPStream on: self
|
|
103 |
! !
|
3
|
104 |
|
0
|
105 |
!Set methodsFor:'*petitparser-core-converting'!
|
|
106 |
|
|
107 |
asParser
|
|
108 |
^ PPChoiceParser withAll: (self collect: [ :each | each asParser ])
|
|
109 |
! !
|
3
|
110 |
|
0
|
111 |
!Stream methodsFor:'*petitparser-core-converting'!
|
|
112 |
|
|
113 |
asPetitStream
|
|
114 |
^ self contents asPetitStream
|
|
115 |
! !
|
3
|
116 |
|
0
|
117 |
!String methodsFor:'*petitparser-core-converting'!
|
|
118 |
|
|
119 |
asParser
|
|
120 |
^ PPLiteralSequenceParser on: self
|
|
121 |
! !
|
3
|
122 |
|
0
|
123 |
!Symbol methodsFor:'*petitparser-core-converting'!
|
|
124 |
|
|
125 |
asParser
|
|
126 |
^ PPPredicateObjectParser perform: self
|
|
127 |
! !
|
3
|
128 |
|
0
|
129 |
!Symbol methodsFor:'Compatibility-Squeak'!
|
|
130 |
|
|
131 |
value:anObject
|
|
132 |
^ anObject perform: self.
|
|
133 |
|
|
134 |
"Created: / 18-12-2010 / 16:47:22 / Jan Kurs <kurs.jan@post.cz>"
|
|
135 |
! !
|
3
|
136 |
|
0
|
137 |
!Text methodsFor:'*petitparser-core'!
|
|
138 |
|
|
139 |
asPetitStream
|
|
140 |
^ string asPetitStream
|
|
141 |
! !
|
3
|
142 |
|
0
|
143 |
!UndefinedObject methodsFor:'*petitparser-converting'!
|
|
144 |
|
|
145 |
asParser
|
|
146 |
^ PPEpsilonParser new
|
|
147 |
! !
|
3
|
148 |
|
4
|
149 |
!stx_goodies_petitparser class methodsFor:'documentation'!
|
3
|
150 |
|
|
151 |
extensionsVersion_CVS
|
58
|
152 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.4 2012-05-04 22:14:41 vrany Exp $'
|
|
153 |
! ! |