compiler/Dart__Parser.st
changeset 2 8fedb5e096fc
parent 1 46dd2b3b6974
child 3 46c322c66a29
equal deleted inserted replaced
1:46dd2b3b6974 2:8fedb5e096fc
     1 "{ Package: 'jv:dart/compiler' }"
     1 "{ Package: 'jv:dart/compiler' }"
     2 
     2 
     3 "{ NameSpace: Dart }"
     3 "{ NameSpace: Dart }"
     4 
     4 
     5 PPCompositeParser subclass:#Parser
     5 PPCompositeParser subclass:#Parser
     6 	instanceVariableNames:''
     6 	instanceVariableNames:'additiveExpression additiveOperator argumentList arguments
       
     7 		assignableExpression assignableSelector assignmentOperator
       
     8 		bitwiseAndExpression bitwiseOperator bitwiseOrExpression
       
     9 		bitwiseXorExpression block catchPart classDefinition
       
    10 		classMemberDefinition compilationUnit compoundLiteral
       
    11 		conditionalExpression constInitializedIdentifier
       
    12 		constInitializedVariableDeclaration
       
    13 		constantConstructorDeclaration constantExpression
       
    14 		constructorDeclaration declaration declaredIdentifier defaultCase
       
    15 		defaultFormalParameter directive equalityExpression
       
    16 		equalityOperator expression expressionInParentheses
       
    17 		expressionList factoryConstructorDeclaration factorySpecification
       
    18 		fieldFormalParameter fieldInitializer finalVarOrType finallyPart
       
    19 		forInitializerStatement forLoopParts formalParameterList
       
    20 		functionBody functionBodyOrNative functionDeclaration
       
    21 		functionExpression functionExpressionBody functionNative
       
    22 		functionPrefix functionTypeAlias getOrSet identifier
       
    23 		importReference importReferences incrementOperator
       
    24 		initializedIdentifier initializedIdentifierList
       
    25 		initializedVariableDeclaration initializers interfaceDefinition
       
    26 		interfaceMemberDefinition interfaces isOperator
       
    27 		iterationStatement label libraryBody libraryDefinition
       
    28 		libraryImport librarySource libraryUnit listLiteral literal
       
    29 		logicalAndExpression logicalOrExpression mapLiteral
       
    30 		mapLiteralEntry methodDeclaration multiplicativeExpression
       
    31 		multiplicativeOperator namedArgument namedConstructorDeclaration
       
    32 		namedFormalParameters negateOperator nonLabelledStatement
       
    33 		normalFormalParameter normalFormalParameterTail postfixExpression
       
    34 		postfixOperator prefixOperator primary primaryFE primaryNoFE
       
    35 		qualified redirection relationalExpression relationalOperator
       
    36 		returnType selectionStatement selector shiftExpression
       
    37 		shiftOperator simpleFormalParameter sourceUrls
       
    38 		specialSignatureDefinition statement statements
       
    39 		staticFinalDeclaration staticFinalDeclarationList
       
    40 		superCallOrFieldInitializer superclass superinterfaces switchCase
       
    41 		topLevelDefinition tryStatement type typeArguments typeList
       
    42 		typeParameter typeParameters unaryExpression
       
    43 		userDefinableOperator variableDeclaration'
     7 	classVariableNames:''
    44 	classVariableNames:''
     8 	poolDictionaries:''
    45 	poolDictionaries:''
     9 	category:'Languages-Dart-Parser'
    46 	category:'Languages-Dart-Parser'
    10 !
    47 !
    11 
    48 
    14 	classVariableNames:''
    51 	classVariableNames:''
    15 	poolDictionaries:''
    52 	poolDictionaries:''
    16 	privateIn:Parser
    53 	privateIn:Parser
    17 !
    54 !
    18 
    55 
       
    56 
       
    57 !Parser methodsFor:'grammar'!
       
    58 
       
    59 additiveExpression
       
    60 
       
    61         ^ (multiplicativeExpression , ((additiveOperator , multiplicativeExpression) star))
       
    62         / ((TokenParser for: #super) , ((additiveOperator , multiplicativeExpression) plus))
       
    63 
       
    64     "Modified: / 11-01-2013 / 09:59:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    65 !
       
    66 
       
    67 additiveOperator
       
    68 
       
    69 	^ ('+' asParser)
       
    70 	/ ('-' asParser)
       
    71 	
       
    72 !
       
    73 
       
    74 argumentList
       
    75 
       
    76 	^ (namedArgument , (((',' asParser) , namedArgument) star))
       
    77 	/ (expressionList , (((',' asParser) , namedArgument) star))
       
    78 	
       
    79 !
       
    80 
       
    81 arguments
       
    82 
       
    83 	^('(' asParser) , (argumentList optional) , (')' asParser)
       
    84 !
       
    85 
       
    86 assignableExpression
       
    87 
       
    88         ^ (primary , (((arguments star) , assignableSelector) plus))
       
    89         / ((TokenParser for: #super) , assignableSelector)
       
    90         / identifier
       
    91 
       
    92     "Modified: / 11-01-2013 / 10:00:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    93 !
       
    94 
       
    95 assignableSelector
       
    96 
       
    97 	^ (('[' asParser) , constantExpression , (']' asParser))
       
    98 	/ (('.' asParser) , identifier)
       
    99 	
       
   100 !
       
   101 
       
   102 assignmentOperator
       
   103 
       
   104 	^ ('=' asParser)
       
   105 	/ ('*=' asParser)
       
   106 	/ ('/=' asParser)
       
   107 	/ ('~/=' asParser)
       
   108 	/ ('%=' asParser)
       
   109 	/ ('+=' asParser)
       
   110 	/ ('-=' asParser)
       
   111 	/ ('<<=' asParser)
       
   112 	/ (('>' asParser) , ('>' asParser) , ('>' asParser) , ('=' asParser))
       
   113 	/ (('>' asParser) , ('>' asParser) , ('=' asParser))
       
   114 	/ ('&=' asParser)
       
   115 	/ ('^=' asParser)
       
   116 	/ ('|=' asParser)
       
   117 	
       
   118 !
       
   119 
       
   120 bitwiseAndExpression
       
   121 
       
   122         ^ (equalityExpression , ((('&' asParser) , equalityExpression) star))
       
   123         / ((TokenParser for: #super) , ((('&' asParser) , equalityExpression) plus))
       
   124 
       
   125     "Modified: / 11-01-2013 / 10:00:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   126 !
       
   127 
       
   128 bitwiseOperator
       
   129 
       
   130 	^ ('&' asParser)
       
   131 	/ ('^' asParser)
       
   132 	/ ('|' asParser)
       
   133 	
       
   134 !
       
   135 
       
   136 bitwiseOrExpression
       
   137 
       
   138 	^ (bitwiseXorExpression , ((('|' asParser) , bitwiseXorExpression) star))
       
   139 	/ ((TokenParser for:#super) , ((('|' asParser) , bitwiseXorExpression) plus))
       
   140 	
       
   141 !
       
   142 
       
   143 bitwiseXorExpression
       
   144 
       
   145 	^ (bitwiseAndExpression , ((('^' asParser) , bitwiseAndExpression) star))
       
   146 	/ ((TokenParser for:#super) , ((('^' asParser) , bitwiseAndExpression) plus))
       
   147 	
       
   148 !
       
   149 
       
   150 block
       
   151 
       
   152 	^('{' asParser) , statements , ('}' asParser)
       
   153 !
       
   154 
       
   155 catchPart
       
   156 
       
   157 	^(TokenParser for:#catch) , ('(' asParser) , declaredIdentifier , (((',' asParser) , declaredIdentifier) optional) , (')' asParser) , block
       
   158 !
       
   159 
       
   160 classDefinition
       
   161 
       
   162 	^ ((TokenParser for:#class) , identifier , (typeParameters optional) , (superclass optional) , (interfaces optional) , ('{' asParser) , (classMemberDefinition star) , ('}' asParser))
       
   163 	/ ((TokenParser for:#class) , identifier , (typeParameters optional) , (interfaces optional) , (TokenParser for:#native) , (TokenParser for:#string) , ('{' asParser) , (classMemberDefinition star) , ('}' asParser))
       
   164 	
       
   165 !
       
   166 
       
   167 classMemberDefinition
       
   168 
       
   169 	^ (declaration , (';' asParser))
       
   170 	/ (constructorDeclaration , (';' asParser))
       
   171 	/ (methodDeclaration , functionBodyOrNative)
       
   172 	/ ((TokenParser for:#const) , factoryConstructorDeclaration , functionNative)
       
   173 	
       
   174 !
       
   175 
       
   176 compilationUnit
       
   177 
       
   178         ^( ((TokenParser for: #'#!!') optional) , (directive star) , (topLevelDefinition star) ) end
       
   179 
       
   180     "Modified: / 11-01-2013 / 10:02:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   181 !
       
   182 
       
   183 compoundLiteral
       
   184 
       
   185 	^ listLiteral
       
   186 	/ mapLiteral
       
   187 	
       
   188 !
       
   189 
       
   190 conditionalExpression
       
   191 
       
   192 	^logicalOrExpression , ((('?' asParser) , constantExpression , (':' asParser) , constantExpression) optional)
       
   193 !
       
   194 
       
   195 constInitializedIdentifier
       
   196 
       
   197 	^identifier , ((('=' asParser) , constantExpression) optional)
       
   198 !
       
   199 
       
   200 constInitializedVariableDeclaration
       
   201 
       
   202 	^declaredIdentifier , ((('=' asParser) , constantExpression) optional) , (((',' asParser) , constInitializedIdentifier) star)
       
   203 !
       
   204 
       
   205 constantConstructorDeclaration
       
   206 
       
   207 	^(TokenParser for:#const) , qualified , formalParameterList
       
   208 !
       
   209 
       
   210 constantExpression
       
   211 
       
   212 	^ (assignableExpression , assignmentOperator , constantExpression)
       
   213 	/ conditionalExpression
       
   214 	
       
   215 !
       
   216 
       
   217 constructorDeclaration
       
   218 
       
   219 	^ (identifier , formalParameterList , ((redirection / initializers ) optional))
       
   220 	/ (namedConstructorDeclaration , ((redirection / initializers ) optional))
       
   221 	
       
   222 !
       
   223 
       
   224 declaration
       
   225 
       
   226 	^ (constantConstructorDeclaration , ((redirection / initializers ) optional))
       
   227 	/ (functionDeclaration , redirection)
       
   228 	/ (namedConstructorDeclaration , redirection)
       
   229 	/ ((TokenParser for:#abstract) , specialSignatureDefinition)
       
   230 	/ ((TokenParser for:#abstract) , functionDeclaration)
       
   231 	/ ((TokenParser for:#static) , (TokenParser for:#final) , (type optional) , staticFinalDeclarationList)
       
   232 	/ (((TokenParser for:#static) optional) , constInitializedVariableDeclaration)
       
   233 	
       
   234 !
       
   235 
       
   236 declaredIdentifier
       
   237 
       
   238 	^ ((TokenParser for:#final) , (type optional) , identifier)
       
   239 	/ ((TokenParser for:#var) , identifier)
       
   240 	/ (type , identifier)
       
   241 	
       
   242 !
       
   243 
       
   244 defaultCase
       
   245 
       
   246 	^(label optional) , (((TokenParser for:#case) , constantExpression , (':' asParser)) star) , (TokenParser for:#default) , (':' asParser) , statements
       
   247 !
       
   248 
       
   249 defaultFormalParameter
       
   250 
       
   251 	^normalFormalParameter , ((('=' asParser) , constantExpression) optional)
       
   252 !
       
   253 
       
   254 directive
       
   255 
       
   256 	^('#' asParser) , identifier , arguments , (';' asParser)
       
   257 !
       
   258 
       
   259 equalityExpression
       
   260 
       
   261 	^ (relationalExpression , ((equalityOperator , relationalExpression) optional))
       
   262 	/ ((TokenParser for:#super) , equalityOperator , relationalExpression)
       
   263 	
       
   264 !
       
   265 
       
   266 equalityOperator
       
   267 
       
   268 	^ ('==' asParser)
       
   269 	/ ('!!=' asParser)
       
   270 	/ ('===' asParser)
       
   271 	/ ('!!==' asParser)
       
   272 	
       
   273 !
       
   274 
       
   275 expressionInParentheses
       
   276 
       
   277 	^('(' asParser) , constantExpression , (')' asParser)
       
   278 !
       
   279 
       
   280 expressionList
       
   281 
       
   282 	^constantExpression , (((',' asParser) , constantExpression) star)
       
   283 !
       
   284 
       
   285 factoryConstructorDeclaration
       
   286 
       
   287 	^(TokenParser for:#factory) , qualified , (typeParameters optional) , ((('.' asParser) , identifier) optional) , formalParameterList
       
   288 !
       
   289 
       
   290 factorySpecification
       
   291 
       
   292 	^(TokenParser for:#factory) , type
       
   293 !
       
   294 
       
   295 fieldFormalParameter
       
   296 
       
   297 	^(finalVarOrType optional) , (TokenParser for:#this) , ('.' asParser) , identifier
       
   298 !
       
   299 
       
   300 fieldInitializer
       
   301 
       
   302 	^(((TokenParser for:#this) , ('.' asParser)) optional) , identifier , ('=' asParser) , conditionalExpression
       
   303 !
       
   304 
       
   305 finalVarOrType
       
   306 
       
   307 	^ ((TokenParser for:#final) , (type optional))
       
   308 	/ (TokenParser for:#var)
       
   309 	/ type
       
   310 	
       
   311 !
       
   312 
       
   313 finallyPart
       
   314 
       
   315 	^(TokenParser for:#finally) , block
       
   316 !
       
   317 
       
   318 forInitializerStatement
       
   319 
       
   320 	^ (initializedVariableDeclaration , (';' asParser))
       
   321 	/ ((constantExpression optional) , (';' asParser))
       
   322 	
       
   323 !
       
   324 
       
   325 forLoopParts
       
   326 
       
   327 	^ (forInitializerStatement , (constantExpression optional) , (';' asParser) , (expressionList optional))
       
   328 	/ (declaredIdentifier , (TokenParser for:#in) , constantExpression)
       
   329 	/ (identifier , (TokenParser for:#in) , constantExpression)
       
   330 	
       
   331 !
       
   332 
       
   333 formalParameterList
       
   334 
       
   335 	^ (('(' asParser) , (namedFormalParameters optional) , (')' asParser))
       
   336 	/ (('(' asParser) , normalFormalParameter , (normalFormalParameterTail optional) , (')' asParser))
       
   337 	
       
   338 !
       
   339 
       
   340 functionBody
       
   341 
       
   342 	^ (('=>' asParser) , constantExpression , (';' asParser))
       
   343 	/ block
       
   344 	
       
   345 !
       
   346 
       
   347 functionBodyOrNative
       
   348 
       
   349 	^ ((TokenParser for:#native) , functionBody)
       
   350 	/ functionNative
       
   351 	/ functionBody
       
   352 	
       
   353 !
       
   354 
       
   355 functionDeclaration
       
   356 
       
   357 	^(returnType optional) , identifier , formalParameterList
       
   358 !
       
   359 
       
   360 functionExpression
       
   361 
       
   362 	^(((returnType optional) , identifier) optional) , formalParameterList , functionExpressionBody
       
   363 !
       
   364 
       
   365 functionExpressionBody
       
   366 
       
   367 	^ (('=>' asParser) , constantExpression)
       
   368 	/ block
       
   369 	
       
   370 !
       
   371 
       
   372 functionNative
       
   373 
       
   374 	^(TokenParser for:#native) , ((TokenParser for:#string) optional) , (';' asParser)
       
   375 !
       
   376 
       
   377 functionPrefix
       
   378 
       
   379 	^(returnType optional) , identifier
       
   380 !
       
   381 
       
   382 functionTypeAlias
       
   383 
       
   384 	^(TokenParser for:#typedef) , functionPrefix , (typeParameters optional) , formalParameterList , (';' asParser)
       
   385 !
       
   386 
       
   387 getOrSet
       
   388 
       
   389 	^ (TokenParser for:#get)
       
   390 	/ (TokenParser for:#set)
       
   391 	
       
   392 !
       
   393 
       
   394 identifier
       
   395 
       
   396 	^ IDENTIFIER_NO_DOLLAR
       
   397 	/ (TokenParser for:#identifier)
       
   398 	/ (TokenParser for:#abstract)
       
   399 	/ ASSERT
       
   400 	/ (TokenParser for:#class)
       
   401 	/ EXTENDS
       
   402 	/ (TokenParser for:#factory)
       
   403 	/ (TokenParser for:#get)
       
   404 	/ (TokenParser for:#implements)
       
   405 	/ (TokenParser for:#import)
       
   406 	/ (TokenParser for:#interface)
       
   407 	/ (TokenParser for:#is)
       
   408 	/ (TokenParser for:#library)
       
   409 	/ (TokenParser for:#native)
       
   410 	/ NEGATE
       
   411 	/ OPERATOR
       
   412 	/ (TokenParser for:#set)
       
   413 	/ (TokenParser for:#source)
       
   414 	/ (TokenParser for:#static)
       
   415 	/ (TokenParser for:#typedef)
       
   416 	
       
   417 !
       
   418 
       
   419 importReference
       
   420 
       
   421 	^(((TokenParser for:#identifier) , (':' asParser)) optional) , (TokenParser for:#string)
       
   422 !
       
   423 
       
   424 importReferences
       
   425 
       
   426 	^importReference , (((',' asParser) , importReference) star) , ((',' asParser) optional)
       
   427 !
       
   428 
       
   429 initializedIdentifier
       
   430 
       
   431 	^identifier , ((('=' asParser) , constantExpression) optional)
       
   432 !
       
   433 
       
   434 initializedIdentifierList
       
   435 
       
   436 	^initializedIdentifier , (((',' asParser) , initializedIdentifier) star)
       
   437 !
       
   438 
       
   439 initializedVariableDeclaration
       
   440 
       
   441 	^declaredIdentifier , ((('=' asParser) , constantExpression) optional) , (((',' asParser) , initializedIdentifier) star)
       
   442 !
       
   443 
       
   444 initializers
       
   445 
       
   446 	^(':' asParser) , superCallOrFieldInitializer , (((',' asParser) , superCallOrFieldInitializer) star)
       
   447 !
       
   448 
       
   449 interfaceDefinition
       
   450 
       
   451 	^(TokenParser for:#interface) , identifier , (typeParameters optional) , (superinterfaces optional) , (factorySpecification optional) , ('{' asParser) , (interfaceMemberDefinition star) , ('}' asParser)
       
   452 !
       
   453 
       
   454 interfaceMemberDefinition
       
   455 
       
   456 	^ ((TokenParser for:#static) , (TokenParser for:#final) , (type optional) , initializedIdentifierList , (';' asParser))
       
   457 	/ (functionDeclaration , (';' asParser))
       
   458 	/ (constantConstructorDeclaration , (';' asParser))
       
   459 	/ (namedConstructorDeclaration , (';' asParser))
       
   460 	/ (specialSignatureDefinition , (';' asParser))
       
   461 	/ (variableDeclaration , (';' asParser))
       
   462 	
       
   463 !
       
   464 
       
   465 interfaces
       
   466 
       
   467 	^(TokenParser for:#implements) , typeList
       
   468 !
       
   469 
       
   470 isOperator
       
   471 
       
   472 	^(TokenParser for:#is) , (('!!' asParser) optional)
       
   473 !
       
   474 
       
   475 iterationStatement
       
   476 
       
   477 	^ ((TokenParser for:#while) , ('(' asParser) , constantExpression , (')' asParser) , statement)
       
   478 	/ ((TokenParser for:#do) , statement , (TokenParser for:#while) , ('(' asParser) , constantExpression , (')' asParser) , (';' asParser))
       
   479 	/ ((TokenParser for:#for) , ('(' asParser) , forLoopParts , (')' asParser) , statement)
       
   480 	
       
   481 !
       
   482 
       
   483 label
       
   484 
       
   485 	^identifier , (':' asParser)
       
   486 !
       
   487 
       
   488 libraryBody
       
   489 
       
   490 	^(libraryImport optional) , (librarySource optional)
       
   491 !
       
   492 
       
   493 libraryDefinition
       
   494 
       
   495 	^(TokenParser for:#library) , ('{' asParser) , libraryBody , ('}' asParser)
       
   496 !
       
   497 
       
   498 libraryImport
       
   499 
       
   500 	^(TokenParser for:#import) , ('=' asParser) , ('[' asParser) , (importReferences optional) , (']' asParser)
       
   501 !
       
   502 
       
   503 librarySource
       
   504 
       
   505 	^(TokenParser for:#source) , ('=' asParser) , ('[' asParser) , (sourceUrls optional) , (']' asParser)
       
   506 !
       
   507 
       
   508 libraryUnit
       
   509 
       
   510         ^libraryDefinition end
       
   511 
       
   512     "Modified: / 11-01-2013 / 10:07:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   513 !
       
   514 
       
   515 listLiteral
       
   516 
       
   517 	^('[' asParser) , ((expressionList , ((',' asParser) optional)) optional) , (']' asParser)
       
   518 !
       
   519 
       
   520 literal
       
   521 
       
   522         ^ (TokenParser for: #null)
       
   523         / (TokenParser for: #true)
       
   524         / (TokenParser for: #false)
       
   525         / (TokenParser for: #number)
       
   526         / (TokenParser for:#string)
       
   527 
       
   528     "Modified: / 11-01-2013 / 10:08:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   529 !
       
   530 
       
   531 logicalAndExpression
       
   532 
       
   533 	^bitwiseOrExpression , ((('&&' asParser) , bitwiseOrExpression) star)
       
   534 !
       
   535 
       
   536 logicalOrExpression
       
   537 
       
   538 	^logicalAndExpression , ((('||' asParser) , logicalAndExpression) star)
       
   539 !
       
   540 
       
   541 mapLiteral
       
   542 
       
   543 	^('{' asParser) , ((mapLiteralEntry , (((',' asParser) , mapLiteralEntry) star) , ((',' asParser) optional)) optional) , ('}' asParser)
       
   544 !
       
   545 
       
   546 mapLiteralEntry
       
   547 
       
   548 	^(TokenParser for:#string) , (':' asParser) , constantExpression
       
   549 !
       
   550 
       
   551 methodDeclaration
       
   552 
       
   553 	^ factoryConstructorDeclaration
       
   554 	/ ((TokenParser for:#static) , functionDeclaration)
       
   555 	/ specialSignatureDefinition
       
   556 	/ (functionDeclaration , (initializers optional))
       
   557 	/ (namedConstructorDeclaration , (initializers optional))
       
   558 	
       
   559 !
       
   560 
       
   561 multiplicativeExpression
       
   562 
       
   563 	^ (unaryExpression , ((multiplicativeOperator , unaryExpression) star))
       
   564 	/ ((TokenParser for:#super) , ((multiplicativeOperator , unaryExpression) plus))
       
   565 	
       
   566 !
       
   567 
       
   568 multiplicativeOperator
       
   569 
       
   570 	^ ('*' asParser)
       
   571 	/ ('/' asParser)
       
   572 	/ ('%' asParser)
       
   573 	/ ('~/' asParser)
       
   574 	
       
   575 !
       
   576 
       
   577 namedArgument
       
   578 
       
   579 	^label , constantExpression
       
   580 !
       
   581 
       
   582 namedConstructorDeclaration
       
   583 
       
   584 	^identifier , ('.' asParser) , identifier , formalParameterList
       
   585 !
       
   586 
       
   587 namedFormalParameters
       
   588 
       
   589 	^('[' asParser) , defaultFormalParameter , (((',' asParser) , defaultFormalParameter) star) , (']' asParser)
       
   590 !
       
   591 
       
   592 negateOperator
       
   593 
       
   594 	^ ('!!' asParser)
       
   595 	/ ('~' asParser)
       
   596 	
       
   597 !
       
   598 
       
   599 nonLabelledStatement
       
   600 
       
   601         ^ block
       
   602         / (initializedVariableDeclaration , (';' asParser))
       
   603         / iterationStatement
       
   604         / selectionStatement
       
   605         / tryStatement
       
   606         / ((TokenParser for: #break) , (identifier optional) , (';' asParser))
       
   607         / ((TokenParser for: #continue) , (identifier optional) , (';' asParser))
       
   608         / ((TokenParser for: #return) , (constantExpression optional) , (';' asParser))
       
   609         / ((TokenParser for: #throw) , (constantExpression optional) , (';' asParser))
       
   610         / ((constantExpression optional) , (';' asParser))
       
   611         / ((TokenParser for: #assert) , ('(' asParser) , conditionalExpression , (')' asParser) , (';' asParser))
       
   612         / (functionDeclaration , functionBody)
       
   613 
       
   614     "Modified: / 11-01-2013 / 10:09:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   615 !
       
   616 
       
   617 normalFormalParameter
       
   618 
       
   619 	^ functionDeclaration
       
   620 	/ fieldFormalParameter
       
   621 	/ simpleFormalParameter
       
   622 	
       
   623 !
       
   624 
       
   625 normalFormalParameterTail
       
   626 
       
   627 	^ ((',' asParser) , namedFormalParameters)
       
   628 	/ ((',' asParser) , normalFormalParameter , (normalFormalParameterTail optional))
       
   629 	
       
   630 !
       
   631 
       
   632 postfixExpression
       
   633 
       
   634 	^ (assignableExpression , postfixOperator)
       
   635 	/ (primary , (selector star))
       
   636 	
       
   637 !
       
   638 
       
   639 postfixOperator
       
   640 
       
   641 	^ ('++' asParser)
       
   642 	/ ('--' asParser)
       
   643 	
       
   644 !
       
   645 
       
   646 prefixOperator
       
   647 
       
   648 	^ additiveOperator
       
   649 	/ negateOperator
       
   650 	
       
   651 !
       
   652 
       
   653 primary
       
   654 
       
   655 	^ primaryNoFE
       
   656 	/ primaryFE
       
   657 	
       
   658 !
       
   659 
       
   660 primaryFE
       
   661 
       
   662 	^ functionExpression
       
   663 	/ primaryNoFE
       
   664 	
       
   665 !
       
   666 
       
   667 primaryNoFE
       
   668 
       
   669         ^ (TokenParser for:#this)
       
   670         / ((TokenParser for:#super) , assignableSelector)
       
   671         / literal
       
   672         / identifier
       
   673         / (((TokenParser for:#const) optional) , (typeArguments optional) , compoundLiteral)
       
   674         / (((TokenParser for: #new) / (TokenParser for:#const) ) , type , ((('.' asParser) , identifier) optional) , arguments)
       
   675         / expressionInParentheses
       
   676 
       
   677     "Modified: / 11-01-2013 / 10:09:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   678 !
       
   679 
       
   680 qualified
       
   681 
       
   682 	^identifier , ((('.' asParser) , identifier) optional)
       
   683 !
       
   684 
       
   685 redirection
       
   686 
       
   687 	^(':' asParser) , (TokenParser for:#this) , ((('.' asParser) , identifier) optional) , arguments
       
   688 !
       
   689 
       
   690 relationalExpression
       
   691 
       
   692 	^ (shiftExpression , (((isOperator , type) / (relationalOperator , shiftExpression) ) optional))
       
   693 	/ ((TokenParser for:#super) , relationalOperator , shiftExpression)
       
   694 	
       
   695 !
       
   696 
       
   697 relationalOperator
       
   698 
       
   699 	^ (('>' asParser) , ('=' asParser))
       
   700 	/ ('>' asParser)
       
   701 	/ ('<=' asParser)
       
   702 	/ ('<' asParser)
       
   703 	
       
   704 !
       
   705 
       
   706 returnType
       
   707 
       
   708         ^ (TokenParser for: #void)
       
   709         / type
       
   710 
       
   711     "Modified: / 11-01-2013 / 10:09:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   712 !
       
   713 
       
   714 selectionStatement
       
   715 
       
   716         ^ ((TokenParser for: #if) , ('(' asParser) , constantExpression , (')' asParser) , statement , (((TokenParser for: #else) , statement) optional))
       
   717         / ((TokenParser for: #switch) , ('(' asParser) , constantExpression , (')' asParser) , ('{' asParser) , (switchCase star) , (defaultCase optional) , ('}' asParser))
       
   718 
       
   719     "Modified: / 11-01-2013 / 10:10:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   720 !
       
   721 
       
   722 selector
       
   723 
       
   724 	^ assignableSelector
       
   725 	/ arguments
       
   726 	
       
   727 !
       
   728 
       
   729 shiftExpression
       
   730 
       
   731 	^ (additiveExpression , ((shiftOperator , additiveExpression) star))
       
   732 	/ ((TokenParser for:#super) , ((shiftOperator , additiveExpression) plus))
       
   733 	
       
   734 !
       
   735 
       
   736 shiftOperator
       
   737 
       
   738 	^ ('<<' asParser)
       
   739 	/ (('>' asParser) , ('>' asParser) , ('>' asParser))
       
   740 	/ (('>' asParser) , ('>' asParser))
       
   741 	
       
   742 !
       
   743 
       
   744 simpleFormalParameter
       
   745 
       
   746 	^ declaredIdentifier
       
   747 	/ identifier
       
   748 	
       
   749 !
       
   750 
       
   751 sourceUrls
       
   752 
       
   753 	^(TokenParser for:#string) , (((',' asParser) , (TokenParser for:#string)) star) , ((',' asParser) optional)
       
   754 !
       
   755 
       
   756 specialSignatureDefinition
       
   757 
       
   758         ^ (((TokenParser for:#static) optional) , (returnType optional) , getOrSet , identifier , formalParameterList)
       
   759         / ((returnType optional) , (TokenParser for: #operator) , userDefinableOperator , formalParameterList)
       
   760 
       
   761     "Modified: / 11-01-2013 / 10:10:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   762 !
       
   763 
       
   764 statement
       
   765 
       
   766 	^(label star) , nonLabelledStatement
       
   767 !
       
   768 
       
   769 statements
       
   770 
       
   771 	^statement star
       
   772 !
       
   773 
       
   774 staticFinalDeclaration
       
   775 
       
   776 	^identifier , ('=' asParser) , constantExpression
       
   777 !
       
   778 
       
   779 staticFinalDeclarationList
       
   780 
       
   781 	^staticFinalDeclaration , (((',' asParser) , staticFinalDeclaration) star)
       
   782 !
       
   783 
       
   784 superCallOrFieldInitializer
       
   785 
       
   786 	^ ((TokenParser for:#super) , arguments)
       
   787 	/ ((TokenParser for:#super) , ('.' asParser) , identifier , arguments)
       
   788 	/ fieldInitializer
       
   789 	
       
   790 !
       
   791 
       
   792 superclass
       
   793 
       
   794         ^(TokenParser for: #extends) , type
       
   795 
       
   796     "Modified: / 11-01-2013 / 10:10:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   797 !
       
   798 
       
   799 superinterfaces
       
   800 
       
   801         ^(TokenParser for: #extends) , typeList
       
   802 
       
   803     "Modified: / 11-01-2013 / 10:10:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   804 !
       
   805 
       
   806 switchCase
       
   807 
       
   808 	^(label optional) , (((TokenParser for:#case) , constantExpression , (':' asParser)) plus) , statements
       
   809 !
       
   810 
       
   811 topLevelDefinition
       
   812 
       
   813 	^ classDefinition
       
   814 	/ interfaceDefinition
       
   815 	/ functionTypeAlias
       
   816 	/ (functionDeclaration , functionBodyOrNative)
       
   817 	/ ((returnType optional) , getOrSet , identifier , formalParameterList , functionBodyOrNative)
       
   818 	/ ((TokenParser for:#final) , (type optional) , staticFinalDeclarationList , (';' asParser))
       
   819 	/ (constInitializedVariableDeclaration , (';' asParser))
       
   820 	
       
   821 !
       
   822 
       
   823 tryStatement
       
   824 
       
   825         ^(TokenParser for: #try) , block , (((catchPart plus) , (finallyPart optional)) / finallyPart )
       
   826 
       
   827     "Modified: / 11-01-2013 / 10:10:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   828 !
       
   829 
       
   830 type
       
   831 
       
   832 	^qualified , (typeArguments optional)
       
   833 !
       
   834 
       
   835 typeArguments
       
   836 
       
   837 	^('<' asParser) , typeList , ('>' asParser)
       
   838 !
       
   839 
       
   840 typeList
       
   841 
       
   842 	^type , (((',' asParser) , type) star)
       
   843 !
       
   844 
       
   845 typeParameter
       
   846 
       
   847         ^identifier , (((TokenParser for: #extends) , type) optional)
       
   848 
       
   849     "Modified: / 11-01-2013 / 10:11:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   850 !
       
   851 
       
   852 typeParameters
       
   853 
       
   854 	^('<' asParser) , typeParameter , (((',' asParser) , typeParameter) star) , ('>' asParser)
       
   855 !
       
   856 
       
   857 unaryExpression
       
   858 
       
   859 	^ postfixExpression
       
   860 	/ (prefixOperator , unaryExpression)
       
   861 	/ (negateOperator , (TokenParser for:#super))
       
   862 	/ (('-' asParser) , (TokenParser for:#super))
       
   863 	/ (postfixOperator , assignableExpression)
       
   864 	
       
   865 !
       
   866 
       
   867 userDefinableOperator
       
   868 
       
   869         ^ multiplicativeOperator
       
   870         / additiveOperator
       
   871         / shiftOperator
       
   872         / relationalOperator
       
   873         / bitwiseOperator
       
   874         / ('==' asParser)
       
   875         / ('~' asParser)
       
   876         / (TokenParser for: #negate)
       
   877         / (('[' asParser) , (']' asParser))
       
   878         / (('[' asParser) , (']' asParser) , ('=' asParser))
       
   879 
       
   880     "Modified: / 11-01-2013 / 10:11:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   881 !
       
   882 
       
   883 variableDeclaration
       
   884 
       
   885 	^declaredIdentifier , (((',' asParser) , identifier) star)
       
   886 ! !
    19 
   887 
    20 !Parser::TokenParser class methodsFor:'instance creation'!
   888 !Parser::TokenParser class methodsFor:'instance creation'!
    21 
   889 
    22 for: tokenType
   890 for: tokenType
    23 
   891