Skip to content

Parser[S: (Any #read & Equatable[S]), optional D: Any #share, optional V: Any #share]

[Source]

Stores a source of inputs to a parse, and a memo of parse results from prior parses. Used to initiate a parse attempt.

actor tag Parser[S: (Any #read & Equatable[S]), optional D: Any #share, optional V: Any #share]

Constructors

create

[Source]

new tag create(
  source: ReadSeq[ReadSeq[S] val] val)
: Parser[S, D, V] tag^

Parameters

Returns


Public Behaviours

insert_segment

[Source]

Insert a source segment at the given index. The insertion will happen upon the next call to parse().

be insert_segment(
  index: USize val,
  segment: ReadSeq[S] val)

Parameters


remove_segment

[Source]

Removes the source segment at the given index. The removal will happen upon the next call to parse().

be remove_segment(
  index: USize val)

Parameters


parse

[Source]

Initiates a parse attempt with the given rule.

be parse(
  rule: RuleNode[S, D, V] val,
  data: D,
  callback: ParseCallback[S, D, V] val,
  start: (Loc[S] val | None val) = reference,
  clear_memo: Bool val = false)

Parameters


Public Functions

num_segments

[Source]

Returns the number of segments currently in the source.

fun box num_segments()
: USize val

Returns