glad to hear Neotoma is getting mature.
Could you please give an update on transformation syntax?
The link you've given doesn't work.
Hope you've adopted syntax i've suggested and partially implemented in my branch:
http://github.com/pirj/neotoma/blob/master/extra/leg.peg
Glad to hear you've finally agreed with that Neotoma PEG syntax should not rely
on Erlang syntax, so that Reia and LFE developers can all use common syntax.
As a matter of fact i've stuck on Retem (templating) development for a different
reason that our misunderstanding. That is an issue that crosses the line between
Neotoma and other PEG parser generators i've tried and prevents from moving
further with the simpliest task i had to do.
So, what a templating engine is? it's a general text and some embraced expressions:
"hello, {name} !"
My syntax rules are here: http://github.com/pirj/ryan/blob/master/src/retem/retem.peg
And yes, i've used my transformations to avoid Erlang syntax in Reia-based templating engine:
dot_expression <- id '.' id : (dot, 1, 3);
I'm doing
peg_gen:file("retem.peg"). c(retem). l(retem).
retem:parse("{for a in aa}{if true}{xxx}{endif}{endfor}").
and it ends up in ILR, for which Neotoma doesn't have any detection/elimination mechanism.
http://github.com/pirj/ryan/commit/84f54825cb89a72d587cc103230c0239c5b4d6ce
That's a commit that seem to work around ILR, but it cannot work fine with text outside braces.
I've tried to port my syntax to that C PEG/LEG library, and it worked just fine.
Since Neotoma is the only one for Erlang, and there are some awesome projects
around the block, such are Herml and ErlyDTL, i've left the idea of writing my own
parser at least until Neotoma resolves this or Reia is mature enough to implement
PEG parser with it.
Phil
AFAIK, you could put your record definition in the "additional code"
section at the bottom of the grammar. However, you might want to check
that assumption out, I'm unsure whether record definitions need to
appear before functions that use them.
Sean
nonterminal <- reduction ` % erlang code goes here `;
> Glad to hear you've finally agreed with that Neotoma PEG syntax should not rely
> on Erlang syntax, so that Reia and LFE developers can all use common syntax.
>
>
At this point I'm only supporting Erlang syntax (because of the
parser-generation piece), but if there is an easy way to generate Reia
parsers, I'm all ears.
> As a matter of fact i've stuck on Retem (templating) development for a different
> reason that our misunderstanding. That is an issue that crosses the line between
> Neotoma and other PEG parser generators i've tried and prevents from moving
> further with the simpliest task i had to do.
>
> So, what a templating engine is? it's a general text and some embraced expressions:
> "hello, {name} !"
>
> My syntax rules are here: http://github.com/pirj/ryan/blob/master/src/retem/retem.peg
> And yes, i've used my transformations to avoid Erlang syntax in Reia-based templating engine:
> dot_expression <- id '.' id : (dot, 1, 3);
>
> I'm doing
> peg_gen:file("retem.peg"). c(retem). l(retem).
> retem:parse("{for a in aa}{if true}{xxx}{endif}{endfor}").
>
> and it ends up in ILR, for which Neotoma doesn't have any detection/elimination mechanism.
>
> http://github.com/pirj/ryan/commit/84f54825cb89a72d587cc103230c0239c5b4d6ce
> That's a commit that seem to work around ILR, but it cannot work fine with text outside braces.
>
> I've tried to port my syntax to that C PEG/LEG library, and it worked just fine.
>
> Since Neotoma is the only one for Erlang, and there are some awesome projects
> around the block, such are Herml and ErlyDTL, i've left the idea of writing my own
> parser at least until Neotoma resolves this or Reia is mature enough to implement
> PEG parser with it.
>
Maybe there's still some confusion here. Neotoma is just a
parser-generator - you'll still need to do semantic analysis yourself.
You might take a look at the extra functions that the metagrammar-parser
includes - it builds up a symbol table, and then when transforming the
top rule, verifies that:
1) all nonterminals have reductions
2) all reductions are reachable
This is something the parser itself, with simple data transformations,
could not check.
It's also possible that I haven't fully comprehended LEGs yet. Perhaps
LEG could be something that goes alongside neotoma's existing PEG?
Sean
Tony,
AFAIK, you could put your record definition in the "additional code" section at the bottom of the grammar. However, you might want to check that assumption out, I'm unsure whether record definitions need to appear before functions that use them.
On Sat, Nov 14, 2009 at 10:00 AM, Sean Cribbs <seanc...@gmail.com> wrote:
Tony,
AFAIK, you could put your record definition in the "additional code" section at the bottom of the grammar. However, you might want to check that assumption out, I'm unsure whether record definitions need to appear before functions that use them.
I'm fairly certain they do. This works in Leex because Leex places the "additional code" at the top of the output file.
Hi Tony, For what it is worth: I have implemented a parser for WikiCreole using Neotoma and it works quite fine. Not sure if that fits your notion of large, though ;-) This was with Neotoma 1.1 and right now I am just dying to upgrade to 1.3 and throw out a bunch of code that really has to be inline transformations. Cheers, Torben On Sat, Nov 14, 2009 at 06:33, Tony Arcieri <to...@medioh.com> wrote:
Not really, it is part of a on-the-side start-up which we hope can bring in some money.
But the WikiCreole part could perhaps be released as an example of how to use Neotoma - I will ask my "co-founders" if they think it is safe to release it.
BTW: I have to update to the new inline stuff since my implementation is based on 1.1 and it is a lot prettier to generate the AST as inline commands on the grammar, not to mention easier to understand!
Cheers,
Torben
Sean,
Let's step a bit back from the joy of having a new feature that makes life easier and gaze a bit at what is really important.
As I see it the key is to be able to generate a nice AST that is easy to work with going forward. In Neotoma 1.1 the transformation functions could help out with that and in Neotoma 1.3 we have the inline transformations with the backtick syntax.
Looking at yecc they use structure building code [1] and that seems to be a clean way of solving the problem - at least it has the added benefit that it can be spelled out for each clause in a production rule (not sure if Neotoma supports that with the current syntax).
How does other PEG implementations bridge the gap between the production rules and the AST? There might be some good ideas on this that could be used to lift the backtick solution to even higher hights!
References:
[1] http://erlang.org/doc/man/yecc.html
Cheers,
Torben