Parser.opBinary

dsl for alternatives e.g. match("abc") | match("def") matches "abc" or "def"

  1. Parser opBinary(Variant[] function(Variant[] objects) toCall)
  2. Parser opBinary(Parser rhs)
    class Parser(T)
    opBinary
    (
    string op
    )
    if (
    op == "|"
    )
  3. Parser opBinary(Parser rhs)

Examples

the pc4d.alternative parser and its dsl '|'

1 import unit_threaded;
2 
3 auto parser = match("abc") | match("def");
4 auto res = parser.parse("abc");
5 res.success.shouldBeTrue;
6 
7 res = parser.parse("def");
8 res.success.shouldBeTrue;
9 
10 res = parser.parse("ghi");
11 res.success.shouldBeFalse;

Meta