Help with porting grammar from PEGjs to D for dustjs project!

Uranuz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 6 00:09:08 PDT 2014


What I was thinking about is possibility to change ParseTree 
struct with user-defined version of it. And I was thinking about 
setting tree type as template parameter to grammar:

grammar!(MyParseTree)("
Arithmetic:
    ...
");

Or somethink like this. I think changing source code of library 
in order to change tree type is not good and should be set as 
parameter. If it's already implemented please let me knoe because 
I couldn't find it. And also some minimal interface is needed to 
be described in documentation for ParseTree (may be ability to 
set it as class is good in order to have polymorthic nodes with 
different methods and properties).

Of course I can transform PEGGED syntactic tree into another form 
of tree specified by usage domain. But if it doesn't 
significantly differs from PEGGED tree (for example node have a 
pair of additional properties) it only causes into additional 
memory consumption and CPU to transform tree. But if domain 
specific tree differs a lot of course we need some useful way to 
transform trees.


More information about the Digitalmars-d-learn mailing list