Package codeanalysis.syntax
Class SyntaxToken
java.lang.Object
codeanalysis.syntax.SyntaxNode
codeanalysis.syntax.SyntaxToken
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSyntaxToken(SyntaxType type, int position, String data, Object value) Initializes a new instance of the SyntaxToken class with the specified type, position, data, and value. -
Method Summary
Modifier and TypeMethodDescriptionGets an iterator over the child nodes of the syntax token.getData()Gets the textual representation of the syntax token.intGets the position of the syntax token in the source code.getSpan()Gets the text span associated with the syntax token.getType()Gets the type of the syntax token.getValue()Gets the value associated with the syntax token.voidSets the textual representation of the syntax token.voidsetPosition(int position) Sets the position of the syntax token in the source code.voidSets the value associated with the syntax token.toString()Returns the string representation of the syntax token.Methods inherited from class codeanalysis.syntax.SyntaxNode
writeTo
-
Field Details
-
_span
-
-
Constructor Details
-
SyntaxToken
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
Gets the type of the syntax token.- Specified by:
getTypein classSyntaxNode- Returns:
- The type of the token.
-
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:
getChildrenin classSyntaxNode- 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
Gets the textual representation of the syntax token.- Returns:
- The textual representation of the token.
-
setData
Sets the textual representation of the syntax token.- Parameters:
data- The textual representation of the token.
-
getValue
Gets the value associated with the syntax token.- Returns:
- The value associated with the token.
-
setValue
Sets the value associated with the syntax token.- Parameters:
value- The value associated with the token.
-
getSpan
Gets the text span associated with the syntax token.- Overrides:
getSpanin classSyntaxNode- Returns:
- The text span of related syntax token.
-
toString
Returns the string representation of the syntax token.- Overrides:
toStringin classSyntaxNode- Returns:
- The string representation of the token.
-