Struct TokenSymbolHandle
Points to a TokenSymbol of a Grammar.
public readonly struct TokenSymbolHandle : IEquatable<TokenSymbolHandle>
- Implements
- Inherited Members
Remarks
This type is lightweight, storing just a number without a Grammar object and can be of use when parsing. To get any information about the token symbol you have to pass it to the GetTokenSymbol(TokenSymbolHandle) method.
Properties
HasValue
Whether this TokenSymbolHandle has a valid value.
public bool HasValue { get; }
Property Value
- See Also
Value
Gets the token symbol's index in the grammar.
public int Value { get; }
Property Value
Remarks
The first token symbol has a value of zero.
Exceptions
- InvalidOperationException
The token symbol's HasValue property is false.
- See Also
Methods
Equals(TokenSymbolHandle)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(TokenSymbolHandle other)
Parameters
other
TokenSymbolHandleAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Operators
operator ==(TokenSymbolHandle, TokenSymbolHandle)
Checks if two TokenSymbolHandles are pointing to the same row.
public static bool operator ==(TokenSymbolHandle left, TokenSymbolHandle right)
Parameters
left
TokenSymbolHandleThe first handle.
right
TokenSymbolHandleThe second handle.
Returns
Remarks
If left
and right
come
from different Grammars the result is undefined.
explicit operator TokenSymbolHandle(EntityHandle)
Casts an EntityHandle to a TokenSymbolHandle.
public static explicit operator TokenSymbolHandle(EntityHandle handle)
Parameters
handle
EntityHandleThe EntityHandle to cast.
Returns
Exceptions
- InvalidCastException
handle
's IsTokenSymbol property is false.
implicit operator EntityHandle(TokenSymbolHandle)
Implicitly converts a TokenSymbolHandle to an EntityHandle.
public static implicit operator EntityHandle(TokenSymbolHandle handle)
Parameters
handle
TokenSymbolHandleThe TokenSymbolHandle to convert.
Returns
operator !=(TokenSymbolHandle, TokenSymbolHandle)
Checks if two TokenSymbolHandles are not pointing to the same row.
public static bool operator !=(TokenSymbolHandle left, TokenSymbolHandle right)
Parameters
left
TokenSymbolHandleThe first handle.
right
TokenSymbolHandleThe second handle.
Returns
Remarks
If left
and right
come
from different Grammars the result is undefined.