Package codeanalysis.syntax
Class SyntaxTree
java.lang.Object
codeanalysis.syntax.SyntaxTree
Represents a syntax tree in the code analysis system.
It consists of an expression syntax node as the root and an end-of-file token.
The syntax tree provides access to diagnostics and allows parsing of source code text.
- Version:
- 1.0
- Author:
- Siyabend Urun
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSyntaxTree(SourceText text, DiagnosticBox diagnostics, ExpressionSyntax root, SyntaxToken EOFToken) Initializes a new instance of the SyntaxTree class with the specified diagnostics, root expression syntax, and end-of-file token. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves an iterator over the diagnostics produced during parsing.getRoot()Gets the root expression syntax node of the syntax tree.getText()Gets the source text of the syntax tree.static SyntaxTreeparse(SourceText text) Parses the specified source code text and returns the corresponding syntax tree.static SyntaxTreeParses the specified source code text and returns the corresponding syntax tree.static Iterable<SyntaxToken>parseTokens(SourceText text) Parses the specified source code text and returns the corresponding tokens.static Iterable<SyntaxToken>parseTokens(String text) Parses the specified source code text and returns the corresponding tokens.
-
Constructor Details
-
SyntaxTree
public SyntaxTree(SourceText text, DiagnosticBox diagnostics, ExpressionSyntax root, SyntaxToken EOFToken) Initializes a new instance of the SyntaxTree class with the specified diagnostics, root expression syntax, and end-of-file token.- Parameters:
text- The source text of the syntax tree.diagnostics- The list of diagnostics produced during parsing.root- The root expression syntax node of the syntax tree.EOFToken- The end-of-file token indicating the completion of parsing.
-
-
Method Details
-
diagnostics
Retrieves an iterator over the diagnostics produced during parsing.- Returns:
- An iterator over the diagnostics.
-
getRoot
Gets the root expression syntax node of the syntax tree.- Returns:
- The root expression syntax node.
-
getText
Gets the source text of the syntax tree.- Returns:
- The source text.
-
parse
Parses the specified source code text and returns the corresponding syntax tree.- Parameters:
text- The source code text to be parsed.- Returns:
- The syntax tree representing the parsed source code.
-
parse
Parses the specified source code text and returns the corresponding syntax tree.- Parameters:
text- The source code text to be parsed.- Returns:
- The syntax tree representing the parsed source code.
-
parseTokens
Parses the specified source code text and returns the corresponding tokens.- Parameters:
text- The text to be parsed.- Returns:
- The tokens representing the parsed source code.
-
parseTokens
Parses the specified source code text and returns the corresponding tokens.- Parameters:
text- The source code text to be parsed.- Returns:
- The tokens representing the parsed source code.
-