10 |
10 |
11 asParser |
11 asParser |
12 ^ PPPluggableParser on: self |
12 ^ PPPluggableParser on: self |
13 ! ! |
13 ! ! |
14 |
14 |
15 !Character methodsFor:'arithmetic'! |
|
16 |
|
17 -converting' |
|
18 ! ! |
|
19 |
|
20 !Character methodsFor:'*petitparser-converting'! |
15 !Character methodsFor:'*petitparser-converting'! |
21 |
16 |
22 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." |
17 asParser |
23 |
18 ^ PPLiteralObjectParser on: self |
24 "DUNNO WHY, but on: collection from: position to: last set the start to position -1" |
|
25 self breakPoint: #petitparser. |
|
26 |
|
27 ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
|
28 ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ] |
|
29 ifTrue: [ super asPetitStream ] |
|
30 |
|
31 |
|
32 "/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
|
33 "/ ifFalse: [ PPStream on: collection from: position to: readLimit ] |
|
34 "/ ifTrue: [ super asPetitStream ] |
|
35 |
|
36 "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>" |
|
37 ! ! |
19 ! ! |
38 |
20 |
39 !Character methodsFor:'arithmetic'! |
21 !Character methodsFor:'arithmetic'! |
40 |
22 |
41 different internal representation. In these cases just use the super implementation that is inefficient but should work in all cases." |
23 ppMinus: aCharacter |
|
24 "Create a range of characters between the receiver and the argument." |
42 |
25 |
43 "DUNNO WHY, but on: collection from: position to: last set the start to position -1" |
26 ^ PPPredicateObjectParser between: self and: aCharacter |
44 self breakPoint: #petitparser. |
|
45 |
27 |
46 ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
28 "Created: / 19-12-2010 / 18:13:19 / Jan Kurs <kurs.jan@post.cz>" |
47 ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ] |
|
48 ifTrue: [ super asPetitStream ] |
|
49 |
|
50 |
|
51 "/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
|
52 "/ ifFalse: [ PPStream on: collection from: position to: readLimit ] |
|
53 "/ ifTrue: [ super asPetitStream ] |
|
54 |
|
55 "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>" |
|
56 ! ! |
29 ! ! |
57 |
30 |
58 !Interval methodsFor:'*petitparser-converting'! |
31 !Interval methodsFor:'*petitparser-converting'! |
59 |
32 |
60 asParser |
33 asParser |
71 " |
44 " |
72 ! ! |
45 ! ! |
73 |
46 |
74 !Object methodsFor:'*petitparser-core-converting'! |
47 !Object methodsFor:'*petitparser-core-converting'! |
75 |
48 |
76 ition isNil or: [ readLimit isNil ] ]) |
49 asParser |
|
50 ^ PPPredicateObjectParser expect: self |
|
51 ! ! |
|
52 |
|
53 !Object methodsFor:'*petitparser-core-testing'! |
|
54 |
|
55 isPetitFailure |
|
56 ^ false |
|
57 ! ! |
|
58 |
|
59 !Object methodsFor:'*petitparser-core-testing'! |
|
60 |
|
61 isPetitParser |
|
62 ^ false |
|
63 ! ! |
|
64 |
|
65 !PositionableStream methodsFor:'*petitparser-core-converting'! |
|
66 |
|
67 asPetitStream |
|
68 "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." |
|
69 |
|
70 "DUNNO WHY, but on: collection from: position to: last set the start to position -1" |
|
71 self breakPoint: #petitparser. |
|
72 |
|
73 ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
77 ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ] |
74 ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ] |
78 ifTrue: [ super asPetitStream ] |
75 ifTrue: [ super asPetitStream ] |
79 |
76 |
80 |
77 |
81 "/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
78 "/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
83 "/ ifTrue: [ super asPetitStream ] |
80 "/ ifTrue: [ super asPetitStream ] |
84 |
81 |
85 "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>" |
82 "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>" |
86 ! ! |
83 ! ! |
87 |
84 |
88 !Object methodsFor:'*petitparser-core-testing'! |
85 !SequenceableCollection methodsFor:'*petitparser-core-converting'! |
89 |
86 |
90 adLimit ] |
87 asParser |
91 ifTrue: [ super asPetitStream ] |
88 ^ PPSequenceParser withAll: (self collect: [ :each | each asParser ]) |
92 |
|
93 |
|
94 "/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
|
95 "/ ifFalse: [ PPStream on: collection from: position to: readLimit ] |
|
96 "/ ifTrue: [ super asPetitStream ] |
|
97 |
|
98 "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>" |
|
99 ! ! |
|
100 |
|
101 !Object methodsFor:'*petitparser-core-testing'! |
|
102 |
|
103 : [ position isNil or: [ readLimit isNil ] ]) |
|
104 "/ ifFalse: [ PPStream on: collection from: position to: readLimit ] |
|
105 "/ ifTrue: [ super asPetitStream ] |
|
106 |
|
107 "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>" |
|
108 ! ! |
|
109 |
|
110 !PositionableStream methodsFor:'*petitparser-core-converting'! |
|
111 |
|
112 ection from: position to: readLimit ] |
|
113 "/ ifTrue: [ super asPetitStream ] |
|
114 |
|
115 "Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>" |
|
116 ! ! |
89 ! ! |
117 |
90 |
118 !SequenceableCollection methodsFor:'*petitparser-core-converting'! |
91 !SequenceableCollection methodsFor:'*petitparser-core-converting'! |
119 |
92 |
120 asParser |
93 asPetitStream |
121 ^ PPSequenceParser withAll: (self collect: [ :each | each asParser ] as:Array) |
94 ^ PPStream on: self |
122 ! ! |
95 ! ! |
123 |
96 |
124 !SequenceableCollection methodsFor:'*petitparser-core-converting'! |
97 !Interval methodsFor:'*petitparser-core-converting'! |
125 |
98 |
126 f |
99 asParser |
|
100 "Create a parser for any in a range of characters between start and stop." |
|
101 |
|
102 self assert:start isCharacter. |
|
103 self assert:stop isCharacter. |
|
104 self assert:step == 1. |
|
105 ^ PPPredicateObjectParser between: start and: stop |
|
106 |
|
107 " |
|
108 ($a to:$f) asParser parse:'a' |
|
109 ($a to:$f) asParser parse:'g' |
|
110 " |
127 ! ! |
111 ! ! |
128 |
112 |
129 !Set methodsFor:'*petitparser-core-converting'! |
113 !Set methodsFor:'*petitparser-core-converting'! |
130 |
114 |
131 arser perform: self |
115 asParser |
|
116 ^ PPChoiceParser withAll: (self collect: [ :each | each asParser ]) |
132 ! ! |
117 ! ! |
133 |
118 |
134 !Stream methodsFor:'*petitparser-core-converting'! |
119 !Stream methodsFor:'*petitparser-core-converting'! |
135 |
120 |
136 2-2010 / 16:47:22 / Jan Kurs <kurs.jan@post.cz>" |
121 asPetitStream |
|
122 ^ self contents asPetitStream |
137 ! ! |
123 ! ! |
138 |
124 |
139 !String methodsFor:'*petitparser-core-converting'! |
125 !String methodsFor:'*petitparser-core-converting'! |
140 |
126 |
141 ream |
127 asParser |
142 ^ string asPetitStream |
128 ^ PPLiteralSequenceParser on: self |
143 ! ! |
129 ! ! |
144 |
130 |
145 !Symbol methodsFor:'*petitparser-core-converting'! |
131 !Symbol methodsFor:'*petitparser-core-converting'! |
146 |
132 |
147 PPEpsilonParser new |
133 asParser |
|
134 ^ PPPredicateObjectParser perform: self |
148 ! ! |
135 ! ! |
149 |
136 |
150 !Symbol methodsFor:'Compatibility-Squeak'! |
137 !Symbol methodsFor:'Compatibility-Squeak'! |
151 |
138 |
152 ion_CVS |
139 value:anObject |
153 ^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.7 2014-02-17 14:35:54 cg Exp $' |
140 ^ anObject perform: self. |
|
141 |
|
142 "Created: / 18-12-2010 / 16:47:22 / Jan Kurs <kurs.jan@post.cz>" |
154 ! ! |
143 ! ! |
155 |
144 |
156 !Text methodsFor:'*petitparser-core'! |
145 !Text methodsFor:'*petitparser-core'! |
157 |
146 |
|
147 asPetitStream |
|
148 ^ string asPetitStream |
158 ! ! |
149 ! ! |
159 |
150 |
160 !UndefinedObject methodsFor:'*petitparser-converting'! |
151 !UndefinedObject methodsFor:'*petitparser-converting'! |
161 |
152 |
|
153 asParser |
|
154 ^ PPEpsilonParser new |
162 ! ! |
155 ! ! |
163 |
156 |
164 !stx_goodies_petitparser class methodsFor:'documentation'! |
157 !stx_goodies_petitparser class methodsFor:'documentation'! |
165 |
158 |
|
159 extensionsVersion_CVS |
|
160 ^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.8 2014-02-17 15:08:10 cg Exp $' |
166 ! ! |
161 ! ! |
167 |
|