Struct Lexer
Definition
Namespace: StardewUI.Framework.Grammar
Assembly: StardewUI.dll
Consumes raw StarML content as a token stream.
Inheritance
Object ⇦ ValueType ⇦ Lexer
Members
Constructors
Name | Description |
---|---|
Lexer(ReadOnlySpan<Char>) | Consumes raw StarML content as a token stream. |
Properties
Name | Description |
---|---|
Current | The most recent token that was read, if the previous call to MoveNext() was successful; otherwise, an empty token. |
Eof | Whether the lexer is at the end of the content, either at the very end or with only trailing whitespace. |
Position | The current position in the markup text, i.e. the position at the end the Current token. |
Methods
Name | Description |
---|---|
Equals(Object) | (Inherited from ValueType) |
GetEnumerator() | Returns a reference to this Lexer. |
GetHashCode() | (Inherited from ValueType) |
MoveNext() | Reads the next token into Current and advances the Position. |
ReadOptionalToken(TokenType) | Attempts to read the next token and, if successful, validates that it has a specific type. |
ReadRequiredToken(TokenType) | Reads the next token and validates that it has a specific type. |
ToString() | (Inherited from ValueType) |
Details
Constructors
Lexer(ReadOnlySpan<Char>)
Consumes raw StarML content as a token stream.
Parameters
text
ReadOnlySpan<Char>
The markup text.
Properties
Current
The most recent token that was read, if the previous call to MoveNext() was successful; otherwise, an empty token.
Property Value
Eof
Whether the lexer is at the end of the content, either at the very end or with only trailing whitespace.
Property Value
Position
The current position in the markup text, i.e. the position at the end the Current token.
Property Value
Methods
GetEnumerator()
Returns a reference to this Lexer.
Returns
Remarks
Implementing this, along with Current and MoveNext(), allows it to be used in a foreach
loop without having to implement IEnumerable<T>, which is not allowed on a ref struct
.
MoveNext()
Reads the next token into Current and advances the Position.
Returns
true
if a token was read; false
if the end of the content was reached.
ReadOptionalToken(TokenType)
Attempts to read the next token and, if successful, validates that it has a specific type.
Parameters
expectedTypes
TokenType
The TokenTypes allowed for the next token.
Returns
true
if a token was read and was one of the expectedTypes
; false
if the end of the content was reached.
ReadRequiredToken(TokenType)
Reads the next token and validates that it has a specific type.
Parameters
expectedTypes
TokenType
The TokenTypes allowed for the next token.