I have thought about this before... it would be cool, but I was never convinced that it would be worth the effort. It would probably be impossible to fully parse the snippets since they're just snippets, so there's a lot of missing context about what are type names and what are variables. You might be able to work around that by forcing the use of 'typename' where it's ambiguous, but that could be pretty clumsy and clutter things up.
You could just tokenize the input, which would enable robust handling of comments, if the regex Ali dug up isn't robust enough (hard to tell, but it looked pretty complete to me). I don't think it would help the string case, since you'd probably just use the same regex to handle strings as individual tokens anyway. Anyway, the original intent was that these would be pretty short snippets, so all this mechanism wouldn't be necessary, but of course it has grown way past that original intent. Steve On Wed, Sep 7, 2011 at 3:23 PM, nathan binkert <[email protected]> wrote: > Do we parse the C snippets? We could also get a grammar for C++. It's not > easy to fully parse C++ when trying to do all of the semantic stuff, but > simply parsing for our purposes isn't that tough and I think that there is > an open source C++ parser that comes with PLY or was written for PLY. > > Nate > > > > On Wed, Sep 7, 2011 at 12:09 PM, Steve Reinhardt <[email protected]> wrote: > >> This is an automatically generated e-mail. To reply, visit: >> http://reviews.m5sim.org/r/841/ >> >> On September 6th, 2011, 11:40 a.m., *Nathan Binkert* wrote: >> >> Out of curiosity, are comments not being handled by PLY? If that's the >> case, why? Check out slicc/parser.py to see how to deal with comments. >> >> We're talking about comments in the C snippets that the ISA parser handles >> via regexes, not the ISA DSL itself. >> >> >> - Steve >> >> On September 5th, 2011, 10:34 p.m., Gabe Black wrote: >> Review request for Default, Ali Saidi, Gabe Black, Steve Reinhardt, and >> Nathan Binkert. >> By Gabe Black. >> >> *Updated 2011-09-05 22:34:45* >> Description >> >> ISA parser: Match /* */ and // style comments. >> >> Comments should not be scanned for operands, and we should look for both /* >> */ >> style and // style. The regular expression is still not quite right because >> it >> doesn't handle comments in strings, but it's closer. >> >> Diffs >> >> - src/arch/isa_parser.py (1f95c9a0bb2f) >> >> View Diff <http://reviews.m5sim.org/r/841/diff/> >> > > _______________________________________________ gem5-dev mailing list [email protected] http://m5sim.org/mailman/listinfo/gem5-dev
