mixinafPegger::RuleCtx

afPegger::RuleCtx

@Js

(Advanced) Handed to Rule classes during the matching process.

currentPos

Source

abstract Int currentPos()

Returns the current position in the underlying input stream.

eos

Source

abstract Bool eos()

Returns true if at the End-Of-Stream.

log

Source

abstract Void log(Str msg)

Logs the given message to debug. It is formatted to be the same as the other Pegger debug messages.

parseErr

Source

abstract PegParseErr parseErr(Str errMsg)

Returns a PEG specific ParseErr to be thrown.

peekChar

Source

abstract Int? peekChar(Int offset := 0)

Peeks a character relative to the current position (Does not consume any characters). For example:

  • peekChar(2) - returns char at currentPos + 2
  • peekChar(-1) - returns char at currentPos - 1

Returns null if out of bounds.

process

Source

abstract Bool process(Rule rule)

Call to process a sub-rule. Returns true if it matched successfully.

readChar

Source

abstract Int readChar()

Consumes 1 character from the underlying input stream.

rollbackToPos

Source

abstract Void rollbackToPos(Int pos)

Rolls back the underlying input stream to the given position.

sos

Source

abstract Bool sos()

Returns true if at the Start-Of-Stream.

str

Source

abstract Str str()

Returns the string we are matching against.