ylixir / phap

Php Has Another Parser
GNU Lesser General Public License v3.0
4 stars 1 forks source link

create labelled parsers #41

Open ylixir opened 5 years ago

ylixir commented 5 years ago

we need some way to do recursive parsers, and mutually recursive parsers.

the best i've come up with is labelling a parser with label and then referencing it with use

$parser = p::label("foo",p::block(p::lit("foo"),p::lit("bar"),p::use("foo");

this parser would parse "foofoobarbar" but "foofoobar" would give an error.

ylixir commented 5 years ago

i think we can do this without labels, by making parser generator factory functions.

this is still something we may want to revisit down the road, but mainly for performance reasons