зеркало из https://github.com/github/codeql.git
QL: Add parser support for parameterised modules
This commit is contained in:
Родитель
84518c8d54
Коммит
a08be0d9b9
|
@ -514,7 +514,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "tree-sitter-ql"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/tausbn/tree-sitter-ql.git?rev=725395405e65814f10095a451404b0ced5dc6289#725395405e65814f10095a451404b0ced5dc6289"
|
||||
source = "git+https://github.com/tausbn/tree-sitter-ql.git?rev=4239ed505a53e9f5340e03725de76911d17387b1#4239ed505a53e9f5340e03725de76911d17387b1"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
|
|
|
@ -10,7 +10,7 @@ edition = "2018"
|
|||
flate2 = "1.0"
|
||||
node-types = { path = "../node-types" }
|
||||
tree-sitter = "0.19"
|
||||
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "725395405e65814f10095a451404b0ced5dc6289" }
|
||||
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "4239ed505a53e9f5340e03725de76911d17387b1" }
|
||||
clap = "2.33"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }
|
||||
|
|
|
@ -11,4 +11,4 @@ clap = "2.33"
|
|||
node-types = { path = "../node-types" }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }
|
||||
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "725395405e65814f10095a451404b0ced5dc6289" }
|
||||
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "4239ed505a53e9f5340e03725de76911d17387b1" }
|
||||
|
|
|
@ -944,15 +944,24 @@ module QL {
|
|||
/** Gets the name of the primary QL class for this element. */
|
||||
final override string getAPrimaryQlClass() { result = "Module" }
|
||||
|
||||
/** Gets the node corresponding to the field `implements`. */
|
||||
final AstNode getImplements(int i) { ql_module_implements(this, i, result) }
|
||||
|
||||
/** Gets the node corresponding to the field `name`. */
|
||||
final ModuleName getName() { ql_module_def(this, result) }
|
||||
|
||||
/** Gets the node corresponding to the field `parameter`. */
|
||||
final AstNode getParameter(int i) { ql_module_parameter(this, i, result) }
|
||||
|
||||
/** Gets the `i`th child of this node. */
|
||||
final AstNode getChild(int i) { ql_module_child(this, i, result) }
|
||||
|
||||
/** Gets a field or child node of this node. */
|
||||
final override AstNode getAFieldOrChild() {
|
||||
ql_module_def(this, result) or ql_module_child(this, _, result)
|
||||
ql_module_implements(this, _, result) or
|
||||
ql_module_def(this, result) or
|
||||
ql_module_parameter(this, _, result) or
|
||||
ql_module_child(this, _, result)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -968,6 +977,18 @@ module QL {
|
|||
final override AstNode getAFieldOrChild() { ql_module_alias_body_def(this, result) }
|
||||
}
|
||||
|
||||
/** A class representing `moduleApplication` nodes. */
|
||||
class ModuleApplication extends @ql_module_application, AstNode {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
final override string getAPrimaryQlClass() { result = "ModuleApplication" }
|
||||
|
||||
/** Gets the `i`th child of this node. */
|
||||
final SignatureExpr getChild(int i) { ql_module_application_child(this, i, result) }
|
||||
|
||||
/** Gets a field or child node of this node. */
|
||||
final override AstNode getAFieldOrChild() { ql_module_application_child(this, _, result) }
|
||||
}
|
||||
|
||||
/** A class representing `moduleExpr` nodes. */
|
||||
class ModuleExpr extends @ql_module_expr, AstNode {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
|
@ -1009,6 +1030,18 @@ module QL {
|
|||
final override AstNode getAFieldOrChild() { ql_module_name_def(this, result) }
|
||||
}
|
||||
|
||||
/** A class representing `moduleParam` nodes. */
|
||||
class ModuleParam extends @ql_module_param, AstNode {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
final override string getAPrimaryQlClass() { result = "ModuleParam" }
|
||||
|
||||
/** Gets the `i`th child of this node. */
|
||||
final AstNode getChild(int i) { ql_module_param_child(this, i, result) }
|
||||
|
||||
/** Gets a field or child node of this node. */
|
||||
final override AstNode getAFieldOrChild() { ql_module_param_child(this, _, result) }
|
||||
}
|
||||
|
||||
/** A class representing `mul_expr` nodes. */
|
||||
class MulExpr extends @ql_mul_expr, AstNode {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
|
@ -1277,6 +1310,23 @@ module QL {
|
|||
final override AstNode getAFieldOrChild() { ql_set_literal_child(this, _, result) }
|
||||
}
|
||||
|
||||
/** A class representing `signatureExpr` nodes. */
|
||||
class SignatureExpr extends @ql_signature_expr, AstNode {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
final override string getAPrimaryQlClass() { result = "SignatureExpr" }
|
||||
|
||||
/** Gets the node corresponding to the field `name`. */
|
||||
final SimpleId getName() { ql_signature_expr_def(this, result) }
|
||||
|
||||
/** Gets the `i`th child of this node. */
|
||||
final AstNode getChild(int i) { ql_signature_expr_child(this, i, result) }
|
||||
|
||||
/** Gets a field or child node of this node. */
|
||||
final override AstNode getAFieldOrChild() {
|
||||
ql_signature_expr_def(this, result) or ql_signature_expr_child(this, _, result)
|
||||
}
|
||||
}
|
||||
|
||||
/** A class representing `simpleId` tokens. */
|
||||
class SimpleId extends @ql_token_simple_id, Token {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
|
|
|
@ -601,6 +601,24 @@ ql_member_predicate_def(
|
|||
int return_type: @ql_memberPredicate_returnType_type ref
|
||||
);
|
||||
|
||||
@ql_module_implements_type = @ql_reserved_word | @ql_signature_expr
|
||||
|
||||
#keyset[ql_module, index]
|
||||
ql_module_implements(
|
||||
int ql_module: @ql_module ref,
|
||||
int index: int ref,
|
||||
unique int implements: @ql_module_implements_type ref
|
||||
);
|
||||
|
||||
@ql_module_parameter_type = @ql_module_param | @ql_reserved_word
|
||||
|
||||
#keyset[ql_module, index]
|
||||
ql_module_parameter(
|
||||
int ql_module: @ql_module ref,
|
||||
int index: int ref,
|
||||
unique int parameter: @ql_module_parameter_type ref
|
||||
);
|
||||
|
||||
@ql_module_child_type = @ql_module_alias_body | @ql_module_member
|
||||
|
||||
#keyset[ql_module, index]
|
||||
|
@ -620,12 +638,23 @@ ql_module_alias_body_def(
|
|||
int child: @ql_module_expr ref
|
||||
);
|
||||
|
||||
#keyset[ql_module_application, index]
|
||||
ql_module_application_child(
|
||||
int ql_module_application: @ql_module_application ref,
|
||||
int index: int ref,
|
||||
unique int child: @ql_signature_expr ref
|
||||
);
|
||||
|
||||
ql_module_application_def(
|
||||
unique int id: @ql_module_application
|
||||
);
|
||||
|
||||
ql_module_expr_name(
|
||||
unique int ql_module_expr: @ql_module_expr ref,
|
||||
unique int name: @ql_token_simple_id ref
|
||||
);
|
||||
|
||||
@ql_moduleExpr_child_type = @ql_module_expr | @ql_token_simple_id
|
||||
@ql_moduleExpr_child_type = @ql_module_application | @ql_module_expr | @ql_token_simple_id
|
||||
|
||||
ql_module_expr_def(
|
||||
unique int id: @ql_module_expr,
|
||||
|
@ -650,6 +679,19 @@ ql_module_name_def(
|
|||
int child: @ql_token_simple_id ref
|
||||
);
|
||||
|
||||
@ql_moduleParam_child_type = @ql_signature_expr | @ql_token_simple_id
|
||||
|
||||
#keyset[ql_module_param, index]
|
||||
ql_module_param_child(
|
||||
int ql_module_param: @ql_module_param ref,
|
||||
int index: int ref,
|
||||
unique int child: @ql_moduleParam_child_type ref
|
||||
);
|
||||
|
||||
ql_module_param_def(
|
||||
unique int id: @ql_module_param
|
||||
);
|
||||
|
||||
@ql_mul_expr_left_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
||||
@ql_mul_expr_right_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
|
||||
|
@ -855,6 +897,20 @@ ql_set_literal_def(
|
|||
unique int id: @ql_set_literal
|
||||
);
|
||||
|
||||
@ql_signatureExpr_child_type = @ql_module_expr | @ql_token_integer
|
||||
|
||||
#keyset[ql_signature_expr, index]
|
||||
ql_signature_expr_child(
|
||||
int ql_signature_expr: @ql_signature_expr ref,
|
||||
int index: int ref,
|
||||
unique int child: @ql_signatureExpr_child_type ref
|
||||
);
|
||||
|
||||
ql_signature_expr_def(
|
||||
unique int id: @ql_signature_expr,
|
||||
int name: @ql_token_simple_id ref
|
||||
);
|
||||
|
||||
ql_special_call_def(
|
||||
unique int id: @ql_special_call,
|
||||
int child: @ql_token_special_id ref
|
||||
|
@ -1057,7 +1113,7 @@ case @ql_token.kind of
|
|||
;
|
||||
|
||||
|
||||
@ql_ast_node = @ql_add_expr | @ql_aggregate | @ql_annot_arg | @ql_annotation | @ql_arityless_predicate_expr | @ql_as_expr | @ql_as_exprs | @ql_body | @ql_bool | @ql_call_body | @ql_call_or_unqual_agg_expr | @ql_charpred | @ql_class_member | @ql_classless_predicate | @ql_comp_term | @ql_conjunction | @ql_dataclass | @ql_datatype | @ql_datatype_branch | @ql_datatype_branches | @ql_db_annotation | @ql_db_args_annotation | @ql_db_branch | @ql_db_case_decl | @ql_db_col_type | @ql_db_column | @ql_db_entry | @ql_db_repr_type | @ql_db_table | @ql_db_table_name | @ql_db_union_decl | @ql_disjunction | @ql_expr_aggregate_body | @ql_expr_annotation | @ql_field | @ql_full_aggregate_body | @ql_higher_order_term | @ql_if_term | @ql_implication | @ql_import_directive | @ql_import_module_expr | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_member_predicate | @ql_module | @ql_module_alias_body | @ql_module_expr | @ql_module_member | @ql_module_name | @ql_mul_expr | @ql_negation | @ql_order_by | @ql_order_bys | @ql_par_expr | @ql_predicate_alias_body | @ql_predicate_expr | @ql_prefix_cast | @ql_ql | @ql_qual_module_expr | @ql_qualified_expr | @ql_qualified_rhs | @ql_quantified | @ql_range | @ql_select | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_token | @ql_type_alias_body | @ql_type_expr | @ql_type_union_body | @ql_unary_expr | @ql_unqual_agg_body | @ql_var_decl | @ql_var_name | @ql_variable | @ql_yaml_comment | @ql_yaml_entry | @ql_yaml_key | @ql_yaml_keyvaluepair | @ql_yaml_listitem
|
||||
@ql_ast_node = @ql_add_expr | @ql_aggregate | @ql_annot_arg | @ql_annotation | @ql_arityless_predicate_expr | @ql_as_expr | @ql_as_exprs | @ql_body | @ql_bool | @ql_call_body | @ql_call_or_unqual_agg_expr | @ql_charpred | @ql_class_member | @ql_classless_predicate | @ql_comp_term | @ql_conjunction | @ql_dataclass | @ql_datatype | @ql_datatype_branch | @ql_datatype_branches | @ql_db_annotation | @ql_db_args_annotation | @ql_db_branch | @ql_db_case_decl | @ql_db_col_type | @ql_db_column | @ql_db_entry | @ql_db_repr_type | @ql_db_table | @ql_db_table_name | @ql_db_union_decl | @ql_disjunction | @ql_expr_aggregate_body | @ql_expr_annotation | @ql_field | @ql_full_aggregate_body | @ql_higher_order_term | @ql_if_term | @ql_implication | @ql_import_directive | @ql_import_module_expr | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_member_predicate | @ql_module | @ql_module_alias_body | @ql_module_application | @ql_module_expr | @ql_module_member | @ql_module_name | @ql_module_param | @ql_mul_expr | @ql_negation | @ql_order_by | @ql_order_bys | @ql_par_expr | @ql_predicate_alias_body | @ql_predicate_expr | @ql_prefix_cast | @ql_ql | @ql_qual_module_expr | @ql_qualified_expr | @ql_qualified_rhs | @ql_quantified | @ql_range | @ql_select | @ql_set_literal | @ql_signature_expr | @ql_special_call | @ql_super_ref | @ql_token | @ql_type_alias_body | @ql_type_expr | @ql_type_union_body | @ql_unary_expr | @ql_unqual_agg_body | @ql_var_decl | @ql_var_name | @ql_variable | @ql_yaml_comment | @ql_yaml_entry | @ql_yaml_key | @ql_yaml_keyvaluepair | @ql_yaml_listitem
|
||||
|
||||
@ql_ast_node_parent = @file | @ql_ast_node
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче