author | Claus Gittinger <cg@exept.de> |
Mon, 17 Feb 2014 15:35:54 +0100 | |
changeset 153 | 43cdafa051d5 |
parent 152 | d104f89293e3 |
child 154 | 5c8f5da40d90 |
permissions | -rw-r--r-- |
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 |
|
153 | 15 |
!Character methodsFor:'arithmetic'! |
16 |
||
17 |
-converting' |
|
18 |
! ! |
|
19 |
||
0 | 20 |
!Character methodsFor:'*petitparser-converting'! |
21 |
||
153 | 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." |
23 |
||
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>" |
|
0 | 37 |
! ! |
3 | 38 |
|
0 | 39 |
!Character methodsFor:'arithmetic'! |
40 |
||
153 | 41 |
different internal representation. In these cases just use the super implementation that is inefficient but should work in all cases." |
0 | 42 |
|
150
24e8d10ff041
Character>>-not needed here - already in libbasic
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
43 |
"DUNNO WHY, but on: collection from: position to: last set the start to position -1" |
24e8d10ff041
Character>>-not needed here - already in libbasic
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
44 |
self breakPoint: #petitparser. |
0 | 45 |
|
150
24e8d10ff041
Character>>-not needed here - already in libbasic
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
46 |
^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
24e8d10ff041
Character>>-not needed here - already in libbasic
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
47 |
ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ] |
24e8d10ff041
Character>>-not needed here - already in libbasic
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
48 |
ifTrue: [ super asPetitStream ] |
0 | 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 |
! ! |
|
3 | 57 |
|
153 | 58 |
!Interval methodsFor:'*petitparser-converting'! |
0 | 59 |
|
60 |
asParser |
|
153 | 61 |
"Create a range of characters between start and stop." |
152 | 62 |
|
63 |
self assert:start isCharacter. |
|
64 |
self assert:stop isCharacter. |
|
65 |
self assert:step == 1. |
|
66 |
^ PPPredicateObjectParser between: start and: stop |
|
67 |
||
68 |
" |
|
69 |
($a to:$f) asParser parse:'a' |
|
70 |
($a to:$f) asParser parse:'g' |
|
71 |
" |
|
72 |
! ! |
|
73 |
||
153 | 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 |
||
0 | 129 |
!Set methodsFor:'*petitparser-core-converting'! |
130 |
||
153 | 131 |
arser perform: self |
0 | 132 |
! ! |
3 | 133 |
|
0 | 134 |
!Stream methodsFor:'*petitparser-core-converting'! |
135 |
||
153 | 136 |
2-2010 / 16:47:22 / Jan Kurs <kurs.jan@post.cz>" |
0 | 137 |
! ! |
3 | 138 |
|
0 | 139 |
!String methodsFor:'*petitparser-core-converting'! |
140 |
||
153 | 141 |
ream |
142 |
^ string asPetitStream |
|
0 | 143 |
! ! |
3 | 144 |
|
0 | 145 |
!Symbol methodsFor:'*petitparser-core-converting'! |
146 |
||
153 | 147 |
PPEpsilonParser new |
0 | 148 |
! ! |
3 | 149 |
|
0 | 150 |
!Symbol methodsFor:'Compatibility-Squeak'! |
151 |
||
153 | 152 |
ion_CVS |
153 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.7 2014-02-17 14:35:54 cg Exp $' |
|
0 | 154 |
! ! |
3 | 155 |
|
0 | 156 |
!Text methodsFor:'*petitparser-core'! |
157 |
||
158 |
! ! |
|
3 | 159 |
|
0 | 160 |
!UndefinedObject methodsFor:'*petitparser-converting'! |
161 |
||
162 |
! ! |
|
3 | 163 |
|
4 | 164 |
!stx_goodies_petitparser class methodsFor:'documentation'! |
3 | 165 |
|
150
24e8d10ff041
Character>>-not needed here - already in libbasic
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
166 |
! ! |
153 | 167 |