# HG changeset patch # User Jan Vrany # Date 1357911717 0 # Node ID 5ef74750c3bc79febdaca6b456be2fddffe31179 # Parent 46c322c66a29b3cb460603d91b6309fb00491184 - Dart::Parser class: Dart::Parser diff -r 46c322c66a29 -r 5ef74750c3bc compiler/Dart__Parser.st --- a/compiler/Dart__Parser.st Fri Jan 11 13:40:41 2013 +0000 +++ b/compiler/Dart__Parser.st Fri Jan 11 13:41:57 2013 +0000 @@ -54,837 +54,6 @@ ! -!Parser methodsFor:'grammar'! - -additiveExpression - - ^ (multiplicativeExpression , ((additiveOperator , multiplicativeExpression) star)) - / ((TokenParser for: #super) , ((additiveOperator , multiplicativeExpression) plus)) - - "Modified: / 11-01-2013 / 09:59:56 / Jan Vrany " -! - -additiveOperator - - ^ ('+' asParser) - / ('-' asParser) - -! - -argumentList - - ^ (namedArgument , (((',' asParser) , namedArgument) star)) - / (expressionList , (((',' asParser) , namedArgument) star)) - -! - -arguments - - ^('(' asParser) , (argumentList optional) , (')' asParser) -! - -assignableExpression - - ^ (primary , (((arguments star) , assignableSelector) plus)) - / ((TokenParser for: #super) , assignableSelector) - / identifier - - "Modified: / 11-01-2013 / 10:00:12 / Jan Vrany " -! - -assignableSelector - - ^ (('[' asParser) , constantExpression , (']' asParser)) - / (('.' asParser) , identifier) - -! - -assignmentOperator - - ^ ('=' asParser) - / ('*=' asParser) - / ('/=' asParser) - / ('~/=' asParser) - / ('%=' asParser) - / ('+=' asParser) - / ('-=' asParser) - / ('<<=' asParser) - / (('>' asParser) , ('>' asParser) , ('>' asParser) , ('=' asParser)) - / (('>' asParser) , ('>' asParser) , ('=' asParser)) - / ('&=' asParser) - / ('^=' asParser) - / ('|=' asParser) - -! - -bitwiseAndExpression - - ^ (equalityExpression , ((('&' asParser) , equalityExpression) star)) - / ((TokenParser for: #super) , ((('&' asParser) , equalityExpression) plus)) - - "Modified: / 11-01-2013 / 10:00:21 / Jan Vrany " -! - -bitwiseOperator - - ^ ('&' asParser) - / ('^' asParser) - / ('|' asParser) - -! - -bitwiseOrExpression - - ^ (bitwiseXorExpression , ((('|' asParser) , bitwiseXorExpression) star)) - / ((TokenParser for:#super) , ((('|' asParser) , bitwiseXorExpression) plus)) - -! - -bitwiseXorExpression - - ^ (bitwiseAndExpression , ((('^' asParser) , bitwiseAndExpression) star)) - / ((TokenParser for:#super) , ((('^' asParser) , bitwiseAndExpression) plus)) - -! - -block - - ^('{' asParser) , statements , ('}' asParser) -! - -catchPart - - ^(TokenParser for:#catch) , ('(' asParser) , declaredIdentifier , (((',' asParser) , declaredIdentifier) optional) , (')' asParser) , block -! - -classDefinition - - ^ ((TokenParser for:#class) , identifier , (typeParameters optional) , (superclass optional) , (interfaces optional) , ('{' asParser) , (classMemberDefinition star) , ('}' asParser)) - / ((TokenParser for:#class) , identifier , (typeParameters optional) , (interfaces optional) , (TokenParser for:#native) , (TokenParser for:#string) , ('{' asParser) , (classMemberDefinition star) , ('}' asParser)) - -! - -classMemberDefinition - - ^ (declaration , (';' asParser)) - / (constructorDeclaration , (';' asParser)) - / (methodDeclaration , functionBodyOrNative) - / ((TokenParser for:#const) , factoryConstructorDeclaration , functionNative) - -! - -compilationUnit - - ^( ((TokenParser for: #'#!!') optional) , (directive star) , (topLevelDefinition star) ) end - - "Modified: / 11-01-2013 / 10:02:29 / Jan Vrany " -! - -compoundLiteral - - ^ listLiteral - / mapLiteral - -! - -conditionalExpression - - ^logicalOrExpression , ((('?' asParser) , constantExpression , (':' asParser) , constantExpression) optional) -! - -constInitializedIdentifier - - ^identifier , ((('=' asParser) , constantExpression) optional) -! - -constInitializedVariableDeclaration - - ^declaredIdentifier , ((('=' asParser) , constantExpression) optional) , (((',' asParser) , constInitializedIdentifier) star) -! - -constantConstructorDeclaration - - ^(TokenParser for:#const) , qualified , formalParameterList -! - -constantExpression - - ^ (assignableExpression , assignmentOperator , constantExpression) - / conditionalExpression - -! - -constructorDeclaration - - ^ (identifier , formalParameterList , ((redirection / initializers ) optional)) - / (namedConstructorDeclaration , ((redirection / initializers ) optional)) - -! - -declaration - - ^ (constantConstructorDeclaration , ((redirection / initializers ) optional)) - / (functionDeclaration , redirection) - / (namedConstructorDeclaration , redirection) - / ((TokenParser for:#abstract) , specialSignatureDefinition) - / ((TokenParser for:#abstract) , functionDeclaration) - / ((TokenParser for:#static) , (TokenParser for:#final) , (type optional) , staticFinalDeclarationList) - / (((TokenParser for:#static) optional) , constInitializedVariableDeclaration) - -! - -declaredIdentifier - - ^ ((TokenParser for:#final) , (type optional) , identifier) - / ((TokenParser for:#var) , identifier) - / (type , identifier) - -! - -defaultCase - - ^(label optional) , (((TokenParser for:#case) , constantExpression , (':' asParser)) star) , (TokenParser for:#default) , (':' asParser) , statements -! - -defaultFormalParameter - - ^normalFormalParameter , ((('=' asParser) , constantExpression) optional) -! - -directive - - ^('#' asParser) , identifier , arguments , (';' asParser) -! - -equalityExpression - - ^ (relationalExpression , ((equalityOperator , relationalExpression) optional)) - / ((TokenParser for:#super) , equalityOperator , relationalExpression) - -! - -equalityOperator - - ^ ('==' asParser) - / ('!!=' asParser) - / ('===' asParser) - / ('!!==' asParser) - -! - -expressionInParentheses - - ^('(' asParser) , constantExpression , (')' asParser) -! - -expressionList - - ^constantExpression , (((',' asParser) , constantExpression) star) -! - -factoryConstructorDeclaration - - ^(TokenParser for:#factory) , qualified , (typeParameters optional) , ((('.' asParser) , identifier) optional) , formalParameterList -! - -factorySpecification - - ^(TokenParser for:#factory) , type -! - -fieldFormalParameter - - ^(finalVarOrType optional) , (TokenParser for:#this) , ('.' asParser) , identifier -! - -fieldInitializer - - ^(((TokenParser for:#this) , ('.' asParser)) optional) , identifier , ('=' asParser) , conditionalExpression -! - -finalVarOrType - - ^ ((TokenParser for:#final) , (type optional)) - / (TokenParser for:#var) - / type - -! - -finallyPart - - ^(TokenParser for:#finally) , block -! - -forInitializerStatement - - ^ (initializedVariableDeclaration , (';' asParser)) - / ((constantExpression optional) , (';' asParser)) - -! - -forLoopParts - - ^ (forInitializerStatement , (constantExpression optional) , (';' asParser) , (expressionList optional)) - / (declaredIdentifier , (TokenParser for:#in) , constantExpression) - / (identifier , (TokenParser for:#in) , constantExpression) - -! - -formalParameterList - - ^ (('(' asParser) , (namedFormalParameters optional) , (')' asParser)) - / (('(' asParser) , normalFormalParameter , (normalFormalParameterTail optional) , (')' asParser)) - -! - -functionBody - - ^ (('=>' asParser) , constantExpression , (';' asParser)) - / block - -! - -functionBodyOrNative - - ^ ((TokenParser for:#native) , functionBody) - / functionNative - / functionBody - -! - -functionDeclaration - - ^(returnType optional) , identifier , formalParameterList -! - -functionExpression - - ^(((returnType optional) , identifier) optional) , formalParameterList , functionExpressionBody -! - -functionExpressionBody - - ^ (('=>' asParser) , constantExpression) - / block - -! - -functionNative - - ^(TokenParser for:#native) , ((TokenParser for:#string) optional) , (';' asParser) -! - -functionPrefix - - ^(returnType optional) , identifier -! - -functionTypeAlias - - ^(TokenParser for:#typedef) , functionPrefix , (typeParameters optional) , formalParameterList , (';' asParser) -! - -getOrSet - - ^ (TokenParser for:#get) - / (TokenParser for:#set) - -! - -identifier - - ^ IDENTIFIER_NO_DOLLAR - / (TokenParser for:#identifier) - / (TokenParser for:#abstract) - / ASSERT - / (TokenParser for:#class) - / EXTENDS - / (TokenParser for:#factory) - / (TokenParser for:#get) - / (TokenParser for:#implements) - / (TokenParser for:#import) - / (TokenParser for:#interface) - / (TokenParser for:#is) - / (TokenParser for:#library) - / (TokenParser for:#native) - / NEGATE - / OPERATOR - / (TokenParser for:#set) - / (TokenParser for:#source) - / (TokenParser for:#static) - / (TokenParser for:#typedef) - -! - -importReference - - ^(((TokenParser for:#identifier) , (':' asParser)) optional) , (TokenParser for:#string) -! - -importReferences - - ^importReference , (((',' asParser) , importReference) star) , ((',' asParser) optional) -! - -initializedIdentifier - - ^identifier , ((('=' asParser) , constantExpression) optional) -! - -initializedIdentifierList - - ^initializedIdentifier , (((',' asParser) , initializedIdentifier) star) -! - -initializedVariableDeclaration - - ^declaredIdentifier , ((('=' asParser) , constantExpression) optional) , (((',' asParser) , initializedIdentifier) star) -! - -initializers - - ^(':' asParser) , superCallOrFieldInitializer , (((',' asParser) , superCallOrFieldInitializer) star) -! - -interfaceDefinition - - ^(TokenParser for:#interface) , identifier , (typeParameters optional) , (superinterfaces optional) , (factorySpecification optional) , ('{' asParser) , (interfaceMemberDefinition star) , ('}' asParser) -! - -interfaceMemberDefinition - - ^ ((TokenParser for:#static) , (TokenParser for:#final) , (type optional) , initializedIdentifierList , (';' asParser)) - / (functionDeclaration , (';' asParser)) - / (constantConstructorDeclaration , (';' asParser)) - / (namedConstructorDeclaration , (';' asParser)) - / (specialSignatureDefinition , (';' asParser)) - / (variableDeclaration , (';' asParser)) - -! - -interfaces - - ^(TokenParser for:#implements) , typeList -! - -isOperator - - ^(TokenParser for:#is) , (('!!' asParser) optional) -! - -iterationStatement - - ^ ((TokenParser for:#while) , ('(' asParser) , constantExpression , (')' asParser) , statement) - / ((TokenParser for:#do) , statement , (TokenParser for:#while) , ('(' asParser) , constantExpression , (')' asParser) , (';' asParser)) - / ((TokenParser for:#for) , ('(' asParser) , forLoopParts , (')' asParser) , statement) - -! - -label - - ^identifier , (':' asParser) -! - -libraryBody - - ^(libraryImport optional) , (librarySource optional) -! - -libraryDefinition - - ^(TokenParser for:#library) , ('{' asParser) , libraryBody , ('}' asParser) -! - -libraryImport - - ^(TokenParser for:#import) , ('=' asParser) , ('[' asParser) , (importReferences optional) , (']' asParser) -! - -librarySource - - ^(TokenParser for:#source) , ('=' asParser) , ('[' asParser) , (sourceUrls optional) , (']' asParser) -! - -libraryUnit - - ^libraryDefinition end - - "Modified: / 11-01-2013 / 10:07:55 / Jan Vrany " -! - -listLiteral - - ^('[' asParser) , ((expressionList , ((',' asParser) optional)) optional) , (']' asParser) -! - -literal - - ^ (TokenParser for: #null) - / (TokenParser for: #true) - / (TokenParser for: #false) - / (TokenParser for: #number) - / (TokenParser for:#string) - - "Modified: / 11-01-2013 / 10:08:48 / Jan Vrany " -! - -logicalAndExpression - - ^bitwiseOrExpression , ((('&&' asParser) , bitwiseOrExpression) star) -! - -logicalOrExpression - - ^logicalAndExpression , ((('||' asParser) , logicalAndExpression) star) -! - -mapLiteral - - ^('{' asParser) , ((mapLiteralEntry , (((',' asParser) , mapLiteralEntry) star) , ((',' asParser) optional)) optional) , ('}' asParser) -! - -mapLiteralEntry - - ^(TokenParser for:#string) , (':' asParser) , constantExpression -! - -methodDeclaration - - ^ factoryConstructorDeclaration - / ((TokenParser for:#static) , functionDeclaration) - / specialSignatureDefinition - / (functionDeclaration , (initializers optional)) - / (namedConstructorDeclaration , (initializers optional)) - -! - -multiplicativeExpression - - ^ (unaryExpression , ((multiplicativeOperator , unaryExpression) star)) - / ((TokenParser for:#super) , ((multiplicativeOperator , unaryExpression) plus)) - -! - -multiplicativeOperator - - ^ ('*' asParser) - / ('/' asParser) - / ('%' asParser) - / ('~/' asParser) - -! - -namedArgument - - ^label , constantExpression -! - -namedConstructorDeclaration - - ^identifier , ('.' asParser) , identifier , formalParameterList -! - -namedFormalParameters - - ^('[' asParser) , defaultFormalParameter , (((',' asParser) , defaultFormalParameter) star) , (']' asParser) -! - -negateOperator - - ^ ('!!' asParser) - / ('~' asParser) - -! - -nonLabelledStatement - - ^ block - / (initializedVariableDeclaration , (';' asParser)) - / iterationStatement - / selectionStatement - / tryStatement - / ((TokenParser for: #break) , (identifier optional) , (';' asParser)) - / ((TokenParser for: #continue) , (identifier optional) , (';' asParser)) - / ((TokenParser for: #return) , (constantExpression optional) , (';' asParser)) - / ((TokenParser for: #throw) , (constantExpression optional) , (';' asParser)) - / ((constantExpression optional) , (';' asParser)) - / ((TokenParser for: #assert) , ('(' asParser) , conditionalExpression , (')' asParser) , (';' asParser)) - / (functionDeclaration , functionBody) - - "Modified: / 11-01-2013 / 10:09:27 / Jan Vrany " -! - -normalFormalParameter - - ^ functionDeclaration - / fieldFormalParameter - / simpleFormalParameter - -! - -normalFormalParameterTail - - ^ ((',' asParser) , namedFormalParameters) - / ((',' asParser) , normalFormalParameter , (normalFormalParameterTail optional)) - -! - -postfixExpression - - ^ (assignableExpression , postfixOperator) - / (primary , (selector star)) - -! - -postfixOperator - - ^ ('++' asParser) - / ('--' asParser) - -! - -prefixOperator - - ^ additiveOperator - / negateOperator - -! - -primary - - ^ primaryNoFE - / primaryFE - -! - -primaryFE - - ^ functionExpression - / primaryNoFE - -! - -primaryNoFE - - ^ (TokenParser for:#this) - / ((TokenParser for:#super) , assignableSelector) - / literal - / identifier - / (((TokenParser for:#const) optional) , (typeArguments optional) , compoundLiteral) - / (((TokenParser for: #new) / (TokenParser for:#const) ) , type , ((('.' asParser) , identifier) optional) , arguments) - / expressionInParentheses - - "Modified: / 11-01-2013 / 10:09:39 / Jan Vrany " -! - -qualified - - ^identifier , ((('.' asParser) , identifier) optional) -! - -redirection - - ^(':' asParser) , (TokenParser for:#this) , ((('.' asParser) , identifier) optional) , arguments -! - -relationalExpression - - ^ (shiftExpression , (((isOperator , type) / (relationalOperator , shiftExpression) ) optional)) - / ((TokenParser for:#super) , relationalOperator , shiftExpression) - -! - -relationalOperator - - ^ (('>' asParser) , ('=' asParser)) - / ('>' asParser) - / ('<=' asParser) - / ('<' asParser) - -! - -returnType - - ^ (TokenParser for: #void) - / type - - "Modified: / 11-01-2013 / 10:09:53 / Jan Vrany " -! - -selectionStatement - - ^ ((TokenParser for: #if) , ('(' asParser) , constantExpression , (')' asParser) , statement , (((TokenParser for: #else) , statement) optional)) - / ((TokenParser for: #switch) , ('(' asParser) , constantExpression , (')' asParser) , ('{' asParser) , (switchCase star) , (defaultCase optional) , ('}' asParser)) - - "Modified: / 11-01-2013 / 10:10:15 / Jan Vrany " -! - -selector - - ^ assignableSelector - / arguments - -! - -shiftExpression - - ^ (additiveExpression , ((shiftOperator , additiveExpression) star)) - / ((TokenParser for:#super) , ((shiftOperator , additiveExpression) plus)) - -! - -shiftOperator - - ^ ('<<' asParser) - / (('>' asParser) , ('>' asParser) , ('>' asParser)) - / (('>' asParser) , ('>' asParser)) - -! - -simpleFormalParameter - - ^ declaredIdentifier - / identifier - -! - -sourceUrls - - ^(TokenParser for:#string) , (((',' asParser) , (TokenParser for:#string)) star) , ((',' asParser) optional) -! - -specialSignatureDefinition - - ^ (((TokenParser for:#static) optional) , (returnType optional) , getOrSet , identifier , formalParameterList) - / ((returnType optional) , (TokenParser for: #operator) , userDefinableOperator , formalParameterList) - - "Modified: / 11-01-2013 / 10:10:28 / Jan Vrany " -! - -statement - - ^(label star) , nonLabelledStatement -! - -statements - - ^statement star -! - -staticFinalDeclaration - - ^identifier , ('=' asParser) , constantExpression -! - -staticFinalDeclarationList - - ^staticFinalDeclaration , (((',' asParser) , staticFinalDeclaration) star) -! - -superCallOrFieldInitializer - - ^ ((TokenParser for:#super) , arguments) - / ((TokenParser for:#super) , ('.' asParser) , identifier , arguments) - / fieldInitializer - -! - -superclass - - ^(TokenParser for: #extends) , type - - "Modified: / 11-01-2013 / 10:10:38 / Jan Vrany " -! - -superinterfaces - - ^(TokenParser for: #extends) , typeList - - "Modified: / 11-01-2013 / 10:10:45 / Jan Vrany " -! - -switchCase - - ^(label optional) , (((TokenParser for:#case) , constantExpression , (':' asParser)) plus) , statements -! - -topLevelDefinition - - ^ classDefinition - / interfaceDefinition - / functionTypeAlias - / (functionDeclaration , functionBodyOrNative) - / ((returnType optional) , getOrSet , identifier , formalParameterList , functionBodyOrNative) - / ((TokenParser for:#final) , (type optional) , staticFinalDeclarationList , (';' asParser)) - / (constInitializedVariableDeclaration , (';' asParser)) - -! - -tryStatement - - ^(TokenParser for: #try) , block , (((catchPart plus) , (finallyPart optional)) / finallyPart ) - - "Modified: / 11-01-2013 / 10:10:54 / Jan Vrany " -! - -type - - ^qualified , (typeArguments optional) -! - -typeArguments - - ^('<' asParser) , typeList , ('>' asParser) -! - -typeList - - ^type , (((',' asParser) , type) star) -! - -typeParameter - - ^identifier , (((TokenParser for: #extends) , type) optional) - - "Modified: / 11-01-2013 / 10:11:03 / Jan Vrany " -! - -typeParameters - - ^('<' asParser) , typeParameter , (((',' asParser) , typeParameter) star) , ('>' asParser) -! - -unaryExpression - - ^ postfixExpression - / (prefixOperator , unaryExpression) - / (negateOperator , (TokenParser for:#super)) - / (('-' asParser) , (TokenParser for:#super)) - / (postfixOperator , assignableExpression) - -! - -userDefinableOperator - - ^ multiplicativeOperator - / additiveOperator - / shiftOperator - / relationalOperator - / bitwiseOperator - / ('==' asParser) - / ('~' asParser) - / (TokenParser for: #negate) - / (('[' asParser) , (']' asParser)) - / (('[' asParser) , (']' asParser) , ('=' asParser)) - - "Modified: / 11-01-2013 / 10:11:13 / Jan Vrany " -! - -variableDeclaration - - ^declaredIdentifier , (((',' asParser) , identifier) star) -! ! - !Parser class methodsFor:'initialization'! debugging: aBoolean