Skip to content

Commit d061df2

Browse files
committed
Ruby: AST ref docs - Module.qll
1 parent f5c2ed9 commit d061df2

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

docs/codeql/codeql-language-guides/abstract-syntax-tree-classes-for-working-with-ruby-programs.rst

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CodeQL has a large selection of classes for representing the abstract syntax tre
88
.. include:: ../reusables/abstract-syntax-tree.rst
99

1010
An ``IDENTIFIER`` should match the regular expression ``/[a-zA-Z_][a-zA-Z0-9_]*/``. A ``CNAME`` should match ``/[A-Z][a-zA-Z0-9_]*/``.
11+
``TERM`` is either a semicolon or a newline used to terminate a statement.
1112

1213
Statement classes
1314
~~~~~~~~~~~~~~~~~
@@ -74,10 +75,6 @@ All classes in this subsection are subclasses of ConstantAccess_.
7475
+========================================+======================+======================+===================+
7576
| CNAME | ConstantReadAccess_ | ConstantAccess_ | |
7677
+----------------------------------------+----------------------+----------------------+-------------------+
77-
| ``class`` CNAME StmtSequence_ ``end`` | ConstantWriteAccess_ | ConstantAccess_ | class definition |
78-
+----------------------------------------+----------------------+----------------------+-------------------+
79-
| ``module`` CNAME StmtSequence_ ``end`` | ConstantWriteAccess_ | ConstantAccess_ | module definition |
80-
+----------------------------------------+----------------------+----------------------+-------------------+
8178
| CNAME ``=`` Expr_ | ConstantAssignment_ | ConstantWriteAccess_ | |
8279
+----------------------------------------+----------------------+----------------------+-------------------+
8380

@@ -272,6 +269,19 @@ All classes in this subsection are subclasses of Literal_.
272269
| ``:foo`` | SymbolLiteral_ | StringlikeLiteral_ | |
273270
+----------------------------+-------------------+----------------------------+-------------------+
274271

272+
Modules and Ruby classes
273+
~~~~~~~~~~~~~~~~~~~~~~~~
274+
275+
All classes in this subsection are subclasses of BodyStmt_ and Scope_.
276+
277+
+----------------------------------------------------------------+--------------------+----------------------------------+-------------------+
278+
| Expression syntax | CodeQL class | Superclasses | Remarks |
279+
+================================================================+====================+==================================+===================+
280+
| ``class`` CNAME [``<`` Expr_] TERM StmtSequence_ TERM ``end`` | ClassDeclaration_ | Namespace_, ConstantWriteAccess_ | |
281+
| ``module`` CNAME TERM StmtSequence_ TERM ``end`` | ModuleDeclaration_ | Namespace_, ConstantWriteAccess_ | |
282+
| ``class <<`` Expr_ TERM StmtSequence_ TERM ``end`` | SingletonClass_ | ModuleBase_ | |
283+
+----------------------------------------------------------------+--------------------+----------------------------------+-------------------+
284+
275285
Method classes
276286
~~~~~~~~~~~~~~
277287

@@ -297,20 +307,9 @@ All classes in this subsection are subclasses of Callable_.
297307
| ``(`` StmtSequence_ ``)`` | ParenthesizedExpr_ | StmtSequence_ | |
298308
| ``rescue`` TODO | RescueClause_ | Expr_ | |
299309
| Stmt_ ``rescue`` Stmt_ | RescueModifierExpr_ | Expr_ | |
300-
| StmtSequence_ ``;`` Stmt_ | StmtSequence_ | Expr_ | A sequence of 0 or more statements, separated by semicolons or newlines |
310+
| StmtSequence_ TERM Stmt_ | StmtSequence_ | Expr_ | A sequence of 0 or more statements, separated by semicolons or newlines |
301311
| StringLiteral_ StringLiteral_ | StringConcatenation_ | Expr_ | Implicit concatenation of consecutive string literals |
302312
303-
304-
..
305-
Module.qll
306-
| | ClassDeclaration_ | | |
307-
| | Module_ | | |
308-
| | ModuleBase_ | | |
309-
| | ModuleDeclaration_ | | |
310-
| | Namespace_ | | |
311-
| | SingletonClass_ | | |
312-
| | Toplevel_ | | |
313-
314313
..
315314
Parameter.qll
316315
| | BlockParameter_ | | |

0 commit comments

Comments
 (0)