Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: dart/google/extracted
Source used for this grammar: Google, Inc., Dart subversion repository, Dart.g
, October 2011, bleeding edge branch, revision 14 [Online]
compilationUnit
, HASHBANG
, NEWLINE
, directive
, identifier
, IDENTIFIER_NO_DOLLAR
, IDENTIFIER_START_NO_DOLLAR
, LETTER
, IDENTIFIER_PART_NO_DOLLAR
, DIGIT
, IDENTIFIER
, IDENTIFIER_START
, IDENTIFIER_PART
, ABSTRACT
, ASSERT
, CLASS
, EXTENDS
, FACTORY
, GET
, IMPLEMENTS
, IMPORT
, INTERFACE
, IS
, LIBRARY
, NATIVE
, NEGATE
, OPERATOR
, SET
, SOURCE
, STATIC
, TYPEDEF
, arguments
, argumentList
, namedArgument
, label
, expression
, assignableExpression
, primary
, primaryNoFE
, THIS
, SUPER
, assignableSelector
, literal
, NULL
, TRUE
, FALSE
, HEX_NUMBER
, HEX_DIGIT
, NUMBER
, NUMBER_OPT_FRACTIONAL_PART
, EXPONENT
, NUMBER_OPT_ILLEGAL_END
, STRING
, MULTI_LINE_STRING
, SINGLE_LINE_STRING
, STRING_CONTENT_DQ
, STRING_CONTENT_SQ
, CONST
, typeArguments
, typeList
, type
, qualified
, compoundLiteral
, listLiteral
, expressionList
, mapLiteral
, mapLiteralEntry
, NEW
, expressionInParentheses
, primaryFE
, functionExpression
, returnType
, VOID
, formalParameterList
, namedFormalParameters
, defaultFormalParameter
, normalFormalParameter
, functionDeclaration
, fieldFormalParameter
, finalVarOrType
, FINAL
, VAR
, simpleFormalParameter
, declaredIdentifier
, constantExpression
, normalFormalParameterTail
, functionExpressionBody
, block
, statements
, statement
, nonLabelledStatement
, initializedVariableDeclaration
, initializedIdentifier
, iterationStatement
, WHILE
, DO
, FOR
, forLoopParts
, forInitializerStatement
, IN
, selectionStatement
, IF
, ELSE
, SWITCH
, switchCase
, CASE
, defaultCase
, DEFAULT
, tryStatement
, TRY
, catchPart
, CATCH
, finallyPart
, FINALLY
, BREAK
, CONTINUE
, RETURN
, THROW
, conditionalExpression
, logicalOrExpression
, logicalAndExpression
, bitwiseOrExpression
, bitwiseXorExpression
, bitwiseAndExpression
, equalityExpression
, relationalExpression
, shiftExpression
, additiveExpression
, multiplicativeExpression
, unaryExpression
, postfixExpression
, postfixOperator
, incrementOperator
, selector
, prefixOperator
, additiveOperator
, negateOperator
, multiplicativeOperator
, shiftOperator
, isOperator
, relationalOperator
, equalityOperator
, functionBody
, assignmentOperator
, topLevelDefinition
, classDefinition
, typeParameters
, typeParameter
, superclass
, interfaces
, classMemberDefinition
, declaration
, constantConstructorDeclaration
, redirection
, initializers
, superCallOrFieldInitializer
, fieldInitializer
, namedConstructorDeclaration
, specialSignatureDefinition
, getOrSet
, userDefinableOperator
, bitwiseOperator
, staticFinalDeclarationList
, staticFinalDeclaration
, constInitializedVariableDeclaration
, constInitializedIdentifier
, constructorDeclaration
, methodDeclaration
, factoryConstructorDeclaration
, functionBodyOrNative
, functionNative
, interfaceDefinition
, superinterfaces
, factorySpecification
, interfaceMemberDefinition
, initializedIdentifierList
, variableDeclaration
, functionTypeAlias
, functionPrefix
, libraryUnit
, libraryDefinition
, libraryBody
, libraryImport
, importReferences
, importReference
, librarySource
, sourceUrls
), 2 root (compilationUnit
, libraryUnit
), 0 top (—), 1 bottom (EOF
2).compilationUnit ::= HASHBANGdirective topLevelDefinition EOF
HASHBANG ::= "#!" α NEWLINE
NEWLINE ::= "\n" "\r"
directive ::= "#" identifier arguments ";"
identifier ::= IDENTIFIER_NO_DOLLAR IDENTIFIER ABSTRACT ASSERT CLASS EXTENDS FACTORY GET IMPLEMENTS IMPORT INTERFACE IS LIBRARY NATIVE NEGATE OPERATOR SET SOURCE STATIC TYPEDEF
IDENTIFIER_NO_DOLLAR ::=
IDENTIFIER_START_NO_DOLLAR IDENTIFIER_PART_NO_DOLLAR
IDENTIFIER_START_NO_DOLLAR ::=
LETTER
"_"
LETTER ::= "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"
IDENTIFIER_PART_NO_DOLLAR ::= IDENTIFIER_START_NO_DOLLAR DIGIT
DIGIT ::= "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
IDENTIFIER ::=
IDENTIFIER_START IDENTIFIER_PART
IDENTIFIER_START ::=
IDENTIFIER_START_NO_DOLLAR
"$"
IDENTIFIER_PART ::= IDENTIFIER_START DIGIT
ABSTRACT ::=
"abstract"
ASSERT ::=
"assert"
CLASS ::=
"class"
EXTENDS ::=
"extends"
FACTORY ::=
"factory"
GET ::=
"get"
IMPLEMENTS ::=
"implements"
IMPORT ::=
"import"
INTERFACE ::=
"interface"
IS ::=
"is"
LIBRARY ::=
"library"
NATIVE ::=
"native"
NEGATE ::=
"negate"
OPERATOR ::=
"operator"
SET ::=
"set"
SOURCE ::=
"source"
STATIC ::=
"static"
TYPEDEF ::=
"typedef"
arguments ::= "(" argumentList ")"
argumentList ::= namedArgument "," namedArgument expressionList "," namedArgument
namedArgument ::= label expression
label ::=
identifier ":"
expression ::= assignableExpression assignmentOperator expression conditionalExpression
assignableExpression ::= primaryarguments assignableSelector SUPER assignableSelector identifier
primary ::= primaryNoFE primaryFE
primaryNoFE ::= THIS SUPER assignableSelector literal identifier CONST"." identifier arguments expressionInParenthesestypeArguments compoundLiteral NEW CONST type
THIS ::=
"this"
SUPER ::=
"super"
assignableSelector ::= "[" expression "]" "." identifier
literal ::= NULL TRUE FALSE HEX_NUMBER NUMBER STRING
NULL ::=
"null"
TRUE ::=
"true"
FALSE ::=
"false"
HEX_NUMBER ::= "0x" HEX_DIGIT "0X" HEX_DIGIT
HEX_DIGIT ::= "a" "b" "c" "d" "e" "f" "A" "B" "C" "D" "E" "F" DIGIT
NUMBER ::= DIGIT"." DIGIT EXPONENT NUMBER_OPT_ILLEGAL_ENDNUMBER_OPT_FRACTIONAL_PART EXPONENT NUMBER_OPT_ILLEGAL_END
NUMBER_OPT_FRACTIONAL_PART ::= "." DIGIT ε
EXPONENT ::= "e""E" "+""-" DIGIT
NUMBER_OPT_ILLEGAL_END ::= ε
STRING ::= "@" MULTI_LINE_STRING SINGLE_LINE_STRING
MULTI_LINE_STRING ::= """"" α """"" "\'\'\'" α "\'\'\'"
SINGLE_LINE_STRING ::= """ STRING_CONTENT_DQ """ "\'" STRING_CONTENT_SQ "\'" "@" "\'" α "\'" "@" """ α """
STRING_CONTENT_DQ ::=
α
"\\" α
STRING_CONTENT_SQ ::=
α
"\\" α
CONST ::=
"const"
typeArguments ::= "<" typeList ">"
typeList ::= type "," type
type ::=
qualified typeArguments
qualified ::= identifier "." identifier
compoundLiteral ::= listLiteral mapLiteral
listLiteral ::= "[" expressionList "," "]"
expressionList ::= expression "," expression
mapLiteral ::= "{" mapLiteralEntry "," mapLiteralEntry "," "}"
mapLiteralEntry ::=
STRING ":" expression
NEW ::=
"new"
expressionInParentheses ::= "(" expression ")"
primaryFE ::= functionExpression primaryNoFE
functionExpression ::=returnType identifier formalParameterList functionExpressionBody
returnType ::= VOID type
VOID ::=
"void"
formalParameterList ::= "(" namedFormalParameters ")" "(" normalFormalParameter normalFormalParameterTail ")"
namedFormalParameters ::= "[" defaultFormalParameter "," defaultFormalParameter "]"
defaultFormalParameter ::= normalFormalParameter "=" constantExpression
normalFormalParameter ::= functionDeclaration fieldFormalParameter simpleFormalParameter
functionDeclaration ::=
returnType
identifier formalParameterListfieldFormalParameter ::= finalVarOrType"." identifierTHIS
finalVarOrType ::=
FINAL type
VAR
typeFINAL ::=
"final"
VAR ::=
"var"
simpleFormalParameter ::= declaredIdentifier identifier
declaredIdentifier ::=
FINAL type
identifier
VAR identifier
type identifierconstantExpression ::= expression
normalFormalParameterTail ::= "," namedFormalParameters "," normalFormalParameter normalFormalParameterTail
functionExpressionBody ::=
"=>" expression
block
block ::= "{" statements "}"
statements ::=
statement
statement ::=
label
nonLabelledStatementnonLabelledStatement ::= block initializedVariableDeclaration ";" iterationStatement selectionStatement tryStatement BREAK identifier ";" CONTINUE identifier ";" RETURN expression ";" THROW expression ";" expression ";" ASSERT "(" conditionalExpression ")" ";" functionDeclaration functionBody
initializedVariableDeclaration ::= declaredIdentifier "=" expression "," initializedIdentifier
initializedIdentifier ::= identifier "=" expression
iterationStatement ::= WHILE "(" expression ")" statement DO statement WHILE "(" expression ")" ";" FOR "(" forLoopParts ")" statement
WHILE ::=
"while"
DO ::=
"do"
FOR ::=
"for"
forLoopParts ::= forInitializerStatement expression";" expressionList declaredIdentifier IN expression identifier IN expression
forInitializerStatement ::= initializedVariableDeclaration ";" expression ";"
IN ::=
"in"
selectionStatement ::= IF "(" expression ")" statement ELSE statement SWITCH "(" expression ")" "{" switchCase defaultCase "}"
IF ::=
"if"
ELSE ::=
"else"
SWITCH ::=
"switch"
switchCase ::= label":" statementsCASE expression
CASE ::=
"case"
defaultCase ::= label":" DEFAULT ":" statementsCASE expression
DEFAULT ::=
"default"
tryStatement ::= TRY blockcatchPart finallyPart finallyPart
TRY ::=
"try"
catchPart ::= CATCH "(" declaredIdentifier "," declaredIdentifier ")" block
CATCH ::=
"catch"
finallyPart ::= FINALLY block
FINALLY ::=
"finally"
BREAK ::=
"break"
CONTINUE ::=
"continue"
RETURN ::=
"return"
THROW ::=
"throw"
conditionalExpression ::= logicalOrExpression "?" expression ":" expression
logicalOrExpression ::= logicalAndExpression "||" logicalAndExpression
logicalAndExpression ::= bitwiseOrExpression "&&" bitwiseOrExpression
bitwiseOrExpression ::= bitwiseXorExpression "|" bitwiseXorExpression SUPER "|" bitwiseXorExpression
bitwiseXorExpression ::= bitwiseAndExpression "^" bitwiseAndExpression SUPER "^" bitwiseAndExpression
bitwiseAndExpression ::= equalityExpression "&" equalityExpression SUPER "&" equalityExpression
equalityExpression ::= relationalExpressionequalityOperator relationalExpression SUPER equalityOperator relationalExpression
relationalExpression ::= shiftExpressionisOperator type relationalOperator shiftExpression SUPER relationalOperator shiftExpression
shiftExpression ::= additiveExpressionshiftOperator additiveExpression SUPER shiftOperator additiveExpression
additiveExpression ::= multiplicativeExpressionadditiveOperator multiplicativeExpression SUPER additiveOperator multiplicativeExpression
multiplicativeExpression ::= unaryExpressionmultiplicativeOperator unaryExpression SUPER multiplicativeOperator unaryExpression
unaryExpression ::=
postfixExpression
prefixOperator unaryExpression
negateOperator SUPER
"-" SUPER
incrementOperator assignableExpression
postfixExpression ::=
assignableExpression postfixOperator
primary selector
postfixOperator ::= incrementOperator
incrementOperator ::= "++" "--"
selector ::= assignableSelector arguments
prefixOperator ::= additiveOperator negateOperator
additiveOperator ::= "+" "-"
negateOperator ::= "!" "~"
multiplicativeOperator ::= "*" "/" "%" "~/"
shiftOperator ::= "<<" ">>>" ">>"
isOperator ::= IS "!"
relationalOperator ::= ">=" ">" "<=" "<"
equalityOperator ::= "==" "!=" "===" "!=="
functionBody ::= "=>" expression ";" block
assignmentOperator ::= "=" "*=" "/=" "~/=" "%=" "+=" "-=" "<<=" ">>>=" ">>=" "&=" "^=" "|="
topLevelDefinition ::= classDefinition interfaceDefinition functionTypeAlias functionDeclaration functionBodyOrNative returnType";" constInitializedVariableDeclaration ";"getOrSet identifier formalParameterList functionBodyOrNative FINAL type staticFinalDeclarationList
classDefinition ::= CLASS identifier typeParameters"{" classMemberDefinition "}" CLASS identifier typeParameters interfaces NATIVE STRING "{" classMemberDefinition "}"superclass interfaces
typeParameters ::= "<" typeParameter "," typeParameter ">"
typeParameter ::= identifierEXTENDS type
superclass ::= EXTENDS type
interfaces ::= IMPLEMENTS typeList
classMemberDefinition ::= declaration ";" constructorDeclaration ";" methodDeclaration functionBodyOrNative CONST factoryConstructorDeclaration functionNative
declaration ::= constantConstructorDeclarationredirection initializers functionDeclaration redirection namedConstructorDeclaration redirection ABSTRACT specialSignatureDefinition ABSTRACT functionDeclaration STATIC FINAL type staticFinalDeclarationList STATIC constInitializedVariableDeclaration
constantConstructorDeclaration ::= CONST qualified formalParameterList
redirection ::= ":" THIS "." identifier arguments
initializers ::= ":" superCallOrFieldInitializer "," superCallOrFieldInitializer
superCallOrFieldInitializer ::=
SUPER arguments
SUPER "." identifier arguments
fieldInitializer
fieldInitializer ::= "." identifier "=" conditionalExpressionTHIS
namedConstructorDeclaration ::=
identifier "." identifier formalParameterList
specialSignatureDefinition ::= STATICreturnType getOrSet identifier formalParameterList returnType OPERATOR userDefinableOperator formalParameterList
getOrSet ::= GET SET
userDefinableOperator ::= multiplicativeOperator additiveOperator shiftOperator relationalOperator bitwiseOperator "==" "~" NEGATE "[" "]" "[" "]" "="
bitwiseOperator ::= "&" "^" "|"
staticFinalDeclarationList ::= staticFinalDeclaration "," staticFinalDeclaration
staticFinalDeclaration ::=
identifier "=" constantExpression
constInitializedVariableDeclaration ::= declaredIdentifier "=" constantExpression "," constInitializedIdentifier
constInitializedIdentifier ::= identifier "=" constantExpression
constructorDeclaration ::= identifier formalParameterListredirection initializers namedConstructorDeclaration redirection initializers
methodDeclaration ::= factoryConstructorDeclaration STATIC functionDeclaration specialSignatureDefinition functionDeclaration initializersnamedConstructorDeclaration initializers
factoryConstructorDeclaration ::= FACTORY qualified typeParameters"." identifier formalParameterList
functionBodyOrNative ::= NATIVE functionBody functionNative functionBody
functionNative ::= NATIVE STRING";"
interfaceDefinition ::= INTERFACE identifier typeParameters"{" interfaceMemberDefinition "}"superinterfaces factorySpecification
superinterfaces ::= EXTENDS typeList
factorySpecification ::= FACTORY type
interfaceMemberDefinition ::= STATIC FINAL type";" functionDeclaration ";" constantConstructorDeclaration ";" namedConstructorDeclaration ";" specialSignatureDefinition ";" variableDeclaration ";"initializedIdentifierList
initializedIdentifierList ::= initializedIdentifier "," initializedIdentifier
variableDeclaration ::= declaredIdentifier "," identifier
functionTypeAlias ::= TYPEDEF functionPrefix typeParameters";"formalParameterList
functionPrefix ::=
returnType
identifierlibraryUnit ::= libraryDefinition EOF
libraryDefinition ::= LIBRARY "{" libraryBody "}"
libraryBody ::= libraryImportlibrarySource
libraryImport ::= IMPORT "=" "[" importReferences "]"
importReferences ::= importReference "," importReference ","
importReference ::= ":" STRINGIDENTIFIER
librarySource ::= SOURCE "=" "[" sourceUrls "]"
sourceUrls ::= STRING "," STRING ","