Skip to content

Choice

[Source]

Given a sequence of parser rules, return the result of the first rule that matches. Note that the result is deterministic: if more than one of the rules could match, the first in the list will be chosen.

class ref Choice is
  Parser box

Implements


Constructors

create

[Source]

new ref create(
  a: Parser box,
  b: Parser box)
: Choice ref^

Parameters

Returns


concat

[Source]

new ref concat(
  a: Choice box,
  b: Parser box)
: Choice ref^

Parameters

Returns


Public Functions

div

[Source]

fun box div(
  that: Parser box)
: Choice ref

Parameters

Returns


parse

[Source]

fun box parse(
  source: Source val,
  offset: USize val,
  tree: Bool val,
  hidden: Parser box)
: (USize val , (AST val | Token val | NotPresent val | 
    Skipped val | Lex val | Parser box))

Parameters

Returns


error_msg

[Source]

fun box error_msg()
: String val

Returns


skip_hidden

fun box skip_hidden(
  source: Source val,
  offset: USize val,
  hidden: Parser box)
: USize val

Parameters

Returns


result

fun box result(
  source: Source val,
  offset: USize val,
  from: USize val,
  length: USize val,
  tree: Bool val,
  l: Label val = reference)
: (USize val , (AST val | Token val | NotPresent val | 
    Skipped val | Lex val | Parser box))

Parameters

Returns


mul

fun box mul(
  that: Parser box)
: Sequence ref

Parameters

Returns


neg

fun box neg()
: Skip ref

Returns


opt

fun box opt()
: Option ref

Returns


many

fun box many(
  sep: Parser box = reference)
: Many ref

Parameters

Returns


many1

fun box many1(
  sep: Parser box = reference)
: Many ref

Parameters

Returns


op_not

fun box op_not()
: Not ref

Returns


op_and

fun box op_and()
: Not ref

Returns


hide

fun box hide(
  that: Parser box)
: Hidden ref

Parameters

Returns


term

fun box term(
  l: Label val = reference)
: Terminal ref

Parameters

  • l: Label val = reference

Returns


eof

fun box eof()
: EndOfFile ref

Returns