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>
127 lines
7.3 KiB
Plaintext
127 lines
7.3 KiB
Plaintext
parseUnit(void)
|
|
skipErrorTokens(void)
|
|
listener: beginCompilationUnit(void)
|
|
syntheticPreviousToken(void)
|
|
parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext')
|
|
parseMetadataStar()
|
|
listener: beginMetadataStar(void)
|
|
listener: endMetadataStar(0)
|
|
parseTopLevelMemberImpl()
|
|
listener: beginTopLevelMember(void)
|
|
parseTopLevelMethod(, null, , Instance of 'VoidType', null, f, false)
|
|
listener: beginTopLevelMethod(, null)
|
|
listener: handleVoidKeyword(void)
|
|
ensureIdentifierPotentiallyRecovered(void, topLevelFunctionDeclaration, false)
|
|
listener: handleIdentifier(f, topLevelFunctionDeclaration)
|
|
parseMethodTypeVar(f)
|
|
listener: handleNoTypeVariables(()
|
|
parseGetterOrFormalParameters(f, f, false, MemberKind.TopLevelMethod)
|
|
parseFormalParameters(f, MemberKind.TopLevelMethod)
|
|
parseFormalParametersRest((, MemberKind.TopLevelMethod)
|
|
listener: beginFormalParameters((, MemberKind.TopLevelMethod)
|
|
parseFormalParameter((, FormalParameterKind.mandatory, MemberKind.TopLevelMethod)
|
|
parseMetadataStar(()
|
|
listener: beginMetadataStar(dynamic)
|
|
listener: endMetadataStar(0)
|
|
listener: beginFormalParameter(dynamic, MemberKind.TopLevelMethod, null, null, null)
|
|
listener: handleIdentifier(dynamic, typeReference)
|
|
listener: handleNoTypeArguments(sample)
|
|
listener: handleType(dynamic, null)
|
|
ensureIdentifier(dynamic, formalParameterDeclaration)
|
|
listener: handleIdentifier(sample, formalParameterDeclaration)
|
|
listener: handleFormalParameterWithoutValue())
|
|
listener: endFormalParameter(null, null, sample, null, null, FormalParameterKind.mandatory, MemberKind.TopLevelMethod)
|
|
listener: endFormalParameters(1, (, ), MemberKind.TopLevelMethod)
|
|
parseAsyncModifierOpt())
|
|
listener: handleAsyncModifier(null, null)
|
|
inPlainSync()
|
|
parseFunctionBody(), false, false)
|
|
listener: beginBlockFunctionBody({)
|
|
notEofOrValue(}, if)
|
|
parseStatement({)
|
|
parseStatementX({)
|
|
parseIfStatement({)
|
|
listener: beginIfStatement(if)
|
|
ensureParenthesizedCondition(if)
|
|
parseExpressionInParenthesisRest(()
|
|
parseExpression(()
|
|
parsePrecedenceExpression((, 1, true)
|
|
parseUnaryExpression((, true)
|
|
parsePrimary((, expression)
|
|
parseSendOrFunctionLiteral((, expression)
|
|
parseSend((, expression)
|
|
ensureIdentifier((, expression)
|
|
listener: handleIdentifier(sample, expression)
|
|
listener: handleNoTypeArguments(.)
|
|
parseArgumentsOpt(sample)
|
|
listener: handleNoArguments(.)
|
|
listener: handleSend(sample, .)
|
|
parsePrimary(., expressionContinuation)
|
|
parseSendOrFunctionLiteral(., expressionContinuation)
|
|
parseSend(., expressionContinuation)
|
|
ensureIdentifier(., expressionContinuation)
|
|
listener: handleIdentifier(value, expressionContinuation)
|
|
listener: handleNoTypeArguments(!)
|
|
parseArgumentsOpt(value)
|
|
listener: handleNoArguments(!)
|
|
listener: handleSend(value, !)
|
|
listener: handleEndingBinaryExpression(.)
|
|
listener: handleNonNullAssertExpression(!)
|
|
listener: beginBinaryExpression(<)
|
|
parsePrecedenceExpression(<, 9, true)
|
|
parseUnaryExpression(<, true)
|
|
parsePrimary(<, expression)
|
|
parseLiteralInt(<)
|
|
listener: handleLiteralInt(10)
|
|
listener: endBinaryExpression(<)
|
|
ensureCloseParen(10, ()
|
|
listener: handleParenthesizedCondition(()
|
|
listener: beginThenStatement({)
|
|
parseStatement())
|
|
parseStatementX())
|
|
parseBlock(), BlockKind(statement))
|
|
ensureBlock(), null, null)
|
|
listener: beginBlock({, BlockKind(statement))
|
|
notEofOrValue(}, print)
|
|
parseStatement({)
|
|
parseStatementX({)
|
|
parseExpressionStatementOrDeclarationAfterModifiers({, {, null, null, null, false)
|
|
looksLikeLocalFunction(print)
|
|
parseExpressionStatement({)
|
|
parseExpression({)
|
|
parsePrecedenceExpression({, 1, true)
|
|
parseUnaryExpression({, true)
|
|
parsePrimary({, expression)
|
|
parseSendOrFunctionLiteral({, expression)
|
|
looksLikeFunctionBody(;)
|
|
parseSend({, expression)
|
|
ensureIdentifier({, expression)
|
|
listener: handleIdentifier(print, expression)
|
|
listener: handleNoTypeArguments(()
|
|
parseArgumentsOpt(print)
|
|
parseArguments(print)
|
|
parseArgumentsRest(()
|
|
listener: beginArguments(()
|
|
parseExpression(()
|
|
parsePrecedenceExpression((, 1, true)
|
|
parseUnaryExpression((, true)
|
|
parsePrimary((, expression)
|
|
parseLiteralString(()
|
|
parseSingleLiteralString(()
|
|
listener: beginLiteralString('thing!')
|
|
listener: endLiteralString(0, ))
|
|
listener: endArguments(1, (, ))
|
|
listener: handleSend(print, ;)
|
|
ensureSemicolon())
|
|
listener: handleExpressionStatement(;)
|
|
notEofOrValue(}, })
|
|
listener: endBlock(1, {, }, BlockKind(statement))
|
|
listener: endThenStatement(})
|
|
listener: endIfStatement(if, null)
|
|
notEofOrValue(}, })
|
|
listener: endBlockFunctionBody(1, {, })
|
|
listener: endTopLevelMethod(void, null, })
|
|
listener: endTopLevelDeclaration()
|
|
reportAllErrorTokens(void)
|
|
listener: endCompilationUnit(1, )
|