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