<p>> > Yeah. It's pretty cool. It really shows up D's metaprogramming<br>
> > capabilities.<br>
><br>
> It's a bit hell to debug it, though. But I finally managed to get a<br>
> working parser out of it.</p>
<p>I received your suggestion of a full debug mode explaining what rules where activated and wich did not.</p>
<p>><br>
> Except now I can't use it, for some reason. Code:<br>
><br>
> void buildGraph(Output o) {<br>
> void parseToGraph(ParseTree p) {<br>
> writeln(p.ruleName);<br>
> }<br>
><br>
> parseToGraph(o.parseTree);<br>
> }<br>
><br>
> void parseconfigs() {<br>
> Output o = ENI.parse(readText("/tmp/ifaces_data"));<br>
> buildGraph(o);<br>
> }<br>
><br>
> produces the following error message:<br>
><br>
> dmd -gc -w -unittest -I../../Pegged -c -ofmain.o main.d<br>
> ipcfg/parser.d(45): Error: struct pegged.peg.Output(TParseTree) if (isParseTree!(TParseTree)) is used as a type<br>
> make: *** [main.o] Error 1<br>
><br>
> Help?</p>
<p>Roman recently templated the parse tree to allow multiple outputs and we didn't update the docs, sorry. That makes Pegged output something other than `Output`. One consequence is hat semantic actions should be templates to function on different kinds of parse trees.</p>
<p>Try:</p>
<p>> void buildGraph(O)(O o) {<br>
> void parseToGraph(ParseTree p) {<br>
> writeln(p.ruleName);<br>
> }<br>
><br>
> parseToGraph(o.parseTree);<br>
> }<br>
><br>
> void parseconfigs() {<br>
> auto o = ENI.parse(readText("/tmp/ifaces_data"));<br>
> buildGraph(o);<br>
> }</p>
<p>What do parseToGraph and buildGraph do?<br></p>
<p>><br>
> What does cause problems, though, is that it won't compile with gdc:<br>
><br>
> gdmd -release -I../../Pegged -c -ofmain.o main.d<br>
> /home/wouter/code/d/Pegged/pegged/grammar.d:128: Error: template pegged.grammar.PEGGED!(ParseTree).PEGGED.parse(ParseLevel pl = ParseLevel.parsing) parse(ParseLevel pl = ParseLevel.parsing) matches more than one template declaration, /home/wouter/code/d/Pegged/pegged/grammar.d(111):parse(ParseLevel pl = ParseLevel.parsing) and /home/wouter/code/d/Pegged/pegged/grammar.d(126):parse(ParseLevel pl = ParseLevel.parsing)<br>
> make: *** [main.o] Error 1<br>
><br>
> GDC 4.6, though, so I'll wait until Iain uploads 4.7 to Debian; if that<br>
> doesn't fix it, I'll file bugs where appropriate.</p>
<p>I find it strange that I don't get that error with DMD. </p>
<p>Philippe<br>
</p>