Ruby: AST ref docs - initial draft

This commit is contained in:
Alex Ford
2022-11-01 23:48:23 +00:00
parent d061df2e12
commit e6f91b91e0

View File

@@ -7,63 +7,63 @@ CodeQL has a large selection of classes for representing the abstract syntax tre
.. include:: ../reusables/abstract-syntax-tree.rst
An ``IDENTIFIER`` should match the regular expression ``/[a-zA-Z_][a-zA-Z0-9_]*/``. A ``CNAME`` should match ``/[A-Z][a-zA-Z0-9_]*/``.
``TERM`` is either a semicolon or a newline used to terminate a statement.
* An ``IDENTIFIER`` denotes an arbitrary identifier.
* A ``CNAME`` denotes a class or module name.
* An ``FNAME`` denotes a method name.
* A ``TERM`` is either a semicolon or a newline used to terminate a statement.
* Elements enclosed in ``« »`` are grouped and may be suffixed by ``?``, ``*``, or ``+`` to denote 0 or 1 occurrences, 0 or more occurrences, and 1 or more occurrences respectively.
Statement classes
~~~~~~~~~~~~~~~~~
This table lists subclasses of Stmt_ representing Ruby statements.
..
TODO: FNAME definition
+------------------------------------------------+--------------+----------------+---------+
| Statement syntax | CodeQL class | Superclasses | Remarks |
+================================================+==============+================+=========+
| ``alias`` FNAME FNAME | AliasStmt_ | Stmt_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``BEGIN {`` StmtSequence_ ``}`` | BeginBlock_ | StmtSequence_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``begin`` StmtSequence_ ``end`` | BeginExpr_ | StmtSequence_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``break`` [Expr_] | BreakStmt_ | ReturningStmt_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``;`` | EmptyStmt_ | Stmt_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``END {`` StmtSequence_ ``}`` | EndBlock_ | StmtSequence_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``next`` [Expr_] | NextStmt_ | ReturningStmt_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``redo`` | RedoStmt_ | Stmt_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``retry`` | RetryStmt_ | Stmt_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``return`` [Expr_] | ReturnStmt_ | ReturningStmt_ | |
+------------------------------------------------+--------------+----------------+---------+
| ``undef`` FNAME (, FNAME) | UndefStmt_ | Stmt_ | |
+------------------------------------------------+--------------+----------------+---------+
+---------------------------------+--------------+----------------+---------+
| Statement syntax | CodeQL class | Superclasses | Remarks |
+=================================+==============+================+=========+
| ``alias`` FNAME FNAME | AliasStmt_ | Stmt_ | |
+---------------------------------+--------------+----------------+---------+
| ``BEGIN {`` StmtSequence_ ``}`` | BeginBlock_ | StmtSequence_ | |
+---------------------------------+--------------+----------------+---------+
| ``begin`` StmtSequence_ ``end`` | BeginExpr_ | StmtSequence_ | |
+---------------------------------+--------------+----------------+---------+
| ``break`` «Expr_»? | BreakStmt_ | ReturningStmt_ | |
+---------------------------------+--------------+----------------+---------+
| ``;`` | EmptyStmt_ | Stmt_ | |
+---------------------------------+--------------+----------------+---------+
| ``END {`` StmtSequence_ ``}`` | EndBlock_ | StmtSequence_ | |
+---------------------------------+--------------+----------------+---------+
| ``next`` «Expr_»? | NextStmt_ | ReturningStmt_ | |
+---------------------------------+--------------+----------------+---------+
| ``redo`` | RedoStmt_ | Stmt_ | |
+---------------------------------+--------------+----------------+---------+
| ``retry`` | RetryStmt_ | Stmt_ | |
+---------------------------------+--------------+----------------+---------+
| ``return`` «Expr_»? | ReturnStmt_ | ReturningStmt_ | |
+---------------------------------+--------------+----------------+---------+
| ``undef`` «FNAME ``,``»+ | UndefStmt_ | Stmt_ | |
+---------------------------------+--------------+----------------+---------+
Calls
~~~~~
+-------------------------+---------------------+----------------+-------------------------------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+=========================+=====================+================+===============================+
| Expr_ ``[`` Expr_ ``]`` | ElementReference_ | MethodCall_ | |
+-------------------------+---------------------+----------------+-------------------------------+
| MethodName_ (, Expr_) | MethodCall_ | Call_ | |
+-------------------------+---------------------+----------------+-------------------------------+
| LhsExpr_ ``=`` Expr_ | SetterMethodCall_ | MethodCall_ | |
+-------------------------+---------------------+----------------+-------------------------------+
| ``super`` | SuperCall_ | MethodCall_ | |
+-------------------------+---------------------+----------------+-------------------------------+
| ``yield`` (, Expr_) | YieldCall_ | Call_ | |
+-------------------------+---------------------+----------------+-------------------------------+
| ``&IDENTIFIER`` | BlockArgument_ | Expr_ | Used as an argument to a call |
+-------------------------+---------------------+----------------+-------------------------------+
| ``...`` | ForwardedArguments_ | Expr_ | Used as an argument to a call |
+-------------------------+---------------------+----------------+-------------------------------+
+----------------------------+---------------------+----------------+-------------------------------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+============================+=====================+================+===============================+
| Expr_ ``[`` Expr_ ``]`` | ElementReference_ | MethodCall_ | |
+----------------------------+---------------------+----------------+-------------------------------+
| MethodName_ «Expr_ ``,``»* | MethodCall_ | Call_ | |
+----------------------------+---------------------+----------------+-------------------------------+
| LhsExpr_ ``=`` Expr_ | SetterMethodCall_ | MethodCall_ | |
+----------------------------+---------------------+----------------+-------------------------------+
| ``super`` | SuperCall_ | MethodCall_ | |
+----------------------------+---------------------+----------------+-------------------------------+
| ``yield`` «Expr_ ``,``»* | YieldCall_ | Call_ | |
+----------------------------+---------------------+----------------+-------------------------------+
| ``&IDENTIFIER`` | BlockArgument_ | Expr_ | Used as an argument to a call |
+----------------------------+---------------------+----------------+-------------------------------+
| ``...`` | ForwardedArguments_ | Expr_ | Used as an argument to a call |
+----------------------------+---------------------+----------------+-------------------------------+
Constant accesses
~~~~~~~~~~~~~~~~~
@@ -83,32 +83,33 @@ Control expressions
All classes in this subsection are subclasses of ControlExpr_.
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+===============================================================================================================================+=====================+================================+=========+
| ``if`` Expr_ ``then`` StmtSequence_ {``elsif`` Expr_ ``then`` StmtSequence_} [``else`` StmtSequence_] ``end`` | IfExpr_ | ConditionalExpr_, ControlExpr_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``while`` Expr_ ``do`` StmtSequence_ ``end`` | WhileExpr_ | ConditionalLoop_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``until`` Expr_ ``do`` StmtSequence_ ``end`` | UntilExpr_ | ConditionalLoop_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``for`` LhsExpr_ ``in`` Expr_ ``do`` StmtSequence_ ``end`` | ForExpr_ | Loop_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Stmt_ ``while`` Expr_ | WhileModifierExpr_ | ConditionalLoop_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Stmt_ ``until`` Expr_ | UntilModifierExpr_ | ConditionalLoop_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Stmt_ ``if`` Expr_ | IfModifierExpr_ | ConditionalExpr_, ControlExpr_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Stmt_ ``unless`` Expr_ | UnlessModifierExpr_ | ConditionalExpr_, ControlExpr_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Expr_ ``?`` Stmt_ ``:`` Stmt_ | TernaryIfExpr_ | ConditionalExpr_, ControlExpr_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``case`` Expr_ ``when`` Expr_ ``then`` StmtSequence_ {``when`` Expr_ ``then`` StmtSequence_} [``else`` StmtSequence_] ``end`` | CaseExpr_ | ControlExpr_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``case when`` Expr_ ``then`` StmtSequence_ [``else`` StmtSequence_] ``end`` | CaseExpr_ | ControlExpr_ | |
+-------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+=================================================================================================================================+=====================+================================+=========+
| ``if`` Expr_ ``then`` StmtSequence_ «``elsif`` Expr_ ``then`` StmtSequence_»* «``else`` StmtSequence_»? ``end`` | IfExpr_ | ConditionalExpr_, ControlExpr_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``while`` Expr_ ``do`` StmtSequence_ ``end`` | WhileExpr_ | ConditionalLoop_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``until`` Expr_ ``do`` StmtSequence_ ``end`` | UntilExpr_ | ConditionalLoop_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``for`` LhsExpr_ ``in`` Expr_ ``do`` StmtSequence_ ``end`` | ForExpr_ | Loop_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Stmt_ ``while`` Expr_ | WhileModifierExpr_ | ConditionalLoop_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Stmt_ ``until`` Expr_ | UntilModifierExpr_ | ConditionalLoop_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Stmt_ ``if`` Expr_ | IfModifierExpr_ | ConditionalExpr_, ControlExpr_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Stmt_ ``unless`` Expr_ | UnlessModifierExpr_ | ConditionalExpr_, ControlExpr_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| Expr_ ``?`` Stmt_ ``:`` Stmt_ | TernaryIfExpr_ | ConditionalExpr_, ControlExpr_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``case`` Expr_ ``when`` Expr_ ``then`` StmtSequence_ «``when`` Expr_ ``then`` StmtSequence_»* «``else`` StmtSequence_»? ``end`` | CaseExpr_ | ControlExpr_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``case when`` Expr_ ``then`` StmtSequence_ «``else`` StmtSequence_»? ``end`` | CaseExpr_ | ControlExpr_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
| ``case`` Expr_ ``in`` «TERM CaseExpr_»+ ``end`` f | CaseExpr_ | ControlExpr_ | |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------+--------------------------------+---------+
Unary operations
~~~~~~~~~~~~~~~~
@@ -277,89 +278,139 @@ All classes in this subsection are subclasses of BodyStmt_ and Scope_.
+----------------------------------------------------------------+--------------------+----------------------------------+-------------------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+================================================================+====================+==================================+===================+
| ``class`` CNAME [``<`` Expr_] TERM StmtSequence_ TERM ``end`` | ClassDeclaration_ | Namespace_, ConstantWriteAccess_ | |
| ``class`` CNAME «``<`` Expr_»? TERM StmtSequence_ TERM ``end`` | ClassDeclaration_ | Namespace_, ConstantWriteAccess_ | |
+----------------------------------------------------------------+--------------------+----------------------------------+-------------------+
| ``module`` CNAME TERM StmtSequence_ TERM ``end`` | ModuleDeclaration_ | Namespace_, ConstantWriteAccess_ | |
+----------------------------------------------------------------+--------------------+----------------------------------+-------------------+
| ``class <<`` Expr_ TERM StmtSequence_ TERM ``end`` | SingletonClass_ | ModuleBase_ | |
+----------------------------------------------------------------+--------------------+----------------------------------+-------------------+
Method classes
~~~~~~~~~~~~~~
Callable classes
~~~~~~~~~~~~~~~~
All classes in this subsection are subclasses of Callable_.
+----------------------------------------+----------------------+----------------------+-------------------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+========================================+======================+======================+===================+
| | BraceBlock_ | Block_ | |
| | Callable_ | | |
| | DoBlock_ | Block_ | |
| | Lambda_ | | |
| | Method_ | | |
| | MethodBase_ | | |
| | SingletonMethod_ | | |
..
Expr.qll
| TODO | ArgumentList_ | Expr_ | The right-hand side of an assignment or a ``return``, ``break``, or ``next`` statement |
| StmtSequence_ TODO | BodyStmt_ | StmtSequence_ | |
| TODO | DestructuredLhsExpr_ | LhsExpr_ | |
| TODO | LhsExpr_ | Expr_ | |
| ``IDENTIFIER:`` Expr_ | Pair_ | Expr_ | Such as in a hash or as a keyword argument |
| ``(`` StmtSequence_ ``)`` | ParenthesizedExpr_ | StmtSequence_ | |
| ``rescue`` TODO | RescueClause_ | Expr_ | |
| Stmt_ ``rescue`` Stmt_ | RescueModifierExpr_ | Expr_ | |
| StmtSequence_ TERM Stmt_ | StmtSequence_ | Expr_ | A sequence of 0 or more statements, separated by semicolons or newlines |
| StringLiteral_ StringLiteral_ | StringConcatenation_ | Expr_ | Implicit concatenation of consecutive string literals |
+----------------------------------------------------------------------+----------------------+----------------------+-------------------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+======================================================================+======================+======================+===================+
| ``{`` «``|`` «Parameter_ ``,``»* ``|``»? StmtSequence_ ``}`` | BraceBlock_ | Block_ | |
+----------------------------------------------------------------------+----------------------+----------------------+-------------------+
| ``do`` «``|`` «Parameter_ ``,``»* ``|``»? BodyStmt_ ``end`` | DoBlock_ | Block_, BodyStmt_ | |
+----------------------------------------------------------------------+----------------------+----------------------+-------------------+
| ``-> (`` «Parameter_ ``,``»* ``)`` ``{`` StmtSequence_ ``}`` | Lambda_ | Callable_, BodyStmt_ | |
+----------------------------------------------------------------------+----------------------+----------------------+-------------------+
| ``-> (`` «Parameter_ ``,``»* ``)`` ``do`` BodyStmt_ ``end`` | Lambda_ | Callable_, BodyStmt_ | |
+----------------------------------------------------------------------+----------------------+----------------------+-------------------+
| ``def`` FNAME «Parameter_ ``,``»* TERM BodyStmt_ TERM ``end`` | Method_ | MethodBase_ | |
+----------------------------------------------------------------------+----------------------+----------------------+-------------------+
| ``def self.`` FNAME «Parameter_ ``,``»* TERM BodyStmt_ TERM ``end`` | SingletonMethod_ | MethodBase_ | |
+----------------------------------------------------------------------+----------------------+----------------------+-------------------+
..
Parameter.qll
| | BlockParameter_ | | |
| | DestructuredParameter_ | | |
| | ForwardParameter_ | | |
| | HashSplatNilParameter_ | | |
| | HashSplatParameter_ | | |
| | KeywordParameter_ | | |
| | NamedParameter_ | | |
| | OptionalParameter_ | | |
| | Parameter_ | | |
| | SimpleParameter_ | | |
| | SplatParameter_ | | |
Parameter classes
~~~~~~~~~~~~~~~~~
..
Pattern.qll
| | AlternativePattern_ | | |
| | ArrayPattern_ | | |
| | AsPattern_ | | |
| | CasePattern_ | | |
| | FindPattern_ | | |
| | HashPattern_ | | |
| | ParenthesizedPattern_ | | |
| | ReferencePattern_ | | |
All classes in this subsection are subclasses of Parameter_.
..
Variable.qll
| | ClassVariable_ | | |
| | ClassVariableAccess_ | | |
| | ClassVariableReadAccess_ | | |
| | ClassVariableWriteAccess_ | | |
| | GlobalVariable_ | | |
| | GlobalVariableAccess_ | | |
| | GlobalVariableReadAccess_ | | |
| | GlobalVariableWriteAccess_ | | |
| | InstanceVariable_ | | |
| | InstanceVariableAccess_ | | |
| | InstanceVariableReadAccess_ | | |
| | InstanceVariableWriteAccess_ | | |
| | LocalVariable_ | | |
| | LocalVariableAccess_ | | |
| | LocalVariableReadAccess_ | | |
| | LocalVariableWriteAccess_ | | |
| | SelfVariable_ | | |
| | SelfVariableAccess_ | | |
| | SelfVariableReadAccess_ | | |
| | Variable_ | | |
| | VariableAccess_ | | |
| | VariableReadAccess_ | | |
| | VariableWriteAccess_ | | |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+============================================================+========================+======================+====================================================================+
| ``&`` IDENTIFIER | BlockParameter_ | NamedParameter_ | |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
| ``(`` «IDENTIFIER ``,``»+ ``)`` | DestructuredParameter_ | | |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
| ``...`` | ForwardParameter_ | | |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
| ``**nil`` | HashSplatNilParameter_ | | Indicates that there are no keyword parameters or keyword patterns |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
| ``**`` IDENTIFIER | HashSplatParameter_ | NamedParameter_ | |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
| IDENTIFIER ``:`` «Expr_»? | KeywordParameter_ | NamedParameter_ | |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
| IDENTIFIER ``=`` Expr_ | OptionalParameter_ | NamedParameter_ | |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
| IDENTIFIER | SimpleParameter_ | NamedParameter_ | |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
| ``*`` IDENTIFIER | SplatParameter_ | NamedParameter_ | |
+------------------------------------------------------------+------------------------+----------------------+--------------------------------------------------------------------+
Pattern classes
~~~~~~~~~~~~~~~
All classes in this subsection are subclasses of CasePattern_. These expressions typically occur in the context of a ``case`` using pattern matching syntax.
+--------------------------------------------------------------------------------+-----------------------+--------------+-------------------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+================================================================================+=======================+==============+===================+
| CasePattern_ «``|`` CasePattern_»+ | AlternativePattern_ | CasePattern_ | |
+--------------------------------------------------------------------------------+-----------------------+--------------+-------------------+
| ``[`` «CasePattern ``,``»* «``*`` IDENTIFIER»? ``]`` | ArrayPattern_ | CasePattern_ | |
+--------------------------------------------------------------------------------+-----------------------+--------------+-------------------+
| CasePattern_ ``=>`` IDENTIFIER | AsPattern_ | CasePattern_ | |
+--------------------------------------------------------------------------------+-----------------------+--------------+-------------------+
| ``[`` ``*`` «IDENTIFIER»? (``,`` CasePattern)* ``,`` ``*`` «IDENTIFIER»? ``]`` | FindPattern_ | CasePattern_ | |
+--------------------------------------------------------------------------------+-----------------------+--------------+-------------------+
| ``{`` «StringlikeLiteral_ ``:`` CasePattern ``,``»* «``**`` IDENTIFIER»? ``}`` | HashPattern_ | CasePattern_ | |
+--------------------------------------------------------------------------------+-----------------------+--------------+-------------------+
| ``(`` CasePattern_ ``)`` | ParenthesizedPattern_ | CasePattern_ | |
+--------------------------------------------------------------------------------+-----------------------+--------------+-------------------+
| ``^`` Expr_ | ReferencePattern_ | CasePattern_ | |
+--------------------------------------------------------------------------------+-----------------------+--------------+-------------------+
Expression classes
~~~~~~~~~~~~~~~~~~
All classes in this subsection are subclasses of Expr_.
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| Expression syntax | CodeQL class | Superclasses | Remarks |
+======================================================================================+======================+===============+========================================================================================+
| «Expr_ ``,``»+ | ArgumentList_ | Expr_ | The right-hand side of an assignment or a ``return``, ``break``, or ``next`` statement |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| StmtSequence_ «RescueClause_»? «``else`` StmtSequence_»? «``ensure`` StmtSequence_»? | BodyStmt_ | StmtSequence_ | |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| Expr_ «``,`` Expr_»+ | DestructuredLhsExpr_ | LhsExpr_ | |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| Expr_ | LhsExpr_ | Expr_ | An Expr_ appearing on the left-hand side of various operations. Can take many forms. |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| Expr_ ``:`` Expr_ | Pair_ | Expr_ | Such as in a hash or as a keyword argument |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| ``(`` StmtSequence_ ``)`` | ParenthesizedExpr_ | StmtSequence_ | |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| ``rescue`` StmtSequence_ | RescueClause_ | Expr_ | |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| Stmt_ ``rescue`` Stmt_ | RescueModifierExpr_ | Expr_ | |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| StmtSequence_ TERM Stmt_ | StmtSequence_ | Expr_ | A sequence of 0 or more statements, separated by semicolons or newlines |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
| StringLiteral_ StringLiteral_ | StringConcatenation_ | Expr_ | Implicit concatenation of consecutive string literals |
+--------------------------------------------------------------------------------------+----------------------+---------------+----------------------------------------------------------------------------------------+
Variable classes
~~~~~~~~~~~~~~~~
All classes in this subsection are subclasses of VariableAccess_.
+----------------------------+------------------------------+-----------------------------------------------+------------------+
| Example expression syntax | CodeQL class | Superclasses | Remarks |
+===========================+==============================+================================================+==================+
| ``@@foo`` | ClassVariableReadAccess_ | VariableReadAccess_, ClassVariableAccess_ | |
+----------------------------+------------------------------+-----------------------------------------------+------------------+
| ``@@foo = 'str'`` | ClassVariableWriteAccess_ | VariableWriteAccess_, ClassVariableAccess_ | |
+----------------------------+------------------------------+-----------------------------------------------+------------------+
| ``$foo`` | GlobalVariableReadAccess_ | VariableReadAccess_, GlobalVariableAccess_ | |
+----------------------------+------------------------------+-----------------------------------------------+------------------+
| ``$foo = 'str'`` | GlobalVariableWriteAccess_ | VariableWriteAccess_, GlobalVariableAccess_ | |
+----------------------------+------------------------------+-----------------------------------------------+------------------+
| ``@foo`` | InstanceVariableReadAccess_ | VariableReadAccess_, InstanceVariableAccess_ | |
+----------------------------+------------------------------+-----------------------------------------------+------------------+
| ``@foo = 'str'`` | InstanceVariableWriteAccess_ | VariableWriteAccess_, InstanceVariableAccess_ | |
+----------------------------+------------------------------+-----------------------------------------------+------------------+
| ``foo`` | LocalVariableReadAccess_ | VariableReadAccess_, LocalVariableAccess_ | |
+----------------------------+------------------------------+-----------------------------------------------+------------------+
| ``foo = 'str'`` | LocalVariableWriteAccess_ | VariableWriteAccess_, LocalVariableAccess_ | |
+----------------------------+------------------------------+-----------------------------------------------+------------------+
| ``self`` | SelfVariableReadAccess_ | VariableReadAccess_, SelfVariableAccess_ | |
+----------------------------+------------------------------+-----------------------------------------------+------------------+
.. _BlockArgument: https://codeql.github.com/codeql-standard-libraries/ruby/codeql/ruby/ast/Call.qll/type.Call$BlockArgument.html
.. _Call: https://codeql.github.com/codeql-standard-libraries/ruby/codeql/ruby/ast/Call.qll/type.Call$Call.html