author | Claus Gittinger <cg@exept.de> |
Tue, 04 Mar 2014 15:33:00 +0100 | |
changeset 170 | 38bf7423a5d4 |
parent 155 | 1109bb0048eb |
child 213 | b38781d329c5 |
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 |
|
0 | 15 |
!Character methodsFor:'*petitparser-converting'! |
16 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
17 |
asParser |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
18 |
^ PPLiteralObjectParser on: self |
0 | 19 |
! ! |
3 | 20 |
|
0 | 21 |
!Character methodsFor:'arithmetic'! |
22 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
23 |
ppMinus: aCharacter |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
24 |
"Create a range of characters between the receiver and the argument." |
0 | 25 |
|
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
26 |
^ PPPredicateObjectParser between: self and: aCharacter |
0 | 27 |
|
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
28 |
"Created: / 19-12-2010 / 18:13:19 / Jan Kurs <kurs.jan@post.cz>" |
0 | 29 |
! ! |
3 | 30 |
|
153 | 31 |
!Interval methodsFor:'*petitparser-converting'! |
0 | 32 |
|
33 |
asParser |
|
153 | 34 |
"Create a range of characters between start and stop." |
152 | 35 |
|
36 |
self assert:start isCharacter. |
|
37 |
self assert:stop isCharacter. |
|
38 |
self assert:step == 1. |
|
39 |
^ PPPredicateObjectParser between: start and: stop |
|
40 |
||
41 |
" |
|
42 |
($a to:$f) asParser parse:'a' |
|
43 |
($a to:$f) asParser parse:'g' |
|
44 |
" |
|
45 |
! ! |
|
46 |
||
153 | 47 |
!Object methodsFor:'*petitparser-core-converting'! |
48 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
49 |
asParser |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
50 |
^ PPPredicateObjectParser expect: self |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
51 |
! ! |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
52 |
|
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
53 |
!Object methodsFor:'*petitparser-core-testing'! |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
54 |
|
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
55 |
isPetitFailure |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
56 |
^ false |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
57 |
! ! |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
58 |
|
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
59 |
!Object methodsFor:'*petitparser-core-testing'! |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
60 |
|
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
61 |
isPetitParser |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
62 |
^ false |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
63 |
! ! |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
64 |
|
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
65 |
!PositionableStream methodsFor:'*petitparser-core-converting'! |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
66 |
|
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
67 |
asPetitStream |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
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." |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
69 |
|
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
70 |
"DUNNO WHY, but on: collection from: position to: last set the start to position -1" |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
71 |
self breakPoint: #petitparser. |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
72 |
|
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
73 |
^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
153 | 74 |
ifFalse: [ PPStream on: collection from: (position +1) to: readLimit ] |
75 |
ifTrue: [ super asPetitStream ] |
|
76 |
||
77 |
||
78 |
"/ ^ (collection isNil or: [ position isNil or: [ readLimit isNil ] ]) |
|
79 |
"/ ifFalse: [ PPStream on: collection from: position to: readLimit ] |
|
80 |
"/ ifTrue: [ super asPetitStream ] |
|
81 |
||
82 |
"Modified: / 18-12-2010 / 17:38:01 / Jan Kurs <kurs.jan@post.cz>" |
|
83 |
! ! |
|
84 |
||
85 |
!SequenceableCollection methodsFor:'*petitparser-core-converting'! |
|
86 |
||
87 |
asParser |
|
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
88 |
^ PPSequenceParser withAll: (self collect: [ :each | each asParser ]) |
153 | 89 |
! ! |
90 |
||
91 |
!SequenceableCollection methodsFor:'*petitparser-core-converting'! |
|
92 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
93 |
asPetitStream |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
94 |
^ PPStream on: self |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
95 |
! ! |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
96 |
|
0 | 97 |
!Set methodsFor:'*petitparser-core-converting'! |
98 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
99 |
asParser |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
100 |
^ PPChoiceParser withAll: (self collect: [ :each | each asParser ]) |
0 | 101 |
! ! |
3 | 102 |
|
0 | 103 |
!Stream methodsFor:'*petitparser-core-converting'! |
104 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
105 |
asPetitStream |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
106 |
^ self contents asPetitStream |
0 | 107 |
! ! |
3 | 108 |
|
0 | 109 |
!String methodsFor:'*petitparser-core-converting'! |
110 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
111 |
asParser |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
112 |
^ PPLiteralSequenceParser on: self |
0 | 113 |
! ! |
3 | 114 |
|
0 | 115 |
!Symbol methodsFor:'*petitparser-core-converting'! |
116 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
117 |
asParser |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
118 |
^ PPPredicateObjectParser perform: self |
0 | 119 |
! ! |
3 | 120 |
|
0 | 121 |
!Symbol methodsFor:'Compatibility-Squeak'! |
122 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
123 |
value:anObject |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
124 |
^ anObject perform: self. |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
125 |
|
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
126 |
"Created: / 18-12-2010 / 16:47:22 / Jan Kurs <kurs.jan@post.cz>" |
0 | 127 |
! ! |
3 | 128 |
|
0 | 129 |
!Text methodsFor:'*petitparser-core'! |
130 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
131 |
asPetitStream |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
132 |
^ string asPetitStream |
0 | 133 |
! ! |
3 | 134 |
|
0 | 135 |
!UndefinedObject methodsFor:'*petitparser-converting'! |
136 |
||
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
137 |
asParser |
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
138 |
^ PPEpsilonParser new |
0 | 139 |
! ! |
3 | 140 |
|
4 | 141 |
!stx_goodies_petitparser class methodsFor:'documentation'! |
3 | 142 |
|
154
5c8f5da40d90
manually fixed bad checkin version
Claus Gittinger <cg@exept.de>
parents:
153
diff
changeset
|
143 |
extensionsVersion_CVS |
155 | 144 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.9 2014-02-17 15:08:38 cg Exp $' |
150
24e8d10ff041
Character>>-not needed here - already in libbasic
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
145 |
! ! |