namespace sys.core
class AsciiParser
this{ref data: Slice};
this{ref data: String};
this{data: String, skipSpaces: Bool};
Constructs a new parser based on n input buffer. The buffer is not copied over so its lifespan must exceed the lifespan of the parser instance.
data=> the data to parse
skipSpaces=>
def EatSpaces(): Bool;
Attempts to consume whitespace and comments. If there was nothing to consume, the state of the parser is not changed.
true if anything was consumed
def EatSpacesNoLineSkip(): Bool;
func IsId(): Bool;
func IsId(id: String): Bool;
Checks if the parser sees an identifier. Identifiers use "C" rules.
id=> the identifier to search for
`true` if the identifier was found
def EatId(id: String): Bool;
Attempts to consume a given identifier. If the identifier was not found, the state of the parser is not changed.
id=> the identifier to search for
`true` if something was consumed
def ReadId(): String;
Attempt to read and consume an identifier. Should be used ideally after `IsId`.
the read identifier
func Peek(): Char;
Peeks into the buffer and returns the next byte without changing the state of the parser.
the next byte
func IsChar(c: Char): Bool;
func IsChar(c1: Char, c2: Char): Bool;
func IsChar(c1: Char, c2: Char, c3: Char): Bool;
Checks if the next 1-3 bytes in the parser are the input ones. Does not alter the state of the parser.
c=> the first byte to check for
c1=> the first byte to check for
c2=> the second byte to check for
c3=> the third byte to check for
`true` if the sequence is found.
def EatChar(c: Char): Bool;
def EatChar(c1: Char, c2: Char): Bool;
def EatChar(c1: Char, c2: Char, c3: Char): Bool;
Attempts to consume 1-3 input bytes.
c=> the first byte to check for
c1=> the first byte to check for
c2=> the second byte to check for
c3=> the third byte to check for
`true` if the bytes were found and consumed
func IsInt(): Bool;
Checks if the parser contains an integer, including sign.
def Sign(): Int;
Atempts to interpret the next character as a numeric sign and return the sign converted to an amount to multiply with. If not sign or '+' is encountered, it returns '1'. If '-' is found, it returns '-1'.
func IsNumber(base: Int): Bool;
Returns true if the parser sees a number in a given base.
base=> the base
def ReadInt(): Int;
Attempts to read and consume an integer in a base 10.
def ReadNumber(base: Int): DWord;
Attempts to read and consume an number in a given base.
base=> the base
val SkipWhitespace;
If set to `true`, every time an entity is consumed, whitespace following said entity is also consumed. If set to `false`, whitespace is not consumed and. It can manually be consumed with `EatSpaces`.
val SkipComments;
If set to true, every time whitespace is consumed, comments are also consumed.
val NestComments;
If set to true, every time comments are consumed, they can nest.