Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: dart/spec-0.01/extracted
Source used for this grammar: The Dart Team, Dart Programming Language Specification, Draft Version 0.01, October 2011
variableDeclaration
, initializedVariableDeclaration
, initializedIdentifierList
, initializedIdentifier
, declaredIdentifier
, finalVarOrType
, functionSignature
, functionPrefix
, functionBody
, block
, formalParameterList
, normalFormalParameters
, namedFormalParameters
, normalFormalParameter
, simpleFormalParameter
, fieldFormalParameter
, defaultFormalParameter
, classDefinition
, classMemberDefinition
, methodSignature
, declaration
, staticFinalDeclarationList
, staticFinalDeclaration
, operatorSignature
, operator
, unaryOperator
, binaryOperator
, prefixOperator
, negateOperator
, getterSignature
, setterSignature
, constructorSignature
, namedConstructorSignature
, redirection
, initializers
, superCallOrFieldInitializer
, fieldInitializer
, factoryConstructorSignature
, constantConstructorSignature
, superclass
, interfaces
, interfaceDefinition
, interfaceMemberDefinition
, factorySpecification
, superinterfaces
, typeParameter
, typeParameters
, expression
, expressionList
, primary
, literal
, nullLiteral
, numericLiteral
, NUMBER
, EXPONENT
, HEX_NUMBER
, HEX_DIGIT
, booleanLiteral
, stringLiteral
, SINGLE_LINE_STRING
, MULTI_LINE_STRING
, ESCAPE_SEQUENCE
, HEX_DIGIT_SEQUENCE
, STRING_CONTENT_DQ
, STRING_CONTENT_SQ
, NEWLINE
, STRING_INTERPOLATION
, listLiteral
, mapLiteral
, mapLiteralEntry
, functionExpression
, functionExpressionBody
, thisExpression
, newExpression
, constantObjectExpression
, arguments
, argumentList
, namedArgument
, assignmentOperator
, compoundAssignmentOperator
, conditionalExpression
, logicalOrExpression
, logicalAndExpression
, bitwiseOrExpression
, bitwiseXorExpression
, bitwiseAndExpression
, bitwiseOperator
, equalityExpression
, equalityOperator
, relationalExpression
, relationalOperator
, shiftExpression
, shiftOperator
, additiveExpression
, additiveOperator
, multiplicativeExpression
, multiplicativeOperator
, unaryExpression
, prefixExpression
, postfixExpression
, postfixOperator
, incrementOperator
, assignableExpression
, selector
, assignableSelector
, identifier
, IDENTIFIER_NO_DOLLAR
, IDENTIFIER
, BUILT_IN_IDENTIFIER
, IDENTIFIER_START
, IDENTIFIER_START_NO_DOLLAR
, IDENTIFIER_PART_NO_DOLLAR
, IDENTIFIER_PART
, qualified
, isOperator
, statements
, statement
, nonLabelledStatement
, expressionStatement
, ifStatement
, forStatement
, forLoopParts
, forInitializerStatement
, whileStatement
, doStatement
, switchStatement
, switchCase
, defaultCase
, tryStatement
, catchPart
, finallyPart
, returnStatement
, label
, breakStatement
, continueStatement
, throwStatement
, assertStatement
, topLevelDefinition
, getOrSet
, libraryDefinition
, scriptTag
, libraryName
, resource
, libraryImport
, include
, compilationUnit
, scriptDefinition
, type
, typeArguments
, typeList
, functionTypeAlias
, LETTER
, DIGIT
, WHITESPACE
, SINGLE_LINE_COMMENT
, MULTI_LINE_COMMENT
, returnType
), 0 root (—), 8 top (ESCAPE_SEQUENCE
, HEX_DIGIT_SEQUENCE
, libraryDefinition
, compilationUnit
, scriptDefinition
, WHITESPACE
, SINGLE_LINE_COMMENT
, MULTI_LINE_COMMENT
), 3 bottom (typeVariables
, EOF
, declaredIndentifier
2).variableDeclaration ::= declaredIdentifier "," identifier
initializedVariableDeclaration ::= declaredIdentifier "=" expression "," initializedIdentifier
initializedIdentifierList ::= initializedIdentifier "," initializedIdentifier
initializedIdentifier ::= identifier "=" expression
declaredIdentifier ::= finalVarOrType identifier
finalVarOrType ::= "final" type "var" type
functionSignature ::=
returnType
identifier formalParameterListfunctionPrefix ::=
returnType
identifierfunctionBody ::= "=>" expression ";" block
block ::= "{" statements "}"
formalParameterList ::= "(" ")" "(" normalFormalParameters "," namedFormalParameters ")" namedFormalParameters
normalFormalParameters ::= normalFormalParameter "," normalFormalParameter
namedFormalParameters ::= "[" defaultFormalParameter "," defaultFormalParameter "]"
normalFormalParameter ::= functionSignature fieldFormalParameter simpleFormalParameter
simpleFormalParameter ::= declaredIdentifier identifier
fieldFormalParameter ::= finalVarOrType"this" "." identifier
defaultFormalParameter ::= normalFormalParameter "=" expression
classDefinition ::= "class" identifier typeParameters superclass interfaces "{" classMemberDefinition "}"
classMemberDefinition ::=
declaration ";"
methodSignature functionBody
methodSignature ::= factoryConstructorSignature "static" functionSignature getterSignature setterSignature operatorSignature functionSignature initializers namedConstructorSignature initializers
declaration ::= constantConstructorSignature "abstract" getterSignature "abstract" setterSignature "abstract" operatorSignature "abstract" functionSignature "static" "final" type staticFinalDeclarationList "static" initializedVariableDeclarationredirection initializers constructorSignature redirection initializers functionSignature redirection namedConstructorSignature redirection
staticFinalDeclarationList ::= staticFinalDeclaration "," staticFinalDeclaration
staticFinalDeclaration ::=
identifier "=" expression
operatorSignature ::= returnType"operator" operator formalParameterList
operator ::= unaryOperator binaryOperator "[]" "[]=" "negate"
unaryOperator ::= negateOperator
binaryOperator ::= multiplicativeOperator additiveOperator shiftOperator relationalOperator equalityOperator bitwiseOperator
prefixOperator ::= additiveOperator negateOperator
negateOperator ::= "!" "~"
getterSignature ::= "static" returnType "get" identifier formalParameterList
setterSignature ::= "static" returnType "set" identifier formalParameterList
constructorSignature ::= identifier formalParameterList namedConstructorSignature
namedConstructorSignature ::=
identifier "." identifier formalParameterList
redirection ::= ":" "this" "." identifier arguments
initializers ::= ":" superCallOrFieldInitializer "," superCallOrFieldInitializer
superCallOrFieldInitializer ::= "super" arguments "super" "." identifier arguments fieldInitializer
fieldInitializer ::= "this" "." identifier "=" conditionalExpression
factoryConstructorSignature ::= "factory" qualified typeVariables "." identifier formalParameterList
constantConstructorSignature ::=
"const" qualified formalParameterList
superclass ::=
"extends" type
interfaces ::=
"implements" typeList
interfaceDefinition ::= "interface" identifier typeParameters superinterfaces factorySpecification "{" interfaceMemberDefinition "}"
interfaceMemberDefinition ::= "static" "final" type initializedIdentifierList ";" functionSignature ";" constantConstructorSignature ";" namedConstructorSignature ";" getterSignature ";" setterSignature ";" operatorSignature ";" variableDeclaration ";"
factorySpecification ::= "factory" identifier typeParameters
superinterfaces ::=
"extends" typeList
typeParameter ::= identifier "extends" type
typeParameters ::= "<" typeParameter "," typeParameter ">"
expression ::= assignableExpression assignmentOperator expression conditionalExpression
expressionList ::= expression "," expression
primary ::= thisExpression "super" assignableSelector functionExpression literal identifier newExpression constantObjectExpression "(" expression ")"
literal ::= nullLiteral booleanLiteral numericLiteral stringLiteral mapLiteral listLiteral
nullLiteral ::=
"null"
numericLiteral ::= NUMBER HEX_NUMBER
NUMBER ::= DIGIT"." DIGIT EXPONENT "." DIGIT EXPONENT
EXPONENT ::= "e""E" "+""-" DIGIT
HEX_NUMBER ::= "0x" HEX_DIGIT "0X" HEX_DIGIT
HEX_DIGIT ::= "a" "b" "c" "d" "e" "f" "A" "B" "C" "D" "E" "F" DIGIT
booleanLiteral ::= "true" "false"
stringLiteral ::= "@" MULTI_LINE_STRING SINGLE_LINE_STRING
SINGLE_LINE_STRING ::= """ STRING_CONTENT_DQ """ "'" STRING_CONTENT_SQ "'" "@" "'" α "'" "@" """ α """
MULTI_LINE_STRING ::= """"" α """"" "'''" α "'''"
ESCAPE_SEQUENCE ::= "\" "n" "\" "r" "\" "f" "\" "b" "\" "t" "\" "v" "\" "x" HEX_DIGIT HEX_DIGIT "\" "u" HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT "\" "u"
HEX_DIGIT_SEQUENCE ::= HEX_DIGIT HEX_DIGITHEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
STRING_CONTENT_DQ ::=
α
"\" α
STRING_INTERPOLATION
STRING_CONTENT_SQ ::=
α
"\" α
STRING_INTERPOLATION
NEWLINE ::= "\n" "\r"
STRING_INTERPOLATION ::= "$" IDENTIFIER_NO_DOLLAR "$" "{" expression "}"
listLiteral ::= "const" typeArguments "[" expressionList "," "]"
mapLiteral ::= "const" typeArguments "{" mapLiteralEntry "," mapLiteralEntry "," "}"
mapLiteralEntry ::= identifier ":" expression stringLiteral ":" expression
functionExpression ::=returnType identifier formalParameterList functionExpressionBody
functionExpressionBody ::=
"=>" expression
block
thisExpression ::=
"this"
newExpression ::= "new" type "." identifier arguments
constantObjectExpression ::= "const" type "." identifier arguments
arguments ::= "(" argumentList ")"
argumentList ::= namedArgument "," namedArgument expressionList "," namedArgument
namedArgument ::= label expression
assignmentOperator ::=
"="
compoundAssignmentOperator
compoundAssignmentOperator ::= "*=" "/=" "~/=" "%=" "+=" "-=" "<<=" ">" ">" ">" "=" "<" "<" "=" "&=" "^=" "|="
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
bitwiseOperator ::= "&" "^" "|"
equalityExpression ::= relationalExpression "super" equalityOperator relationalExpressionequalityOperator relationalExpression
equalityOperator ::= "==" "!=" "===" "!=="
relationalExpression ::= shiftExpression "super" relationalOperator shiftExpressionisOperator type relationalOperator shiftExpression
relationalOperator ::= ">=" ">" "<=" "<"
shiftExpression ::= additiveExpression "super" shiftOperator additiveExpressionshiftOperator additiveExpression
shiftOperator ::= "<<" ">>>" ">>"
additiveExpression ::= multiplicativeExpression "super" additiveOperator multiplicativeExpressionadditiveOperator multiplicativeExpression
additiveOperator ::= "+" "-"
multiplicativeExpression ::= unaryExpression "super" multiplicativeOperator unaryExpressionmultiplicativeOperator unaryExpression
multiplicativeOperator ::= "*" "/" "%" "~/"
unaryExpression ::= prefixExpression postfixExpression unaryOperator "super" "-" "super" incrementOperator assignableExpression
prefixExpression ::= prefixOperator unaryExpression
postfixExpression ::=
assignableExpression postfixOperator
primary selector
postfixOperator ::= incrementOperator
incrementOperator ::= "++" "--"
assignableExpression ::= primary "super" assignableSelector identifierarguments assignableSelector
selector ::= assignableSelector arguments
assignableSelector ::= "[" expression "]" "." identifier
identifier ::= IDENTIFIER_NO_DOLLAR IDENTIFIER BUILT_IN_IDENTIFIER
IDENTIFIER_NO_DOLLAR ::=
IDENTIFIER_START_NO_DOLLAR IDENTIFIER_PART_NO_DOLLAR
IDENTIFIER ::=
IDENTIFIER_START IDENTIFIER_PART
BUILT_IN_IDENTIFIER ::= "abstract" "assert" "class" "extends" "factory" "get" "implements" "import" "interface" "is" "library" "negate" "operator" "set" "source" "static" "typedef"
IDENTIFIER_START ::=
IDENTIFIER_START_NO_DOLLAR
"$"
IDENTIFIER_START_NO_DOLLAR ::=
LETTER
"_"
IDENTIFIER_PART_NO_DOLLAR ::= IDENTIFIER_START_NO_DOLLAR DIGIT
IDENTIFIER_PART ::= IDENTIFIER_START DIGIT
qualified ::= identifier "." identifier
isOperator ::= "is" "!"
statements ::=
statement
statement ::=
label
nonLabelledStatementnonLabelledStatement ::=
block
initializedVariableDeclaration ";"
forStatement
whileStatement
doStatement
switchStatement
ifStatement
tryStatement
breakStatement
continueStatement
returnStatement
throwStatement
expressionStatement
assertStatement
functionSignature functionBody
expressionStatement ::= expression";"
ifStatement ::= "if" "(" expression ")" statement "else" statement
forStatement ::= "for" "(" forLoopParts ")" statement
forLoopParts ::= forInitializerStatement expression";" expressionList declaredIdentifier "in" expression identifier "in" expression
forInitializerStatement ::= initializedVariableDeclaration ";" expression ";"
whileStatement ::= "while" "(" expression ")" statement
doStatement ::= "do" statement "while" "(" expression ")" ";"
switchStatement ::= "switch" "(" expression ")" "{" switchCase defaultCase "}"
switchCase ::= label"case" expression ":" statements
defaultCase ::= label"case" expression ":" "default" ":" statements
tryStatement ::= "try" block catchPart finallyPart finallyPart
catchPart ::= "catch" "(" declaredIndentifier "," declaredIndentifier ")" block
finallyPart ::=
"finally" block
returnStatement ::= "return" expression ";"
label ::=
identifier ":"
breakStatement ::= "break" identifier ";"
continueStatement ::= "continue" identifier ";"
throwStatement ::= "throw" expression ";"
assertStatement ::= "assert" "(" conditionalExpression ")" ";"
topLevelDefinition ::= classDefinition interfaceDefinition functionTypeAlias functionSignature functionBody returnType"final" type staticFinalDeclarationList ";" variableDeclaration ";"getOrSet identifier formalParameterList functionBody
getOrSet ::= "get" "set"
libraryDefinition ::= scriptTaglibraryName libraryImport include resource topLevelDefinition
scriptTag ::= "#!" α NEWLINE
libraryName ::= "#" "library" "(" stringLiteral ")" ";"
resource ::= "#" "resource" "(" stringLiteral ")" ";"
libraryImport ::= "#" "import" "(" stringLiteral "," "prefix:" stringLiteral ")" ";"
include ::= "#" "source" "(" stringLiteral ")" ";"
compilationUnit ::=
topLevelDefinition
EOFscriptDefinition ::= scriptTaglibraryName libraryImport include resource topLevelDefinition
type ::=
qualified typeArguments
typeArguments ::= "<" typeList ">"
typeList ::= type "," type
functionTypeAlias ::= "typedef" functionPrefix typeParameters formalParameterList ";"
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"
DIGIT ::= "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
WHITESPACE ::= "\t"" " NEWLINE
SINGLE_LINE_COMMENT ::= "//" α NEWLINE
MULTI_LINE_COMMENT ::= "/*" α
returnType ::=
"void"
type