Where can I download the EBNF syntax description document for C++ syntax parser by clang?
clang does not include a document like that.
Like most C++ parsers, clang’s parser is a hand-written recursive-descent parser, so there’s no way to automatically extract a machine-parsable description of the grammar. And trying to write one by hand wouldn’t really be productive.
I’m not sure how one would express in EBNF parsing decisions based on semantic analysis and tentative parsing, e.g in identifier < identifier or “most vexing parse” situations.
Without a grammar standard (assuming described using EBNF), how can I know the semantics of each node in AST?
for example, from DeclNodes.td:
def Named : Decl<1>;
…
….def Value : DDecl<Named, 1>;
……..def EnumConstant : DDecl;
…
….def Template : DDecl<Named, 1>;
……..def RedeclarableTemplate : DDecl<Template, 1>;
……..def FunctionTemplate : DDecl;
……..def ClassTemplate : DDecl;
……..def VarTemplate : DDecl;
…
How do I know the meaning of the “RedeclarableTemplate” ?
I feel like there’s some confusion about what Clang AST is. As someone else aptly put it, it’s a wrongly named concrete semantic graph.
Answering those questions directly, by the time you see an e.g. RedeclarableTemplate node, parser has already decided on the semantic of the corresponding preprocessing tokens by picking that kind of node over a different kind of node.