graphql-perl - Pegex findings
I'm porting the reference implementation of GraphQL for JavaScript to Perl, sponsored by Perl Careers. Part of that is obviously to lex/parse GraphQL queries. I decided to try this with Pegex.
Key findings:
- Pegex rules with regexes need to keep Pegex "atoms" separated from the "/" characters by whitespace, else it will be treated as a literal
- If you override the "ws" rule, do not have "-" in a regex in any sub-rules, or the compiler will go into an infinite loop
- auto-rebuild your grammar class using this snippet in your Makefile.PL: https://github.com/ingydotnet/pegex-pm/pull/62/files
- test with something like https://github.com/graphql-perl/graphql-perl/blob/master/t/language-lexer.t
- debug your grammar with (in bash)
make && PERL_PEGEX_DEBUG=1 perl -Ilib t/language-lexer.t |& less
Leave a comment