Open fy0 opened 2 months ago
Hi @fy0 Thanks for your pull request. I would like to better understand in what kind of situations you want to control the parser manually. Can you elaborate and provide some real world examples?
Hi @fy0 Thanks for your pull request. I would like to better understand in what kind of situations you want to control the parser manually. Can you elaborate and provide some real world examples?
For example, I want to embed another parser inside my peg parser.
{
package main
}
e <- "<%js" js_code "%>" !.
js_code <- *{
// there is a js parser, eat unknow length text, return a object
}
If do this work with current pigeon, I need to describe all syntax by peg, or just match '%>' and pray for '%>' is not appears in js code part.
It's also useful to implement meta programming language feature.
Another example, i want user can register their own operators. pigeon's #{
syntax is nearly works, but not good.
Sometimes, i want to use a hand writing parser for some exprerssion, for example:
For that, i made a fork. Owe to pigeon's clear design, it's much easier than i thought it should be.
I use sign "*{}" to describle custom parser code block:
test code:
But if i want to control the parser by manual, expose "parser" object to action is necessary. I noticed parser object is willful hide for all code blocks. So i'm worried about i had break a guideline.
Have a look and have a nice day.