TokenBase Class
Represents the base class for an IToken implementation.
public abstract class TokenBase : IToken
- Inheritance:
- Object Object
- Derived:
- MergableToken
- Implements:
- IToken
Constructors
TokenBase(Int32, Int32, TextPosition, TextPosition)
Initializes a new instance of the TokenBase
class.
protected TokenBase(int startOffset, int length, TextPosition startPosition, TextPosition endPosition)
Parameter | Type | Description |
---|---|---|
startOffset | Int32 | The start offset of the token. |
length | Int32 | The length of the token. |
startPosition | TextPosition | The TextPosition of the first character in the token. |
endPosition | TextPosition | The TextPosition after the last character in the token. |
Properties
EndOffset
Gets the offset after the last character in the token.
public int EndOffset { get; }
Property Value
- Int32:
The offset after the last character in the token.
EndPosition
Gets the TextPosition after the last character in the token.
public TextPosition EndPosition { get; }
Property Value
- TextPosition:
The TextPosition after the last character in the token.
Id
Gets the ID assigned to the token.
Key
Gets the key assigned to the token.
Length
Gets or sets the absolute length of the token.
LexicalStateId
Gets the ID assigned to the lexical state that contains the token.
public virtual int LexicalStateId { get; }
Property Value
- Int32:
The ID assigned to the lexical state that contains the token.
PositionRange
Gets a TextPositionRange that specifies the text position range of the token.
public TextPositionRange PositionRange { get; }
Property Value
- TextPositionRange:
A TextPositionRange that specifies the text position range of the token.
StartOffset
Gets or sets the offset of the first character in the token.
public int StartOffset { get; set; }
Property Value
- Int32:
The offset of the first character in the token.
StartPosition
Gets the TextPosition of the first character in the token.
public TextPosition StartPosition { get; }
Property Value
- TextPosition:
The TextPosition of the first character in the token.
TextRange
Gets a TextRange that specifies the text range of the token.
public TextRange TextRange { get; }
Property Value
Methods
Contains(TextPosition)
Returns whether the IToken contains the specified TextPosition.
public bool Contains(TextPosition position)
Parameter | Type | Description |
---|---|---|
position | TextPosition | The TextPosition to examine. |
Returns
- Boolean:
true
if the IToken contains the specified TextPosition; otherwise,false
.
Remarks
This method returns false
if the position falls on the EndPosition position
since this method indicates if the position is encompassed by the IToken.
Contains(Int32)
Returns whether the IToken contains the specified offset.
public bool Contains(int offset)
Parameter | Type | Description |
---|---|---|
offset | Int32 | The offset to examine. |
Returns
Remarks
This method returns false
if the offset falls on the EndOffset offset
since this method indicates if the offset is encompassed by the IToken.
Equals(Object)
Determines whether the specified Object
is equal to the current Object
.
public override bool Equals(object obj)
Parameter | Type | Description |
---|---|---|
obj | Object | The |
Returns
- Boolean:
true
if the specifiedObject
is equal to the currentObject
; otherwise,false
.
GetHashCode()
Returns a hash code for this object.
public override int GetHashCode()
Returns
- Int32:
An integer value that specifies a hash value for this object.
ToString()
Creates and returns a string representation of the current object.
ToString(String)
Creates and returns a string representation of the current object.
public string ToString(string tokenDescription)
Parameter | Type | Description |
---|---|---|
tokenDescription | String | The description of the IToken. |
Returns
- String:
A string representation of the current object.