lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Here's a start on a C parser.  Mostly useful for lists of expression
statements without things like structs, or branching/looping code:

http://www.mat.ucsb.edu/projects/luaAV/browser/trunk/extra/modules/matrixfx/parser.lua

wes


On Sat, Sep 19, 2009 at 11:31 AM, David Manura <dm.lua@math2.org> wrote:
> On Fri, Sep 18, 2009 at 8:48 AM, Peter Cawley wrote:
>> You might be interested in reusing some code I wrote recently. It is a
>> Lua/LPEG creation to parse C++ source files, extract information, and
>> then output it in wiki markup.
>
> For comparison, there's another LPeg-based C tokenizer at [1].  There
> may be some issues using a C tokenizer as is on C++.  For example,
> '::' is a C++ only token.  Peter's supports that (mine doesn't) though
> doesn't appear to specially mark C++ keywords like 'try' and 'class'
> for example.
>
> Reliably parsing, not just lexing, C++ is no small feat.  gccxml was
> discussed previously on this list [3].  See also [4].  Using the xml
> output option from Doxygen may be a fairly accessible solution that's
> good enough.
>
> [1] http://lua-users.org/wiki/LpegRecipes
> [2] http://www.gccxml.org/
> [3] http://lua-users.org/lists/lua-l/
> [4] http://stackoverflow.com/questions/526797/good-tools-for-creating-a-c-c-parser-analyzer
>