Class SyntaxToken

java.lang.Object
codeanalysis.syntax.SyntaxNode
codeanalysis.syntax.SyntaxToken

public class SyntaxToken extends SyntaxNode
Represents a token in the code analysis system. It is a syntax node with a specific type, position, data, and value. Tokens are the building blocks of a syntax tree.
Version:
1.0
Author:
Siyabend Urun
See Also:
  • Field Details

  • Constructor Details

    • SyntaxToken

      public SyntaxToken(SyntaxType type, int position, String data, Object value)
      Initializes a new instance of the SyntaxToken class with the specified type, position, data, and value.
      Parameters:
      type - The type of the token.
      position - The position of the token in the source code.
      data - The textual representation of the token.
      value - The value associated with the token.
  • Method Details

    • getType

      public SyntaxType getType()
      Gets the type of the syntax token.
      Specified by:
      getType in class SyntaxNode
      Returns:
      The type of the token.
    • getChildren

      public Iterator<SyntaxNode> getChildren()
      Gets an iterator over the child nodes of the syntax token. Since a token is a leaf node, this iterator will be empty.
      Specified by:
      getChildren in class SyntaxNode
      Returns:
      An empty iterator.
    • getPosition

      public int getPosition()
      Gets the position of the syntax token in the source code.
      Returns:
      The position of the token.
    • setPosition

      public void setPosition(int position)
      Sets the position of the syntax token in the source code.
      Parameters:
      position - The position of the token.
    • getData

      public String getData()
      Gets the textual representation of the syntax token.
      Returns:
      The textual representation of the token.
    • setData

      public void setData(String data)
      Sets the textual representation of the syntax token.
      Parameters:
      data - The textual representation of the token.
    • getValue

      public Object getValue()
      Gets the value associated with the syntax token.
      Returns:
      The value associated with the token.
    • setValue

      public void setValue(Object value)
      Sets the value associated with the syntax token.
      Parameters:
      value - The value associated with the token.
    • getSpan

      public TextSpan getSpan()
      Gets the text span associated with the syntax token.
      Overrides:
      getSpan in class SyntaxNode
      Returns:
      The text span of related syntax token.
    • toString

      public String toString()
      Returns the string representation of the syntax token.
      Overrides:
      toString in class SyntaxNode
      Returns:
      The string representation of the token.