Peter Stuifzand

Building a parser with Marpa::XS

Tonight I wrote this parser in Perl with Marpa::XS. The nice thing about Marpa is that it will tell you which terminals (or tokens) it expects at the current position. So instead of guessing what the next token will be you can just try to parse a token and try it.

I got the general idea from the TAP::Spec::Parser. The difference is that it will try all alternatives at once, while mine tries each after the other until one works.

I hope this will help people to understand this kind of parsing better. Let me know what you think.

© 2023 Peter Stuifzand