robrix / Madness

Recursive Descent Into Madness
MIT License
291 stars 17 forks source link

Null parser #39

Closed robrix closed 9 years ago

robrix commented 9 years ago

Parses everywhere but doesn’t actually produce any trees or advance the input at all.

let null: Parser<()>.Function = { ((), $0) }

This is the same as ε. It could be a workaround for/alternative to #38 in that since it produces () trees, alternation with T will produce T?:

(x | null) --> { $0.map(const("x matched")) ?? "x did not match" }
robrix commented 9 years ago

This would produce Ignore now.

robrix commented 9 years ago

This exists, it’s none.