<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Generally a parser generated by other tool and accepting tokens returns the abstract syntax tree, but it return the evaluated value in the example.<br>
In other words, it does lexical analysis, parsing and (type) converting at a time.<br>
If you want simply abstract syntax tree, it may be a little pain to use ctpg.<br></blockquote><div><br></div><div> Hello Youkei</div><div><br></div><div>I am trying to use CTPG for compile time parsing for a DSL I am working on. I have tried the examples you created in the examples directory.</div>

<div><br></div><div>I would like the parser to effect some side effects. For this purpose, I tried including the parser mixin into a class, but I got a strange error saying:</div><div><br></div><div>Error: need 'this' to access member parse</div>

<div><br></div><div>I have copied the code I am trying to compile at the end of the email. Let me know what I could be doing wrong here.</div><div><br></div><div>Regards</div><div>- Puneet</div><div><br></div><div><br></div>

<div><div>import ctpg;</div><div>import std.array: join;</div><div>import std.conv: to;</div><div><br></div><div>class Foo</div><div>{</div><div>  int result;</div><div>  mixin(generateParsers(q{</div><div>        int root = mulExp $;</div>

<div><br></div><div>        int mulExp =</div><div>          primary !"*" mulExp >> (lhs, rhs){ return lhs * rhs; }</div><div>        / primary;</div><div><br></div><div>        int primary = !"(" mulExp !")" / [0-9]+ >> join >> to!int;</div>

<div>      }));</div><div><br></div><div>  void frop() {</div><div>    result = parse!root("5*8");</div><div>  }</div><div>}</div><div><br></div><div><br></div><div>void main(){</div><div>  Foo foo = new Foo();</div>

<div>  foo.frop();</div><div>}</div></div><div><br></div></div>