PrivateconstructorProtectedadvanceMoves the current position forward by one byte. Has no effect when already at end of input.
ProtectedatReturns true when the parser has reached the end of input.
Implemented by subclasses based on their input representation.
ProtectedcaptureReturns a zero-copy DataView slice of the source buffer.
Start byte offset (inclusive), relative to the start of source.
End byte offset (exclusive), relative to the start of source.
ProtectedconsumeProtecteddecodeDecodes a byte range of the source buffer as a UTF-8 string.
Start offset (inclusive).
End offset (exclusive).
ProtecteddescribeReturns a human-readable description of the input element at pos for
use in error messages. In scannerless parsers this describes a byte; in
token parsers it describes a token.
The position index to describe.
ProtectederrorThrows an RDParserException with the given message and the current
position appended. The return type is never so call sites can write
return this.error(...) to satisfy TypeScript's control-flow analysis.
Description of the parse failure.
ProtectederrorThrows a RDParserException naming the unexpected input element at the furthest position reached during parsing.
Call this from the top-level parse() method when the first rule returns
null, to give callers a precise error location rather than a generic
"Failed to parse input (at position 0)" message.
ProtectedexpectProtectedgetReturns the furthest position at which a terminal match was attempted and failed. Useful for producing informative error messages when the overall parse fails.
ProtectedgetReturns the current position within the input.
ProtectedisReturns true if byte is an ASCII letter (A–Z or a–z).
ProtectedisReturns true if byte is an ASCII digit (0–9).
ProtectedisReturns true if byte is a valid ASCII hex digit (0–9, A–F, a–f).
ProtectedisEBNF names allow underscore, letters, digits, and hyphen.
ProtectedisEBNF names allow underscore in addition to letters.
ProtectedmatchIf the current byte equals expectedByte, consumes it and returns true.
Otherwise leaves the position unchanged and returns false.
The byte value to match.
Parse the source and return a GrammarAST.
PrivateparsePrivateparsePrivateparsePrivateparsePrivateparsePrivateparsePrivateparsePrivateparseProtectedpeekReturns the byte at the current position without consuming it,
or null if the parser has reached the end of input.
PrivatepeekProtectedreadIf the current byte equals expectedByte, consumes it and returns it as a one-character string.
Otherwise leaves the position unchanged and returns null.
This is the value-returning counterpart of matchChar, used by generated parsers to capture terminal characters directly into the parse tree.
The byte value to match.
ProtectedreadIf the current byte falls within [lowerBound, upperBound] (inclusive), consumes it and returns it
as a one-character string. Otherwise leaves the position unchanged and returns null.
Used by generated parsers to capture character-range terminals into the parse tree.
Lower bound (inclusive) of the byte range.
Upper bound (inclusive) of the byte range.
ProtectedrestoreRestores the current position to a previously saved value.
Used with getPosition to implement backtracking in parser alternatives.
The position to restore to.
PrivateskipProtectedupdateRecords the current position as a fail point if it is further than any previously recorded fail. Subclasses call this when a terminal match fails.
StaticparseParse ISO 14977 EBNF source text and return a GrammarAST.
EBNF grammar source text.
Optional_options: EBNFParseOptionsParse options (currently unused).
The raw input buffer. Accessible to subclasses so they can decode slices.