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