class
GUIStyleSheetLexer
Scans style sheet code and outputs token that can then by used by the parser to parse style sheet code.
Public
Constructors
GUIStyleSheetLexer
Methods
StartScanning
Starts scanning the provided code.
Calling this method starts (or restarts scanning). Returns true if the scanning started successfully.
ScanNextToken
Returns the current token and advances to the next token.
GetErrors
Returns errors that occurred during scanning, if any.
Private
Methods
IsCurrentCharacterNewLine
Checks is the current character a newline character.
IsCurrentCharacter
Checks is the current character the provided character.
GetCurrentCharacter
Returns the current character.
GetCurrentCharacterAndAdvance
Returns the current character and advances to the next character.
GetCurrentCharacterAndAdvance
Reads the current character and compares it to the expected value.
If the value matches the character is output in , stream is advanced to the next character and the method returns true.
If the value does not match the expected character an error is logged and false is returned.
CreateToken
Constructs a new token.
- type
- Type of the token to create.
- takeCharacter
- If true, the current character is consumed and the stream advanced. The token spelling will be the taken character.
Returns: Created token.
CreateToken
Constructs a new token.
- type
- Type of the token to create.
- spelling
- Text that was scanned matching the token.
- takeCharacter
- If true, the current character is consumed and the stream advanced. The token spelling will be appended with the taken character.
Returns: Created token.
CreateToken
Constructs a new token.
- type
- Type of the token to create.
- spelling
- Text that was scanned matching the token.
- sourceCodePosition
- Explicit source code position at which the token is located.
- takeCharacter
- If true, the current character is consumed and the stream advanced. The token spelling will be appended with the taken character.
Returns: Created token.
SkipMatching
Advances the stream as long as the characters are matching the provided predicate (predicate returns true).
SkipWhiteSpaces
Advances the stream until the current character is not a whitespace.
- includeNewLines
- If true, newline are counted as whitespace and will also be skipped.
SaveCurrentSourcePosition
Saves current source code position to be used for any following call using the source code position (e.g. error reporting).
ScanToken
Tries to scan the next token and returns the token if scanning is successful.
Token type will be automatically determined based on the current character.
ScanElementSelectorOrHexColor
Tries to scan the next token as an element selector identifier or a hex color (both starting with #).
Returns null if the scanning failed.
ScanIdentifier
Tries to scan the next token as an identifier.
Returns null if the scanning failed.
ScanStringLiteral
Tries to scan the next token as a string literal (text surrounded by "").
Returns null if the scanning failed.
ScanNumberOrClassSelector
Tries to scan the next token as a number or a class selector.
Assumes the current token is a '.'. Returns null if the scanning failed.
ScanNumber
Tries to scan the next token as a number.
Returns null if the scanning failed.
Error
Records an error message and returns null.
ErrorUnexpected
Records an error message that the current character is unexpected and returns null.
ErrorUnexpected
Records an error message that the current character doesn't match and returns null.