author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 11 Jan 2013 13:41:57 +0000 | |
changeset 4 | 5ef74750c3bc |
parent 3 | 46c322c66a29 |
child 6 | 06efdfe62106 |
permissions | -rw-r--r-- |
1
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1 |
"{ Package: 'jv:dart/compiler' }" |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
2 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
3 |
"{ NameSpace: Dart }" |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
4 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
5 |
PPCompositeParser subclass:#Parser |
2
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
6 |
instanceVariableNames:'additiveExpression additiveOperator argumentList arguments |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
7 |
assignableExpression assignableSelector assignmentOperator |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
8 |
bitwiseAndExpression bitwiseOperator bitwiseOrExpression |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
9 |
bitwiseXorExpression block catchPart classDefinition |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
10 |
classMemberDefinition compilationUnit compoundLiteral |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
11 |
conditionalExpression constInitializedIdentifier |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
12 |
constInitializedVariableDeclaration |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
13 |
constantConstructorDeclaration constantExpression |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
14 |
constructorDeclaration declaration declaredIdentifier defaultCase |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
15 |
defaultFormalParameter directive equalityExpression |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
16 |
equalityOperator expression expressionInParentheses |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
17 |
expressionList factoryConstructorDeclaration factorySpecification |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
18 |
fieldFormalParameter fieldInitializer finalVarOrType finallyPart |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
19 |
forInitializerStatement forLoopParts formalParameterList |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
20 |
functionBody functionBodyOrNative functionDeclaration |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
21 |
functionExpression functionExpressionBody functionNative |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
22 |
functionPrefix functionTypeAlias getOrSet identifier |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
23 |
importReference importReferences incrementOperator |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
24 |
initializedIdentifier initializedIdentifierList |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
25 |
initializedVariableDeclaration initializers interfaceDefinition |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
26 |
interfaceMemberDefinition interfaces isOperator |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
27 |
iterationStatement label libraryBody libraryDefinition |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
28 |
libraryImport librarySource libraryUnit listLiteral literal |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
29 |
logicalAndExpression logicalOrExpression mapLiteral |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
30 |
mapLiteralEntry methodDeclaration multiplicativeExpression |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
31 |
multiplicativeOperator namedArgument namedConstructorDeclaration |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
32 |
namedFormalParameters negateOperator nonLabelledStatement |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
33 |
normalFormalParameter normalFormalParameterTail postfixExpression |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
34 |
postfixOperator prefixOperator primary primaryFE primaryNoFE |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
35 |
qualified redirection relationalExpression relationalOperator |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
36 |
returnType selectionStatement selector shiftExpression |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
37 |
shiftOperator simpleFormalParameter sourceUrls |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
38 |
specialSignatureDefinition statement statements |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
39 |
staticFinalDeclaration staticFinalDeclarationList |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
40 |
superCallOrFieldInitializer superclass superinterfaces switchCase |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
41 |
topLevelDefinition tryStatement type typeArguments typeList |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
42 |
typeParameter typeParameters unaryExpression |
8fedb5e096fc
Initial grammar definition based on http://slps.github.com/zoo/index.html#Google_Dart.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
43 |
userDefinableOperator variableDeclaration' |
3 | 44 |
classVariableNames:'Debugging' |
1
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
45 |
poolDictionaries:'' |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
46 |
category:'Languages-Dart-Parser' |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
47 |
! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
48 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
49 |
PPParser subclass:#TokenParser |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
50 |
instanceVariableNames:'tokenType' |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
51 |
classVariableNames:'' |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
52 |
poolDictionaries:'' |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
53 |
privateIn:Parser |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
54 |
! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
55 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
56 |
|
3 | 57 |
!Parser class methodsFor:'initialization'! |
58 |
||
59 |
debugging: aBoolean |
|
60 |
Debugging := aBoolean |
|
61 |
||
62 |
" |
|
63 |
JavaParser debugging: true. |
|
64 |
JavaParser debugging: false. |
|
65 |
" |
|
66 |
||
67 |
"Created: / 11-01-2013 / 11:32:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
68 |
! |
|
69 |
||
70 |
initialize |
|
71 |
"Invoked at system start or when the class is dynamically loaded." |
|
72 |
||
73 |
"/ please change as required (and remove this comment) |
|
74 |
||
75 |
Debugging := false. |
|
76 |
||
77 |
"Modified: / 11-01-2013 / 11:32:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
78 |
! ! |
|
79 |
||
80 |
!Parser methodsFor:'accessing'! |
|
81 |
||
82 |
start |
|
83 |
^compilationUnit , (TokenParser for: #EOF). |
|
84 |
||
85 |
"Created: / 11-01-2013 / 13:19:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
86 |
! ! |
|
87 |
||
88 |
!Parser methodsFor:'grammar'! |
|
89 |
||
90 |
additiveExpression |
|
91 |
||
92 |
^ (multiplicativeExpression , ((additiveOperator , multiplicativeExpression) star)) |
|
93 |
/ ((TokenParser for: #super) , ((additiveOperator , multiplicativeExpression) plus)) |
|
94 |
||
95 |
"Modified: / 11-01-2013 / 09:59:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
96 |
! |
|
97 |
||
98 |
additiveOperator |
|
99 |
||
100 |
^ ('+' asParser) |
|
101 |
/ ('-' asParser) |
|
102 |
||
103 |
! |
|
104 |
||
105 |
argumentList |
|
106 |
||
107 |
^ (namedArgument , (((',' asParser) , namedArgument) star)) |
|
108 |
/ (expressionList , (((',' asParser) , namedArgument) star)) |
|
109 |
||
110 |
! |
|
111 |
||
112 |
arguments |
|
113 |
||
114 |
^('(' asParser) , (argumentList optional) , (')' asParser) |
|
115 |
! |
|
116 |
||
117 |
assignableExpression |
|
118 |
||
119 |
^ (primary , (((arguments star) , assignableSelector) plus)) |
|
120 |
/ ((TokenParser for: #super) , assignableSelector) |
|
121 |
/ identifier |
|
122 |
||
123 |
"Modified: / 11-01-2013 / 10:00:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
124 |
! |
|
125 |
||
126 |
assignableSelector |
|
127 |
||
128 |
^ (('[' asParser) , constantExpression , (']' asParser)) |
|
129 |
/ (('.' asParser) , identifier) |
|
130 |
||
131 |
! |
|
132 |
||
133 |
assignmentOperator |
|
134 |
||
135 |
^ ('=' asParser) |
|
136 |
/ ('*=' asParser) |
|
137 |
/ ('/=' asParser) |
|
138 |
/ ('~/=' asParser) |
|
139 |
/ ('%=' asParser) |
|
140 |
/ ('+=' asParser) |
|
141 |
/ ('-=' asParser) |
|
142 |
/ ('<<=' asParser) |
|
143 |
/ (('>' asParser) , ('>' asParser) , ('>' asParser) , ('=' asParser)) |
|
144 |
/ (('>' asParser) , ('>' asParser) , ('=' asParser)) |
|
145 |
/ ('&=' asParser) |
|
146 |
/ ('^=' asParser) |
|
147 |
/ ('|=' asParser) |
|
148 |
||
149 |
! |
|
150 |
||
151 |
bitwiseAndExpression |
|
152 |
||
153 |
^ (equalityExpression , ((('&' asParser) , equalityExpression) star)) |
|
154 |
/ ((TokenParser for: #super) , ((('&' asParser) , equalityExpression) plus)) |
|
155 |
||
156 |
"Modified: / 11-01-2013 / 10:00:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
157 |
! |
|
158 |
||
159 |
bitwiseOperator |
|
160 |
||
161 |
^ ('&' asParser) |
|
162 |
/ ('^' asParser) |
|
163 |
/ ('|' asParser) |
|
164 |
||
165 |
! |
|
166 |
||
167 |
bitwiseOrExpression |
|
168 |
||
169 |
^ (bitwiseXorExpression , ((('|' asParser) , bitwiseXorExpression) star)) |
|
170 |
/ ((TokenParser for:#super) , ((('|' asParser) , bitwiseXorExpression) plus)) |
|
171 |
||
172 |
! |
|
173 |
||
174 |
bitwiseXorExpression |
|
175 |
||
176 |
^ (bitwiseAndExpression , ((('^' asParser) , bitwiseAndExpression) star)) |
|
177 |
/ ((TokenParser for:#super) , ((('^' asParser) , bitwiseAndExpression) plus)) |
|
178 |
||
179 |
! |
|
180 |
||
181 |
block |
|
182 |
||
183 |
^('{' asParser) , statements , ('}' asParser) |
|
184 |
! |
|
185 |
||
186 |
catchPart |
|
187 |
||
188 |
^(TokenParser for:#catch) , ('(' asParser) , declaredIdentifier , (((',' asParser) , declaredIdentifier) optional) , (')' asParser) , block |
|
189 |
! |
|
190 |
||
191 |
classDefinition |
|
192 |
||
193 |
^ ((TokenParser for:#class) , identifier , (typeParameters optional) , (superclass optional) , (interfaces optional) , ('{' asParser) , (classMemberDefinition star) , ('}' asParser)) |
|
194 |
/ ((TokenParser for:#class) , identifier , (typeParameters optional) , (interfaces optional) , (TokenParser for:#native) , (TokenParser for:#string) , ('{' asParser) , (classMemberDefinition star) , ('}' asParser)) |
|
195 |
||
196 |
! |
|
197 |
||
198 |
classMemberDefinition |
|
199 |
||
200 |
^ (declaration , (';' asParser)) |
|
201 |
/ (constructorDeclaration , (';' asParser)) |
|
202 |
/ (methodDeclaration , functionBodyOrNative) |
|
203 |
/ ((TokenParser for:#const) , factoryConstructorDeclaration , functionNative) |
|
204 |
||
205 |
! |
|
206 |
||
207 |
compilationUnit |
|
208 |
||
209 |
^( ((TokenParser for: #'#!!') optional) , (directive star) , (topLevelDefinition star) ) |
|
210 |
||
211 |
"Modified: / 11-01-2013 / 13:18:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
212 |
! |
|
213 |
||
214 |
compoundLiteral |
|
215 |
||
216 |
^ listLiteral |
|
217 |
/ mapLiteral |
|
218 |
||
219 |
! |
|
220 |
||
221 |
conditionalExpression |
|
222 |
||
223 |
^logicalOrExpression , ((('?' asParser) , constantExpression , (':' asParser) , constantExpression) optional) |
|
224 |
! |
|
225 |
||
226 |
constInitializedIdentifier |
|
227 |
||
228 |
^identifier , ((('=' asParser) , constantExpression) optional) |
|
229 |
! |
|
230 |
||
231 |
constInitializedVariableDeclaration |
|
232 |
||
233 |
^declaredIdentifier , ((('=' asParser) , constantExpression) optional) , (((',' asParser) , constInitializedIdentifier) star) |
|
234 |
! |
|
235 |
||
236 |
constantConstructorDeclaration |
|
237 |
||
238 |
^(TokenParser for:#const) , qualified , formalParameterList |
|
239 |
! |
|
240 |
||
241 |
constantExpression |
|
242 |
||
243 |
^ (assignableExpression , assignmentOperator , constantExpression) |
|
244 |
/ conditionalExpression |
|
245 |
||
246 |
! |
|
247 |
||
248 |
constructorDeclaration |
|
249 |
||
250 |
^ (identifier , formalParameterList , ((redirection / initializers ) optional)) |
|
251 |
/ (namedConstructorDeclaration , ((redirection / initializers ) optional)) |
|
252 |
||
253 |
! |
|
254 |
||
255 |
declaration |
|
256 |
||
257 |
^ (constantConstructorDeclaration , ((redirection / initializers ) optional)) |
|
258 |
/ (functionDeclaration , redirection) |
|
259 |
/ (namedConstructorDeclaration , redirection) |
|
260 |
/ ((TokenParser for:#abstract) , specialSignatureDefinition) |
|
261 |
/ ((TokenParser for:#abstract) , functionDeclaration) |
|
262 |
/ ((TokenParser for:#static) , (TokenParser for:#final) , (type optional) , staticFinalDeclarationList) |
|
263 |
/ (((TokenParser for:#static) optional) , constInitializedVariableDeclaration) |
|
264 |
||
265 |
! |
|
266 |
||
267 |
declaredIdentifier |
|
268 |
||
269 |
^ ((TokenParser for:#final) , (type optional) , identifier) |
|
270 |
/ ((TokenParser for:#var) , identifier) |
|
271 |
/ (type , identifier) |
|
272 |
||
273 |
! |
|
274 |
||
275 |
defaultCase |
|
276 |
||
277 |
^(label optional) , (((TokenParser for:#case) , constantExpression , (':' asParser)) star) , (TokenParser for:#default) , (':' asParser) , statements |
|
278 |
! |
|
279 |
||
280 |
defaultFormalParameter |
|
281 |
||
282 |
^normalFormalParameter , ((('=' asParser) , constantExpression) optional) |
|
283 |
! |
|
284 |
||
285 |
directive |
|
286 |
||
287 |
^('#' asParser) , identifier , arguments , (';' asParser) |
|
288 |
! |
|
289 |
||
290 |
equalityExpression |
|
291 |
||
292 |
^ (relationalExpression , ((equalityOperator , relationalExpression) optional)) |
|
293 |
/ ((TokenParser for:#super) , equalityOperator , relationalExpression) |
|
294 |
||
295 |
! |
|
296 |
||
297 |
equalityOperator |
|
298 |
||
299 |
^ ('==' asParser) |
|
300 |
/ ('!!=' asParser) |
|
301 |
/ ('===' asParser) |
|
302 |
/ ('!!==' asParser) |
|
303 |
||
304 |
! |
|
305 |
||
306 |
expression |
|
307 |
||
308 |
^ (assignableExpression , assignmentOperator , expression) |
|
309 |
/ conditionalExpression |
|
310 |
||
311 |
"Created: / 11-01-2013 / 13:22:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
312 |
! |
|
313 |
||
314 |
expressionInParentheses |
|
315 |
||
316 |
^('(' asParser) , constantExpression , (')' asParser) |
|
317 |
! |
|
318 |
||
319 |
expressionList |
|
320 |
||
321 |
^constantExpression , (((',' asParser) , constantExpression) star) |
|
322 |
! |
|
323 |
||
324 |
factoryConstructorDeclaration |
|
325 |
||
326 |
^(TokenParser for:#factory) , qualified , (typeParameters optional) , ((('.' asParser) , identifier) optional) , formalParameterList |
|
327 |
! |
|
328 |
||
329 |
factorySpecification |
|
330 |
||
331 |
^(TokenParser for:#factory) , type |
|
332 |
! |
|
333 |
||
334 |
fieldFormalParameter |
|
335 |
||
336 |
^(finalVarOrType optional) , (TokenParser for:#this) , ('.' asParser) , identifier |
|
337 |
! |
|
338 |
||
339 |
fieldInitializer |
|
340 |
||
341 |
^(((TokenParser for:#this) , ('.' asParser)) optional) , identifier , ('=' asParser) , conditionalExpression |
|
342 |
! |
|
343 |
||
344 |
finalVarOrType |
|
345 |
||
346 |
^ ((TokenParser for:#final) , (type optional)) |
|
347 |
/ (TokenParser for:#var) |
|
348 |
/ type |
|
349 |
||
350 |
! |
|
351 |
||
352 |
finallyPart |
|
353 |
||
354 |
^(TokenParser for:#finally) , block |
|
355 |
! |
|
356 |
||
357 |
forInitializerStatement |
|
358 |
||
359 |
^ (initializedVariableDeclaration , (';' asParser)) |
|
360 |
/ ((constantExpression optional) , (';' asParser)) |
|
361 |
||
362 |
! |
|
363 |
||
364 |
forLoopParts |
|
365 |
||
366 |
^ (forInitializerStatement , (constantExpression optional) , (';' asParser) , (expressionList optional)) |
|
367 |
/ (declaredIdentifier , (TokenParser for:#in) , constantExpression) |
|
368 |
/ (identifier , (TokenParser for:#in) , constantExpression) |
|
369 |
||
370 |
! |
|
371 |
||
372 |
formalParameterList |
|
373 |
||
374 |
^ (('(' asParser) , (namedFormalParameters optional) , (')' asParser)) |
|
375 |
/ (('(' asParser) , normalFormalParameter , (normalFormalParameterTail optional) , (')' asParser)) |
|
376 |
||
377 |
! |
|
378 |
||
379 |
functionBody |
|
380 |
||
381 |
^ (('=>' asParser) , constantExpression , (';' asParser)) |
|
382 |
/ block |
|
383 |
||
384 |
! |
|
385 |
||
386 |
functionBodyOrNative |
|
387 |
||
388 |
^ ((TokenParser for:#native) , functionBody) |
|
389 |
/ functionNative |
|
390 |
/ functionBody |
|
391 |
||
392 |
! |
|
393 |
||
394 |
functionDeclaration |
|
395 |
||
396 |
^(returnType optional) , identifier , formalParameterList |
|
397 |
! |
|
398 |
||
399 |
functionExpression |
|
400 |
||
401 |
^(((returnType optional) , identifier) optional) , formalParameterList , functionExpressionBody |
|
402 |
! |
|
403 |
||
404 |
functionExpressionBody |
|
405 |
||
406 |
^ (('=>' asParser) , constantExpression) |
|
407 |
/ block |
|
408 |
||
409 |
! |
|
410 |
||
411 |
functionNative |
|
412 |
||
413 |
^(TokenParser for:#native) , ((TokenParser for:#string) optional) , (';' asParser) |
|
414 |
! |
|
415 |
||
416 |
functionPrefix |
|
417 |
||
418 |
^(returnType optional) , identifier |
|
419 |
! |
|
420 |
||
421 |
functionTypeAlias |
|
422 |
||
423 |
^(TokenParser for:#typedef) , functionPrefix , (typeParameters optional) , formalParameterList , (';' asParser) |
|
424 |
! |
|
425 |
||
426 |
getOrSet |
|
427 |
||
428 |
^ (TokenParser for:#get) |
|
429 |
/ (TokenParser for:#set) |
|
430 |
||
431 |
! |
|
432 |
||
433 |
identifier |
|
434 |
||
435 |
^ (TokenParser for:#identifier_no_dollar) |
|
436 |
/ (TokenParser for:#identifier) |
|
437 |
/ (TokenParser for:#abstract) |
|
438 |
/ (TokenParser for:#assert) |
|
439 |
/ (TokenParser for:#class) |
|
440 |
/ (TokenParser for:#extends) |
|
441 |
/ (TokenParser for:#factory) |
|
442 |
/ (TokenParser for:#get) |
|
443 |
/ (TokenParser for:#implements) |
|
444 |
/ (TokenParser for:#import) |
|
445 |
/ (TokenParser for:#interface) |
|
446 |
/ (TokenParser for:#is) |
|
447 |
/ (TokenParser for:#library) |
|
448 |
/ (TokenParser for:#native) |
|
449 |
/ (TokenParser for:#negate) |
|
450 |
/ (TokenParser for:#operator) |
|
451 |
/ (TokenParser for:#set) |
|
452 |
/ (TokenParser for:#source) |
|
453 |
/ (TokenParser for:#static) |
|
454 |
/ (TokenParser for:#typedef) |
|
455 |
||
456 |
"Modified: / 11-01-2013 / 13:25:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
457 |
! |
|
458 |
||
459 |
importReference |
|
460 |
||
461 |
^(((TokenParser for:#identifier) , (':' asParser)) optional) , (TokenParser for:#string) |
|
462 |
! |
|
463 |
||
464 |
importReferences |
|
465 |
||
466 |
^importReference , (((',' asParser) , importReference) star) , ((',' asParser) optional) |
|
467 |
! |
|
468 |
||
469 |
incrementOperator |
|
470 |
||
471 |
^ ('++' asParser) |
|
472 |
/ ('--' asParser) |
|
473 |
||
474 |
"Created: / 11-01-2013 / 13:27:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
475 |
! |
|
476 |
||
477 |
initializedIdentifier |
|
478 |
||
479 |
^identifier , ((('=' asParser) , constantExpression) optional) |
|
480 |
! |
|
481 |
||
482 |
initializedIdentifierList |
|
483 |
||
484 |
^initializedIdentifier , (((',' asParser) , initializedIdentifier) star) |
|
485 |
! |
|
486 |
||
487 |
initializedVariableDeclaration |
|
488 |
||
489 |
^declaredIdentifier , ((('=' asParser) , constantExpression) optional) , (((',' asParser) , initializedIdentifier) star) |
|
490 |
! |
|
491 |
||
492 |
initializers |
|
493 |
||
494 |
^(':' asParser) , superCallOrFieldInitializer , (((',' asParser) , superCallOrFieldInitializer) star) |
|
495 |
! |
|
496 |
||
497 |
interfaceDefinition |
|
498 |
||
499 |
^(TokenParser for:#interface) , identifier , (typeParameters optional) , (superinterfaces optional) , (factorySpecification optional) , ('{' asParser) , (interfaceMemberDefinition star) , ('}' asParser) |
|
500 |
! |
|
501 |
||
502 |
interfaceMemberDefinition |
|
503 |
||
504 |
^ ((TokenParser for:#static) , (TokenParser for:#final) , (type optional) , initializedIdentifierList , (';' asParser)) |
|
505 |
/ (functionDeclaration , (';' asParser)) |
|
506 |
/ (constantConstructorDeclaration , (';' asParser)) |
|
507 |
/ (namedConstructorDeclaration , (';' asParser)) |
|
508 |
/ (specialSignatureDefinition , (';' asParser)) |
|
509 |
/ (variableDeclaration , (';' asParser)) |
|
510 |
||
511 |
! |
|
512 |
||
513 |
interfaces |
|
514 |
||
515 |
^(TokenParser for:#implements) , typeList |
|
516 |
! |
|
517 |
||
518 |
isOperator |
|
519 |
||
520 |
^(TokenParser for:#is) , (('!!' asParser) optional) |
|
521 |
! |
|
522 |
||
523 |
iterationStatement |
|
524 |
||
525 |
^ ((TokenParser for:#while) , ('(' asParser) , constantExpression , (')' asParser) , statement) |
|
526 |
/ ((TokenParser for:#do) , statement , (TokenParser for:#while) , ('(' asParser) , constantExpression , (')' asParser) , (';' asParser)) |
|
527 |
/ ((TokenParser for:#for) , ('(' asParser) , forLoopParts , (')' asParser) , statement) |
|
528 |
||
529 |
! |
|
530 |
||
531 |
label |
|
532 |
||
533 |
^identifier , (':' asParser) |
|
534 |
! |
|
535 |
||
536 |
libraryBody |
|
537 |
||
538 |
^(libraryImport optional) , (librarySource optional) |
|
539 |
! |
|
540 |
||
541 |
libraryDefinition |
|
542 |
||
543 |
^(TokenParser for:#library) , ('{' asParser) , libraryBody , ('}' asParser) |
|
544 |
! |
|
545 |
||
546 |
libraryImport |
|
547 |
||
548 |
^(TokenParser for:#import) , ('=' asParser) , ('[' asParser) , (importReferences optional) , (']' asParser) |
|
549 |
! |
|
550 |
||
551 |
librarySource |
|
552 |
||
553 |
^(TokenParser for:#source) , ('=' asParser) , ('[' asParser) , (sourceUrls optional) , (']' asParser) |
|
554 |
! |
|
555 |
||
556 |
libraryUnit |
|
557 |
||
558 |
^libraryDefinition end |
|
559 |
||
560 |
"Modified: / 11-01-2013 / 10:07:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
561 |
! |
|
562 |
||
563 |
listLiteral |
|
564 |
||
565 |
^('[' asParser) , ((expressionList , ((',' asParser) optional)) optional) , (']' asParser) |
|
566 |
! |
|
567 |
||
568 |
literal |
|
569 |
||
570 |
^ (TokenParser for: #null) |
|
571 |
/ (TokenParser for: #true) |
|
572 |
/ (TokenParser for: #false) |
|
573 |
/ (TokenParser for: #number) |
|
574 |
/ (TokenParser for:#string) |
|
575 |
||
576 |
"Modified: / 11-01-2013 / 10:08:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
577 |
! |
|
578 |
||
579 |
logicalAndExpression |
|
580 |
||
581 |
^bitwiseOrExpression , ((('&&' asParser) , bitwiseOrExpression) star) |
|
582 |
! |
|
583 |
||
584 |
logicalOrExpression |
|
585 |
||
586 |
^logicalAndExpression , ((('||' asParser) , logicalAndExpression) star) |
|
587 |
! |
|
588 |
||
589 |
mapLiteral |
|
590 |
||
591 |
^('{' asParser) , ((mapLiteralEntry , (((',' asParser) , mapLiteralEntry) star) , ((',' asParser) optional)) optional) , ('}' asParser) |
|
592 |
! |
|
593 |
||
594 |
mapLiteralEntry |
|
595 |
||
596 |
^(TokenParser for:#string) , (':' asParser) , constantExpression |
|
597 |
! |
|
598 |
||
599 |
methodDeclaration |
|
600 |
||
601 |
^ factoryConstructorDeclaration |
|
602 |
/ ((TokenParser for:#static) , functionDeclaration) |
|
603 |
/ specialSignatureDefinition |
|
604 |
/ (functionDeclaration , (initializers optional)) |
|
605 |
/ (namedConstructorDeclaration , (initializers optional)) |
|
606 |
||
607 |
! |
|
608 |
||
609 |
multiplicativeExpression |
|
610 |
||
611 |
^ (unaryExpression , ((multiplicativeOperator , unaryExpression) star)) |
|
612 |
/ ((TokenParser for:#super) , ((multiplicativeOperator , unaryExpression) plus)) |
|
613 |
||
614 |
! |
|
615 |
||
616 |
multiplicativeOperator |
|
617 |
||
618 |
^ ('*' asParser) |
|
619 |
/ ('/' asParser) |
|
620 |
/ ('%' asParser) |
|
621 |
/ ('~/' asParser) |
|
622 |
||
623 |
! |
|
624 |
||
625 |
namedArgument |
|
626 |
||
627 |
^label , constantExpression |
|
628 |
! |
|
629 |
||
630 |
namedConstructorDeclaration |
|
631 |
||
632 |
^identifier , ('.' asParser) , identifier , formalParameterList |
|
633 |
! |
|
634 |
||
635 |
namedFormalParameters |
|
636 |
||
637 |
^('[' asParser) , defaultFormalParameter , (((',' asParser) , defaultFormalParameter) star) , (']' asParser) |
|
638 |
! |
|
639 |
||
640 |
negateOperator |
|
641 |
||
642 |
^ ('!!' asParser) |
|
643 |
/ ('~' asParser) |
|
644 |
||
645 |
! |
|
646 |
||
647 |
nonLabelledStatement |
|
648 |
||
649 |
^ block |
|
650 |
/ (initializedVariableDeclaration , (';' asParser)) |
|
651 |
/ iterationStatement |
|
652 |
/ selectionStatement |
|
653 |
/ tryStatement |
|
654 |
/ ((TokenParser for: #break) , (identifier optional) , (';' asParser)) |
|
655 |
/ ((TokenParser for: #continue) , (identifier optional) , (';' asParser)) |
|
656 |
/ ((TokenParser for: #return) , (constantExpression optional) , (';' asParser)) |
|
657 |
/ ((TokenParser for: #throw) , (constantExpression optional) , (';' asParser)) |
|
658 |
/ ((constantExpression optional) , (';' asParser)) |
|
659 |
/ ((TokenParser for: #assert) , ('(' asParser) , conditionalExpression , (')' asParser) , (';' asParser)) |
|
660 |
/ (functionDeclaration , functionBody) |
|
661 |
||
662 |
"Modified: / 11-01-2013 / 10:09:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
663 |
! |
|
664 |
||
665 |
normalFormalParameter |
|
666 |
||
667 |
^ functionDeclaration |
|
668 |
/ fieldFormalParameter |
|
669 |
/ simpleFormalParameter |
|
670 |
||
671 |
! |
|
672 |
||
673 |
normalFormalParameterTail |
|
674 |
||
675 |
^ ((',' asParser) , namedFormalParameters) |
|
676 |
/ ((',' asParser) , normalFormalParameter , (normalFormalParameterTail optional)) |
|
677 |
||
678 |
! |
|
679 |
||
680 |
postfixExpression |
|
681 |
||
682 |
^ (assignableExpression , postfixOperator) |
|
683 |
/ (primary , (selector star)) |
|
684 |
||
685 |
! |
|
686 |
||
687 |
postfixOperator |
|
688 |
||
689 |
^ ('++' asParser) |
|
690 |
/ ('--' asParser) |
|
691 |
||
692 |
! |
|
693 |
||
694 |
prefixOperator |
|
695 |
||
696 |
^ additiveOperator |
|
697 |
/ negateOperator |
|
698 |
||
699 |
! |
|
700 |
||
701 |
primary |
|
702 |
||
703 |
^ primaryNoFE |
|
704 |
/ primaryFE |
|
705 |
||
706 |
! |
|
707 |
||
708 |
primaryFE |
|
709 |
||
710 |
^ functionExpression |
|
711 |
/ primaryNoFE |
|
712 |
||
713 |
! |
|
714 |
||
715 |
primaryNoFE |
|
716 |
||
717 |
^ (TokenParser for:#this) |
|
718 |
/ ((TokenParser for:#super) , assignableSelector) |
|
719 |
/ literal |
|
720 |
/ identifier |
|
721 |
/ (((TokenParser for:#const) optional) , (typeArguments optional) , compoundLiteral) |
|
722 |
/ (((TokenParser for: #new) / (TokenParser for:#const) ) , type , ((('.' asParser) , identifier) optional) , arguments) |
|
723 |
/ expressionInParentheses |
|
724 |
||
725 |
"Modified: / 11-01-2013 / 10:09:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
726 |
! |
|
727 |
||
728 |
qualified |
|
729 |
||
730 |
^identifier , ((('.' asParser) , identifier) optional) |
|
731 |
! |
|
732 |
||
733 |
redirection |
|
734 |
||
735 |
^(':' asParser) , (TokenParser for:#this) , ((('.' asParser) , identifier) optional) , arguments |
|
736 |
! |
|
737 |
||
738 |
relationalExpression |
|
739 |
||
740 |
^ (shiftExpression , (((isOperator , type) / (relationalOperator , shiftExpression) ) optional)) |
|
741 |
/ ((TokenParser for:#super) , relationalOperator , shiftExpression) |
|
742 |
||
743 |
! |
|
744 |
||
745 |
relationalOperator |
|
746 |
||
747 |
^ (('>' asParser) , ('=' asParser)) |
|
748 |
/ ('>' asParser) |
|
749 |
/ ('<=' asParser) |
|
750 |
/ ('<' asParser) |
|
751 |
||
752 |
! |
|
753 |
||
754 |
returnType |
|
755 |
||
756 |
^ (TokenParser for: #void) |
|
757 |
/ type |
|
758 |
||
759 |
"Modified: / 11-01-2013 / 10:09:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
760 |
! |
|
761 |
||
762 |
selectionStatement |
|
763 |
||
764 |
^ ((TokenParser for: #if) , ('(' asParser) , constantExpression , (')' asParser) , statement , (((TokenParser for: #else) , statement) optional)) |
|
765 |
/ ((TokenParser for: #switch) , ('(' asParser) , constantExpression , (')' asParser) , ('{' asParser) , (switchCase star) , (defaultCase optional) , ('}' asParser)) |
|
766 |
||
767 |
"Modified: / 11-01-2013 / 10:10:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
768 |
! |
|
769 |
||
770 |
selector |
|
771 |
||
772 |
^ assignableSelector |
|
773 |
/ arguments |
|
774 |
||
775 |
! |
|
776 |
||
777 |
shiftExpression |
|
778 |
||
779 |
^ (additiveExpression , ((shiftOperator , additiveExpression) star)) |
|
780 |
/ ((TokenParser for:#super) , ((shiftOperator , additiveExpression) plus)) |
|
781 |
||
782 |
! |
|
783 |
||
784 |
shiftOperator |
|
785 |
||
786 |
^ ('<<' asParser) |
|
787 |
/ (('>' asParser) , ('>' asParser) , ('>' asParser)) |
|
788 |
/ (('>' asParser) , ('>' asParser)) |
|
789 |
||
790 |
! |
|
791 |
||
792 |
simpleFormalParameter |
|
793 |
||
794 |
^ declaredIdentifier |
|
795 |
/ identifier |
|
796 |
||
797 |
! |
|
798 |
||
799 |
sourceUrls |
|
800 |
||
801 |
^(TokenParser for:#string) , (((',' asParser) , (TokenParser for:#string)) star) , ((',' asParser) optional) |
|
802 |
! |
|
803 |
||
804 |
specialSignatureDefinition |
|
805 |
||
806 |
^ (((TokenParser for:#static) optional) , (returnType optional) , getOrSet , identifier , formalParameterList) |
|
807 |
/ ((returnType optional) , (TokenParser for: #operator) , userDefinableOperator , formalParameterList) |
|
808 |
||
809 |
"Modified: / 11-01-2013 / 10:10:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
810 |
! |
|
811 |
||
812 |
statement |
|
813 |
||
814 |
^(label star) , nonLabelledStatement |
|
815 |
! |
|
816 |
||
817 |
statements |
|
818 |
||
819 |
^statement star |
|
820 |
! |
|
821 |
||
822 |
staticFinalDeclaration |
|
823 |
||
824 |
^identifier , ('=' asParser) , constantExpression |
|
825 |
! |
|
826 |
||
827 |
staticFinalDeclarationList |
|
828 |
||
829 |
^staticFinalDeclaration , (((',' asParser) , staticFinalDeclaration) star) |
|
830 |
! |
|
831 |
||
832 |
superCallOrFieldInitializer |
|
833 |
||
834 |
^ ((TokenParser for:#super) , arguments) |
|
835 |
/ ((TokenParser for:#super) , ('.' asParser) , identifier , arguments) |
|
836 |
/ fieldInitializer |
|
837 |
||
838 |
! |
|
839 |
||
840 |
superclass |
|
841 |
||
842 |
^(TokenParser for: #extends) , type |
|
843 |
||
844 |
"Modified: / 11-01-2013 / 10:10:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
845 |
! |
|
846 |
||
847 |
superinterfaces |
|
848 |
||
849 |
^(TokenParser for: #extends) , typeList |
|
850 |
||
851 |
"Modified: / 11-01-2013 / 10:10:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
852 |
! |
|
853 |
||
854 |
switchCase |
|
855 |
||
856 |
^(label optional) , (((TokenParser for:#case) , constantExpression , (':' asParser)) plus) , statements |
|
857 |
! |
|
858 |
||
859 |
topLevelDefinition |
|
860 |
||
861 |
^ classDefinition |
|
862 |
/ interfaceDefinition |
|
863 |
/ functionTypeAlias |
|
864 |
/ (functionDeclaration , functionBodyOrNative) |
|
865 |
/ ((returnType optional) , getOrSet , identifier , formalParameterList , functionBodyOrNative) |
|
866 |
/ ((TokenParser for:#final) , (type optional) , staticFinalDeclarationList , (';' asParser)) |
|
867 |
/ (constInitializedVariableDeclaration , (';' asParser)) |
|
868 |
||
869 |
! |
|
870 |
||
871 |
tryStatement |
|
872 |
||
873 |
^(TokenParser for: #try) , block , (((catchPart plus) , (finallyPart optional)) / finallyPart ) |
|
874 |
||
875 |
"Modified: / 11-01-2013 / 10:10:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
876 |
! |
|
877 |
||
878 |
type |
|
879 |
||
880 |
^qualified , (typeArguments optional) |
|
881 |
! |
|
882 |
||
883 |
typeArguments |
|
884 |
||
885 |
^('<' asParser) , typeList , ('>' asParser) |
|
886 |
! |
|
887 |
||
888 |
typeList |
|
889 |
||
890 |
^type , (((',' asParser) , type) star) |
|
891 |
! |
|
892 |
||
893 |
typeParameter |
|
894 |
||
895 |
^identifier , (((TokenParser for: #extends) , type) optional) |
|
896 |
||
897 |
"Modified: / 11-01-2013 / 10:11:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
898 |
! |
|
899 |
||
900 |
typeParameters |
|
901 |
||
902 |
^('<' asParser) , typeParameter , (((',' asParser) , typeParameter) star) , ('>' asParser) |
|
903 |
! |
|
904 |
||
905 |
unaryExpression |
|
906 |
||
907 |
^ postfixExpression |
|
908 |
/ (prefixOperator , unaryExpression) |
|
909 |
/ (negateOperator , (TokenParser for:#super)) |
|
910 |
/ (('-' asParser) , (TokenParser for:#super)) |
|
911 |
/ (postfixOperator , assignableExpression) |
|
912 |
||
913 |
! |
|
914 |
||
915 |
userDefinableOperator |
|
916 |
||
917 |
^ multiplicativeOperator |
|
918 |
/ additiveOperator |
|
919 |
/ shiftOperator |
|
920 |
/ relationalOperator |
|
921 |
/ bitwiseOperator |
|
922 |
/ ('==' asParser) |
|
923 |
/ ('~' asParser) |
|
924 |
/ (TokenParser for: #negate) |
|
925 |
/ (('[' asParser) , (']' asParser)) |
|
926 |
/ (('[' asParser) , (']' asParser) , ('=' asParser)) |
|
927 |
||
928 |
"Modified: / 11-01-2013 / 10:11:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
929 |
! |
|
930 |
||
931 |
variableDeclaration |
|
932 |
||
933 |
^declaredIdentifier , (((',' asParser) , identifier) star) |
|
934 |
! ! |
|
935 |
||
936 |
!Parser methodsFor:'initialization'! |
|
937 |
||
938 |
initializeStartingAt: aSymbol |
|
939 |
| allVariableNames ignoredVariableNames productionIndexesAndNames debugger | |
|
940 |
self initialize. |
|
941 |
||
942 |
Debugging ifTrue:[ |
|
943 |
PPDebugger notNil ifTrue:[ |
|
944 |
self assert: (Smalltalk loadPackage: 'stx:goodies/petitparser/devtools'). |
|
945 |
debugger := PPDebugger new |
|
946 |
]. |
|
947 |
]. |
|
948 |
"find all the productions that need to be initialized" |
|
949 |
allVariableNames := self class allInstVarNames |
|
950 |
collect: [ :each | each asSymbol ]. |
|
951 |
ignoredVariableNames := self class ignoredNames |
|
952 |
collect: [ :each | each asSymbol ]. |
|
953 |
productionIndexesAndNames := ((1 to: self class instSize) |
|
954 |
collect: [ :index | index -> (allVariableNames at: index) ]) |
|
955 |
reject: [ :assoc | ignoredVariableNames includes: assoc value ]. |
|
956 |
||
957 |
"initialize productions with an undefined parser to be replaced later" |
|
958 |
parser := PPUnresolvedParser named: aSymbol. |
|
959 |
productionIndexesAndNames do: [ :assoc | |
|
960 |
self instVarAt: assoc key put: (PPUnresolvedParser named: assoc value) ]. |
|
961 |
parser def: (self perform: aSymbol). |
|
962 |
||
963 |
"resolve unresolved parsers with their actual implementation" |
|
964 |
productionIndexesAndNames do: [ :assoc | |
|
965 |
(self respondsTo: assoc value) |
|
966 |
ifFalse: [ self error: 'Unable to initialize ' , assoc value printString ] |
|
967 |
ifTrue: [ |
|
968 |
| production | |
|
969 |
production := ((self perform: assoc value) name: assoc value; yourself). |
|
970 |
Debugging ifTrue:[ |
|
971 |
production := PPDebuggingParser parser: production debugger: debugger |
|
972 |
]. |
|
973 |
||
974 |
(self instVarAt: assoc key) def: production. |
|
975 |
||
976 |
] ] |
|
977 |
||
978 |
"Created: / 12-03-2012 / 16:51:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
979 |
"Modified: / 11-01-2013 / 11:35:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
980 |
! ! |
|
981 |
||
1
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
982 |
!Parser::TokenParser class methodsFor:'instance creation'! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
983 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
984 |
for: tokenType |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
985 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
986 |
^self new tokenType: tokenType |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
987 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
988 |
"Created: / 14-03-2012 / 23:10:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
989 |
! ! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
990 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
991 |
!Parser::TokenParser methodsFor:'accessing'! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
992 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
993 |
tokenType |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
994 |
^ tokenType |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
995 |
! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
996 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
997 |
tokenType:aSymbol |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
998 |
tokenType := aSymbol. |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
999 |
! ! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1000 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1001 |
!Parser::TokenParser methodsFor:'parsing'! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1002 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1003 |
parseOn:aJavaScanner |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1004 |
"Parse aStream with the receiving parser and answer the parse-result or an instance of PPFailure. |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1005 |
Override this method in subclasses to specify custom parse behavior. Do not call this method from outside, |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1006 |
instead use #parse:." |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1007 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1008 |
| pos | |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1009 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1010 |
pos := aJavaScanner position. |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1011 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1012 |
^(aJavaScanner nextToken = tokenType) ifTrue:[ |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1013 |
aJavaScanner token |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1014 |
] ifFalse:[ |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1015 |
aJavaScanner position: pos. |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1016 |
PPFailure message: (tokenType printString , ' token expected (got ', aJavaScanner tokenType , ' {',(aJavaScanner tokenValue ? '<nil>') printString,'})') at: aJavaScanner position |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1017 |
] |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1018 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1019 |
"Modified: / 17-03-2012 / 13:34:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1020 |
! ! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1021 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1022 |
!Parser class methodsFor:'documentation'! |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1023 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1024 |
version_HG |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1025 |
|
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1026 |
^ '$Changeset: <not expanded> $' |
46dd2b3b6974
Initial outline of Dart parser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1027 |
! ! |
3 | 1028 |
|
1029 |
Parser initialize! |