3a1f732c0f
This CL:
* Changes the events so beginX and endX events always comes in pairs
(though technically not right as some specific events can be beginX
endY --- but in those cases it is at least documented and used in code
that actually tests it).
-> This entails adding some events and converting something from
"beginX" to "handleX" instead.
* Adds a utility that can generate an AST of sorts directly from the
parser via a listener using the begin/end matching (and knowing of the
specific ones that doesn't match directly).
* Adds a test that checks that - at least for all tested (50,000+) files
- the AST actually generate "correctly", i.e. matches up begin/ends
and ends up with a single top entry "CompilationUnit".
* Adds a different visualization to the parser listener events by
displaying the "AST directly from the parser" in a UI that can be
navigated. The visualization may not be the best, but it's certainly
a stepping stone.
Change-Id: I9b27f7bbf3be442adc92f357c7b3c46da6f84cf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159664
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
164 lines
9.3 KiB
Plaintext
164 lines
9.3 KiB
Plaintext
parseUnit(class)
|
|
skipErrorTokens(class)
|
|
listener: beginCompilationUnit(class)
|
|
syntheticPreviousToken(class)
|
|
parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext')
|
|
parseMetadataStar()
|
|
listener: beginMetadataStar(class)
|
|
listener: endMetadataStar(0)
|
|
parseTopLevelKeywordDeclaration(, class, Instance of 'DirectiveContext')
|
|
parseClassDeclarationModifiers(, class)
|
|
parseClassOrNamedMixinApplication(null, class)
|
|
listener: beginClassOrNamedMixinApplicationPrelude(class)
|
|
ensureIdentifier(class, classOrMixinDeclaration)
|
|
listener: handleIdentifier(X, classOrMixinDeclaration)
|
|
listener: handleNoTypeVariables({)
|
|
listener: beginClassDeclaration(class, null, X)
|
|
parseClass(X, class, class, X)
|
|
parseClassHeaderOpt(X, class, class)
|
|
parseClassExtendsOpt(X)
|
|
listener: handleNoType(X)
|
|
listener: handleClassExtends(null, 1)
|
|
parseWithClauseOpt(X)
|
|
listener: handleClassNoWithClause()
|
|
parseClassOrMixinImplementsOpt(X)
|
|
listener: handleClassOrMixinImplements(null, 0)
|
|
listener: handleClassHeader(class, class, null)
|
|
parseClassOrMixinOrExtensionBody(X, DeclarationKind.Class, X)
|
|
listener: beginClassOrMixinBody(DeclarationKind.Class, {)
|
|
notEofOrValue(}, late)
|
|
parseClassOrMixinOrExtensionMemberImpl({, DeclarationKind.Class, X)
|
|
parseMetadataStar({)
|
|
listener: beginMetadataStar(late)
|
|
listener: endMetadataStar(0)
|
|
listener: beginMember()
|
|
isReservedKeyword(;)
|
|
parseFields({, null, null, null, null, late, null, late, Instance of 'NoType', x1, DeclarationKind.Class, X, false)
|
|
listener: beginFields({)
|
|
reportRecoverableError(x1, MissingConstFinalVarOrType)
|
|
listener: handleRecoverableError(MissingConstFinalVarOrType, x1, x1)
|
|
listener: handleNoType(late)
|
|
ensureIdentifierPotentiallyRecovered(late, fieldDeclaration, false)
|
|
listener: handleIdentifier(x1, fieldDeclaration)
|
|
parseFieldInitializerOpt(x1, x1, late, null, null, null, DeclarationKind.Class, X)
|
|
listener: handleNoFieldInitializer(;)
|
|
listener: endClassFields(null, null, null, null, late, null, 1, late, ;)
|
|
listener: endMember()
|
|
notEofOrValue(}, static)
|
|
parseClassOrMixinOrExtensionMemberImpl(;, DeclarationKind.Class, X)
|
|
parseMetadataStar(;)
|
|
listener: beginMetadataStar(static)
|
|
listener: endMetadataStar(0)
|
|
listener: beginMember()
|
|
isReservedKeyword(;)
|
|
parseFields(;, null, null, static, null, late, null, late, Instance of 'NoType', x2, DeclarationKind.Class, X, false)
|
|
listener: beginFields(;)
|
|
reportRecoverableError(x2, MissingConstFinalVarOrType)
|
|
listener: handleRecoverableError(MissingConstFinalVarOrType, x2, x2)
|
|
listener: handleNoType(late)
|
|
ensureIdentifierPotentiallyRecovered(late, fieldDeclaration, false)
|
|
listener: handleIdentifier(x2, fieldDeclaration)
|
|
parseFieldInitializerOpt(x2, x2, late, null, null, null, DeclarationKind.Class, X)
|
|
listener: handleNoFieldInitializer(;)
|
|
listener: endClassFields(null, null, static, null, late, null, 1, static, ;)
|
|
listener: endMember()
|
|
notEofOrValue(}, covariant)
|
|
parseClassOrMixinOrExtensionMemberImpl(;, DeclarationKind.Class, X)
|
|
parseMetadataStar(;)
|
|
listener: beginMetadataStar(covariant)
|
|
listener: endMetadataStar(0)
|
|
listener: beginMember()
|
|
isReservedKeyword(;)
|
|
parseFields(;, null, null, null, covariant, late, null, late, Instance of 'NoType', x3, DeclarationKind.Class, X, false)
|
|
listener: beginFields(;)
|
|
reportRecoverableError(x3, MissingConstFinalVarOrType)
|
|
listener: handleRecoverableError(MissingConstFinalVarOrType, x3, x3)
|
|
listener: handleNoType(late)
|
|
ensureIdentifierPotentiallyRecovered(late, fieldDeclaration, false)
|
|
listener: handleIdentifier(x3, fieldDeclaration)
|
|
parseFieldInitializerOpt(x3, x3, late, null, null, null, DeclarationKind.Class, X)
|
|
listener: handleNoFieldInitializer(;)
|
|
listener: endClassFields(null, null, null, covariant, late, null, 1, covariant, ;)
|
|
listener: endMember()
|
|
notEofOrValue(}, late)
|
|
parseClassOrMixinOrExtensionMemberImpl(;, DeclarationKind.Class, X)
|
|
parseMetadataStar(;)
|
|
listener: beginMetadataStar(late)
|
|
listener: endMetadataStar(0)
|
|
listener: beginMember()
|
|
isReservedKeyword(=)
|
|
parseFields(;, null, null, null, null, late, null, late, Instance of 'NoType', x4, DeclarationKind.Class, X, false)
|
|
listener: beginFields(;)
|
|
reportRecoverableError(x4, MissingConstFinalVarOrType)
|
|
listener: handleRecoverableError(MissingConstFinalVarOrType, x4, x4)
|
|
listener: handleNoType(late)
|
|
ensureIdentifierPotentiallyRecovered(late, fieldDeclaration, false)
|
|
listener: handleIdentifier(x4, fieldDeclaration)
|
|
parseFieldInitializerOpt(x4, x4, late, null, null, null, DeclarationKind.Class, X)
|
|
listener: beginFieldInitializer(=)
|
|
parseExpression(=)
|
|
parsePrecedenceExpression(=, 1, true)
|
|
parseUnaryExpression(=, true)
|
|
parsePrimary(=, expression)
|
|
parseLiteralInt(=)
|
|
listener: handleLiteralInt(0)
|
|
listener: endFieldInitializer(=, ;)
|
|
listener: endClassFields(null, null, null, null, late, null, 1, late, ;)
|
|
listener: endMember()
|
|
notEofOrValue(}, static)
|
|
parseClassOrMixinOrExtensionMemberImpl(;, DeclarationKind.Class, X)
|
|
parseMetadataStar(;)
|
|
listener: beginMetadataStar(static)
|
|
listener: endMetadataStar(0)
|
|
listener: beginMember()
|
|
isReservedKeyword(=)
|
|
parseFields(;, null, null, static, null, late, null, late, Instance of 'NoType', x5, DeclarationKind.Class, X, false)
|
|
listener: beginFields(;)
|
|
reportRecoverableError(x5, MissingConstFinalVarOrType)
|
|
listener: handleRecoverableError(MissingConstFinalVarOrType, x5, x5)
|
|
listener: handleNoType(late)
|
|
ensureIdentifierPotentiallyRecovered(late, fieldDeclaration, false)
|
|
listener: handleIdentifier(x5, fieldDeclaration)
|
|
parseFieldInitializerOpt(x5, x5, late, null, null, null, DeclarationKind.Class, X)
|
|
listener: beginFieldInitializer(=)
|
|
parseExpression(=)
|
|
parsePrecedenceExpression(=, 1, true)
|
|
parseUnaryExpression(=, true)
|
|
parsePrimary(=, expression)
|
|
parseLiteralInt(=)
|
|
listener: handleLiteralInt(0)
|
|
listener: endFieldInitializer(=, ;)
|
|
listener: endClassFields(null, null, static, null, late, null, 1, static, ;)
|
|
listener: endMember()
|
|
notEofOrValue(}, covariant)
|
|
parseClassOrMixinOrExtensionMemberImpl(;, DeclarationKind.Class, X)
|
|
parseMetadataStar(;)
|
|
listener: beginMetadataStar(covariant)
|
|
listener: endMetadataStar(0)
|
|
listener: beginMember()
|
|
isReservedKeyword(=)
|
|
parseFields(;, null, null, null, covariant, late, null, late, Instance of 'NoType', x6, DeclarationKind.Class, X, false)
|
|
listener: beginFields(;)
|
|
reportRecoverableError(x6, MissingConstFinalVarOrType)
|
|
listener: handleRecoverableError(MissingConstFinalVarOrType, x6, x6)
|
|
listener: handleNoType(late)
|
|
ensureIdentifierPotentiallyRecovered(late, fieldDeclaration, false)
|
|
listener: handleIdentifier(x6, fieldDeclaration)
|
|
parseFieldInitializerOpt(x6, x6, late, null, null, null, DeclarationKind.Class, X)
|
|
listener: beginFieldInitializer(=)
|
|
parseExpression(=)
|
|
parsePrecedenceExpression(=, 1, true)
|
|
parseUnaryExpression(=, true)
|
|
parsePrimary(=, expression)
|
|
parseLiteralInt(=)
|
|
listener: handleLiteralInt(0)
|
|
listener: endFieldInitializer(=, ;)
|
|
listener: endClassFields(null, null, null, covariant, late, null, 1, covariant, ;)
|
|
listener: endMember()
|
|
notEofOrValue(}, })
|
|
listener: endClassOrMixinBody(DeclarationKind.Class, 6, {, })
|
|
listener: endClassDeclaration(class, })
|
|
listener: endTopLevelDeclaration()
|
|
reportAllErrorTokens(class)
|
|
listener: endCompilationUnit(1, )
|