[cfe-commits] Comment AST and parser

Douglas Gregor dgregor at apple.com
Tue Jul 3 13:08:46 PDT 2012


On Jul 3, 2012, at 10:40 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> On Mon, Jul 2, 2012 at 3:10 PM, Douglas Gregor <dgregor at apple.com> wrote:
>> On Jul 2, 2012, at 3:04 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>>>> Index: utils/TableGen/TableGen.cpp
>>>> ===================================================================
>>>> --- utils/TableGen/TableGen.cpp (revision 159471)
>>>> +++ utils/TableGen/TableGen.cpp (working copy)
>>>> @@ -38,6 +38,7 @@
>>>>    GenClangDiagsDefs,
>>>>    GenClangDiagGroups,
>>>>    GenClangDiagsIndexName,
>>>> +  GenClangCommentNodes,
>>>>    GenClangDeclNodes,
>>>>    GenClangStmtNodes,
>>>>    GenClangSACheckers,
>>>> @@ -86,6 +87,8 @@
>>>>                      clEnumValN(GenClangDiagsIndexName,
>>>>                                 "gen-clang-diags-index-name",
>>>>                                 "Generate Clang diagnostic name index"),
>>>> +                    clEnumValN(GenClangCommentNodes, "gen-clang-comment-nodes",
>>>> +                               "Generate Clang AST comment nodes"),
>>>>                      clEnumValN(GenClangDeclNodes, "gen-clang-decl-nodes",
>>>>                                 "Generate Clang AST declaration nodes"),
>>>>                      clEnumValN(GenClangStmtNodes, "gen-clang-stmt-nodes",
>>>> @@ -148,6 +151,9 @@
>>>>      case GenClangDiagsIndexName:
>>>>        EmitClangDiagsIndexName(Records, OS);
>>>>        break;
>>>> +    case GenClangCommentNodes:
>>>> +      EmitClangASTNodes(Records, OS, "Comment", "");
>>>> +      break;
>>>>      case GenClangDeclNodes:
>>>>        EmitClangASTNodes(Records, OS, "Decl", "Decl");
>>>>        EmitClangDeclContext(Records, OS);
>>>> 
>>>> Is there more that you intend to do with TableGen for the AST nodes themselves? It looks like all we're getting is the list of node names, but TableGen is a pretty heavyweight way to keep that up-to-date.
>>> 
>>> Currently we tablegen'ing clang/AST/CommentNodes.inc.  I plan to
>>> tablegen a list of supported commands with two attributes: command
>>> kind (inline/block/verbatim block/verbatim line) and number of
>>> arguments.
>> 
>> It seems to me like this will be a different set of TableGen classes with different generators. If that's indeed true, using TableGen to generate CommentNodes.inc is rather excessive. A .def file would be simpler in such cases.
> 
> Seems like I am misunderstanding you.  Currently I use TableGen to
> generate CommentNodes.inc that describes inheritance tree of AST nodes
> and it does not seem like an overkill.


It just seems like writing a .def file (with the contents of the generated .inc) would be simpler, but I don't feel strongly about it.

	- Doug



More information about the cfe-commits mailing list