Tablegen Grammar "include" as a keyword

Was in the process of creating an TabelGen plugin for IntelliJ IDEs, wondering why in the documentation "include" is not listed as a keyword?

Yaotia

I suspect this is just an oversight, it would be great to fix this :slight_smile:

-Chris

It’s great to see work on improving language support for TableGen in tools!

“include” is technically a preprocessing directive in TableGen. It is not a keyword of the TableGen grammar proper, just as “include” is not a keyword in the C/C++ grammar. E.g. “include” is not listed in section “2.11 Keywords [lex.key]” in the C++ language standard, but rather only mentioned in a highly specific way in “16 Preprocessing directives [cpp]”.

We mention TableGen’s include mechanism briefly in https://llvm.org/docs/TableGen/LangRef.html#syntax

TableGen has an include mechanism. It does not play a role in the syntax per se, since it is lexically replaced with the contents of the included file.

IncludeDirective ::= "include" TokString

Since that’s the only “preprocessing” TableGen has, we don’t have a while explicit section (analogous to “16 Preprocessing directives [cpp]” in the C++ standard) giving more details on the TableGen “preprocessor” in this sense. We maybe should, technically speaking.

TableGen’s top-level grammar production is TableGenFile ::= Object*, analogous to C++'s “translation-unit” production.

– Sean Silva