gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

> e.g. we may introduce abstract bases like "loop" that the grammar doesn't 
> care about in order to model is-a concepts that might make refactorings more 
> expressive. This is less natural in a grammar-like idiom.

Loop can be an alternative rule in the grammar, I'm not sure what is less 
natural about it:

  Statement ::=
    IfStatement | LoopStatement | BreakStatement | ...
  
  LoopStatement ::=
    ForLoopStatement | WhileLoopStatement | ...



================
Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:36
+  // Documentation for this Node subclass.
+  string documentation;
 }
----------------
I think it would be best to make documentation mandatory, and for nodes that 
are currently lacking it, add a FIXME so that we clearly see where the tech 
debt is.


================
Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:48
+
+// An abstract node type which merely serves as a base for more specific types.
+class Alternatives<NodeType base_ = Tree> : NodeType { let base = base_; }
----------------
+
```
It corresponds to an alternative rule in the grammar, for example:
Statement ::=
  IfStatement | ForStatement | ...

`Statement` should be modeled with `Alternatives<>`. `IfStatement` and 
`ForStatement` are derived from `Statement`.
`````


================
Comment at: clang/utils/TableGen/ClangSyntaxEmitter.cpp:147-148
+
+// Format a documentation string as a C++ comment.
+// This has special whitespace handling as comments may appear in *.td as:
+//    documentation = [{
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90543/new/

https://reviews.llvm.org/D90543

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to