author | Claus Gittinger <cg@exept.de> |
Mon, 17 Feb 2014 02:30:49 +0100 | |
changeset 150 | 24e8d10ff041 |
parent 58 | 4af6ce1837b2 |
child 152 | d104f89293e3 |
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 |
|
0 | 81 |
!Set methodsFor:'*petitparser-core-converting'! |
82 |
||
83 |
asParser |
|
84 |
^ PPChoiceParser withAll: (self collect: [ :each | each asParser ]) |
|
85 |
! ! |
|
3 | 86 |
|
0 | 87 |
!Stream methodsFor:'*petitparser-core-converting'! |
88 |
||
89 |
asPetitStream |
|
90 |
^ self contents asPetitStream |
|
91 |
! ! |
|
3 | 92 |
|
0 | 93 |
!String methodsFor:'*petitparser-core-converting'! |
94 |
||
95 |
asParser |
|
96 |
^ PPLiteralSequenceParser on: self |
|
97 |
! ! |
|
3 | 98 |
|
0 | 99 |
!Symbol methodsFor:'*petitparser-core-converting'! |
100 |
||
101 |
asParser |
|
102 |
^ PPPredicateObjectParser perform: self |
|
103 |
! ! |
|
3 | 104 |
|
0 | 105 |
!Symbol methodsFor:'Compatibility-Squeak'! |
106 |
||
107 |
value:anObject |
|
108 |
^ anObject perform: self. |
|
109 |
||
110 |
"Created: / 18-12-2010 / 16:47:22 / Jan Kurs <kurs.jan@post.cz>" |
|
111 |
! ! |
|
3 | 112 |
|
0 | 113 |
!Text methodsFor:'*petitparser-core'! |
114 |
||
115 |
asPetitStream |
|
116 |
^ string asPetitStream |
|
117 |
! ! |
|
3 | 118 |
|
0 | 119 |
!UndefinedObject methodsFor:'*petitparser-converting'! |
120 |
||
121 |
asParser |
|
122 |
^ PPEpsilonParser new |
|
123 |
! ! |
|
3 | 124 |
|
4 | 125 |
!stx_goodies_petitparser class methodsFor:'documentation'! |
3 | 126 |
|
127 |
extensionsVersion_CVS |
|
150
24e8d10ff041
Character>>-not needed here - already in libbasic
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
128 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/extensions.st,v 1.5 2014-02-17 01:30:49 cg Exp $' |
24e8d10ff041
Character>>-not needed here - already in libbasic
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
129 |
! ! |