[llvm-commits] Initial TableGen language reference

Dmitri Gribenko gribozavr at gmail.com
Wed Jan 2 11:15:41 PST 2013


On Mon, Dec 31, 2012 at 2:20 PM, Sean Silva <silvas at purdue.edu> wrote:
> Hi, this patch adds the beginnings of a language reference for
> TableGen. It covers just the syntax currently. I didn't dive too deep
> into the semantics primarily due to sheer exhaustion from reading
> through the code.
>
> The document is pretty bare bones, but pretty much all of the
> productions should be there. I've used Sphinx's "productionlist"
> directive to get relatively nice hyperlinked syntax productions
> (although IMO the syntax for them in the .rst file is pretty ugly).
>
> I gleaned the syntax from a depth-first traversal of TGParser.cpp
> starting from TGParser::ParseFile. I've kept it close to the rough
> grammar laid out in the comments, but I'm open to refactoring it to
> make it clearer. The lexical stuff was of course pulled from
> TGLexer.cpp.

Thank you for working on this!

+``class``\es

IIRC, this needs a space after the backslash.

+A given class can only be defined once. A ``class`` declaration is
+considered to define the class if one of the following is true:

s/one/any/, to be more precise?

+You can declare an empty class by giving and empty :token:`TemplateArgList`
+and an empty :token:`ObjectBody`.

An example would be appropriate.

+and an empty :token:`ObjectBody`. This can serve as a restricted form of
+forward declaration: note that records deriving from the forward-declared
+class will inherit no fields from it since the record expansion is done
+when the record is parsed.

That's... interesting.  We might want to do something about it, unless
it is actually useful in an unexpected way.

+Values
+------
+
+.. productionlist::
+   Value: `SimpleValue` ValueSuffix*

`ValueSuffix`

+The peculiar last form of :token:`RangePiece` is due to the fact that the
+``-`` is included in the :token:`TokInteger`, hence ``1-5`` gets lexed as

"``-``" might be better (monospaced font alone does not make an
obvious difference).

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the llvm-commits mailing list