Re: Printing PEG structure
OvermindDL1 <[email protected]> Sun, 14 Mar 2010 20:24:19 -0600
| Newsgroups | gmane.comp.parsers.spirit.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Mar 14, 2010 at 7:41 PM, Joel de Guzman <[email protected]> wrote: > On 3/14/2010 11:39 AM, OvermindDL1 wrote: >> I am curious. I know that the grammar for Spirit generates a kind of >> bytecode at compile time that the parse functions can go over to do >> the actual parsing (again, optimized at compile time). I am curious, >> would it be possible to create such a function that goes over that >> bytecode/typetree of Qi/Karma and can print out the PEG string >> representation of what the parsing does? For terminals it does not >> know about would need to override a function or so that lets it print >> out its representation. >> >> Would be great for debugging though. >> >> rule<...> r1, r2; >> r1 = int_>> space>> double_%','; >> r2 = r1 | (lit('"')>>*~char_('"')>>lit('"')); >> r1.name("r1"); >> r2.name("r2"); >> >> ostringstream o; >> peg_string(o, r2); >> o.str(); // returns: >> >> r2 = r1 | ('"' (~'"')* '"') >> r1 = int space double (',' double)* >> int = /* however this is defined */ >> space = ' '|'\t'|'\r'|'\n' >> double = /* however this is defined */ >> >> Or something like that. Does not need to be pretty, just get the >> point across, would be great to toss into documentation for a created >> parser too. > > That's one of the things Hartmut and I want to do with our planned > BoostCon 2010 presentation. Oh how I wish I could attend! Will there be a video? ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Spirit-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spirit-devel