Class SyntaxTree

java.lang.Object
codeanalysis.syntax.SyntaxTree

public final class SyntaxTree extends Object
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 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

      public DiagnosticBox diagnostics()
      Retrieves an iterator over the diagnostics produced during parsing.
      Returns:
      An iterator over the diagnostics.
    • getRoot

      public ExpressionSyntax getRoot()
      Gets the root expression syntax node of the syntax tree.
      Returns:
      The root expression syntax node.
    • getText

      public SourceText getText()
      Gets the source text of the syntax tree.
      Returns:
      The source text.
    • parse

      public static SyntaxTree parse(String text)
      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

      public static SyntaxTree parse(SourceText text)
      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

      public static Iterable<SyntaxToken> parseTokens(String text)
      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

      public static Iterable<SyntaxToken> parseTokens(SourceText text)
      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.