Merge pull request #150 from github/parent_child

Create `ast_node_parent` relation
This commit is contained in:
Nick Rolfe
2021-03-22 15:06:50 +00:00
committed by GitHub
21 changed files with 2825 additions and 42831 deletions

View File

@@ -328,11 +328,17 @@ impl Visitor<'_> {
match &table.kind {
EntryKind::Token { kind_id, .. } => {
self.trap_writer.add_tuple(
"tokeninfo",
"ast_node_parent",
vec![
Arg::Label(id),
Arg::Label(parent_id),
Arg::Int(parent_index),
],
);
self.trap_writer.add_tuple(
"tokeninfo",
vec![
Arg::Label(id),
Arg::Int(*kind_id),
Arg::Label(self.file_label),
Arg::Int(self.token_counter),
@@ -347,10 +353,16 @@ impl Visitor<'_> {
name: table_name,
} => {
if let Some(args) = self.complex_node(&node, fields, &child_nodes, id) {
self.trap_writer.add_tuple(
"ast_node_parent",
vec![
Arg::Label(id),
Arg::Label(parent_id),
Arg::Int(parent_index),
],
);
let mut all_args = Vec::new();
all_args.push(Arg::Label(id));
all_args.push(Arg::Label(parent_id));
all_args.push(Arg::Int(parent_index));
all_args.extend(args);
all_args.push(Arg::Label(loc));
self.trap_writer.add_tuple(&table_name, all_args);

View File

@@ -178,30 +178,14 @@ fn convert_nodes<'a>(nodes: &'a node_types::NodeTypeMap) -> Vec<dbscheme::Entry<
// It's a product type, defined by a table.
let mut main_table = dbscheme::Table {
name: &name,
columns: vec![
dbscheme::Column {
db_type: dbscheme::DbColumnType::Int,
name: "id",
unique: true,
ql_type: ql::Type::AtType(&node.dbscheme_name),
ql_type_is_ref: false,
},
dbscheme::Column {
db_type: dbscheme::DbColumnType::Int,
name: "parent",
unique: false,
ql_type: ql::Type::AtType("ast_node_parent"),
ql_type_is_ref: true,
},
dbscheme::Column {
unique: false,
db_type: dbscheme::DbColumnType::Int,
name: "parent_index",
ql_type: ql::Type::Int,
ql_type_is_ref: true,
},
],
keysets: Some(vec!["parent", "parent_index"]),
columns: vec![dbscheme::Column {
db_type: dbscheme::DbColumnType::Int,
name: "id",
unique: true,
ql_type: ql::Type::AtType(&node.dbscheme_name),
ql_type_is_ref: false,
}],
keysets: None,
};
ast_node_members.insert(&node.dbscheme_name);
@@ -275,22 +259,21 @@ fn convert_nodes<'a>(nodes: &'a node_types::NodeTypeMap) -> Vec<dbscheme::Entry<
name: "ast_node_parent",
members: ["ast_node", "file"].iter().cloned().collect(),
}));
entries.push(dbscheme::Entry::Table(create_ast_node_parent_table()));
entries
}
fn create_tokeninfo<'a>(
token_kinds: Map<&'a str, usize>,
) -> (dbscheme::Case<'a>, dbscheme::Table<'a>) {
let table = dbscheme::Table {
name: "tokeninfo",
keysets: Some(vec!["parent", "parent_index"]),
fn create_ast_node_parent_table<'a>() -> dbscheme::Table<'a> {
dbscheme::Table {
name: "ast_node_parent",
columns: vec![
dbscheme::Column {
db_type: dbscheme::DbColumnType::Int,
name: "id",
unique: true,
ql_type: ql::Type::AtType("token"),
ql_type_is_ref: false,
name: "child",
unique: false,
ql_type: ql::Type::AtType("ast_node"),
ql_type_is_ref: true,
},
dbscheme::Column {
db_type: dbscheme::DbColumnType::Int,
@@ -306,6 +289,25 @@ fn create_tokeninfo<'a>(
ql_type: ql::Type::Int,
ql_type_is_ref: true,
},
],
keysets: Some(vec!["parent", "parent_index"]),
}
}
fn create_tokeninfo<'a>(
token_kinds: Map<&'a str, usize>,
) -> (dbscheme::Case<'a>, dbscheme::Table<'a>) {
let table = dbscheme::Table {
name: "tokeninfo",
keysets: None,
columns: vec![
dbscheme::Column {
db_type: dbscheme::DbColumnType::Int,
name: "id",
unique: true,
ql_type: ql::Type::AtType("token"),
ql_type_is_ref: false,
},
dbscheme::Column {
unique: false,
db_type: dbscheme::DbColumnType::Int,

View File

@@ -46,8 +46,34 @@ fn create_ast_node_class<'a>() -> ql::Class<'a> {
create_none_predicate("getLocation", false, Some(ql::Type::Normal("Location")));
let get_a_field_or_child =
create_none_predicate("getAFieldOrChild", false, Some(ql::Type::Normal("AstNode")));
let get_parent = create_none_predicate("getParent", false, Some(ql::Type::Normal("AstNode")));
let get_parent_index = create_none_predicate("getParentIndex", false, Some(ql::Type::Int));
let get_parent = ql::Predicate {
name: "getParent",
overridden: false,
return_type: Some(ql::Type::Normal("AstNode")),
formal_parameters: vec![],
body: ql::Expression::Pred(
"ast_node_parent",
vec![
ql::Expression::Var("this"),
ql::Expression::Var("result"),
ql::Expression::Var("_"),
],
),
};
let get_parent_index = ql::Predicate {
name: "getParentIndex",
overridden: false,
return_type: Some(ql::Type::Int),
formal_parameters: vec![],
body: ql::Expression::Pred(
"ast_node_parent",
vec![
ql::Expression::Var("this"),
ql::Expression::Var("_"),
ql::Expression::Var("result"),
],
),
};
let get_a_primary_ql_class = ql::Predicate {
name: "getAPrimaryQlClass",
overridden: false,
@@ -75,33 +101,20 @@ fn create_ast_node_class<'a>() -> ql::Class<'a> {
}
fn create_token_class<'a>() -> ql::Class<'a> {
let get_parent = ql::Predicate {
name: "getParent",
overridden: true,
return_type: Some(ql::Type::Normal("AstNode")),
formal_parameters: vec![],
body: create_get_field_expr_for_column_storage("result", "tokeninfo", 0, 8),
};
let get_parent_index = ql::Predicate {
name: "getParentIndex",
overridden: true,
return_type: Some(ql::Type::Int),
formal_parameters: vec![],
body: create_get_field_expr_for_column_storage("result", "tokeninfo", 1, 8),
};
let tokeninfo_arity = 6;
let get_value = ql::Predicate {
name: "getValue",
overridden: false,
return_type: Some(ql::Type::String),
formal_parameters: vec![],
body: create_get_field_expr_for_column_storage("result", "tokeninfo", 5, 8),
body: create_get_field_expr_for_column_storage("result", "tokeninfo", 3, tokeninfo_arity),
};
let get_location = ql::Predicate {
name: "getLocation",
overridden: true,
return_type: Some(ql::Type::Normal("Location")),
formal_parameters: vec![],
body: create_get_field_expr_for_column_storage("result", "tokeninfo", 6, 8),
body: create_get_field_expr_for_column_storage("result", "tokeninfo", 4, tokeninfo_arity),
};
let to_string = ql::Predicate {
name: "toString",
@@ -121,8 +134,6 @@ fn create_token_class<'a>() -> ql::Class<'a> {
.collect(),
characteristic_predicate: None,
predicates: vec![
get_parent,
get_parent_index,
get_value,
get_location,
to_string,
@@ -476,12 +487,10 @@ pub fn convert_nodes<'a>(nodes: &'a node_types::NodeTypeMap) -> Vec<ql::TopLevel
// Count how many columns there will be in the main table.
// There will be:
// - one for the id
// - one for the parent
// - one for the parent index
// - one for the location
// - one for each field that's stored as a column
// - if there are no fields, one for the text column.
let main_table_arity = 4 + if fields.is_empty() {
let main_table_arity = 2 + if fields.is_empty() {
1
} else {
fields
@@ -512,7 +521,7 @@ pub fn convert_nodes<'a>(nodes: &'a node_types::NodeTypeMap) -> Vec<ql::TopLevel
.predicates
.push(create_get_text_predicate(&main_table_name));
} else {
let mut main_table_column_index: usize = 2;
let mut main_table_column_index: usize = 0;
let mut get_child_exprs: Vec<ql::Expression> = Vec::new();
// Iterate through the fields, creating:
@@ -533,32 +542,6 @@ pub fn convert_nodes<'a>(nodes: &'a node_types::NodeTypeMap) -> Vec<ql::TopLevel
}
}
main_class.predicates.push(ql::Predicate {
name: "getParent",
overridden: true,
return_type: Some(ql::Type::Normal("AstNode")),
formal_parameters: vec![],
body: create_get_field_expr_for_column_storage(
"result",
&main_table_name,
0,
main_table_arity,
),
});
main_class.predicates.push(ql::Predicate {
name: "getParentIndex",
overridden: true,
return_type: Some(ql::Type::Int),
formal_parameters: vec![],
body: create_get_field_expr_for_column_storage(
"result",
&main_table_name,
1,
main_table_arity,
),
});
main_class.predicates.push(ql::Predicate {
name: "getAFieldOrChild",
overridden: true,

File diff suppressed because it is too large Load Diff

View File

@@ -58,11 +58,8 @@ sourceLocationPrefix(
@underscore_variable = @token_class_variable | @token_constant | @token_global_variable | @token_identifier | @token_instance_variable | @token_self | @token_super
#keyset[parent, parent_index]
alias_def(
unique int id: @alias,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int alias: @underscore_method_name ref,
int name: @underscore_method_name ref,
int loc: @location ref
@@ -77,11 +74,8 @@ argument_list_child(
unique int child: @argument_list_child_type ref
);
#keyset[parent, parent_index]
argument_list_def(
unique int id: @argument_list,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -94,11 +88,8 @@ array_child(
unique int child: @array_child_type ref
);
#keyset[parent, parent_index]
array_def(
unique int id: @array,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -106,11 +97,8 @@ array_def(
@assignment_right_type = @break | @call | @next | @return | @right_assignment_list | @splat_argument | @underscore_arg | @yield
#keyset[parent, parent_index]
assignment_def(
unique int id: @assignment,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int left: @assignment_left_type ref,
int right: @assignment_right_type ref,
int loc: @location ref
@@ -125,11 +113,8 @@ bare_string_child(
unique int child: @bare_string_child_type ref
);
#keyset[parent, parent_index]
bare_string_def(
unique int id: @bare_string,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -142,11 +127,8 @@ bare_symbol_child(
unique int child: @bare_symbol_child_type ref
);
#keyset[parent, parent_index]
bare_symbol_def(
unique int id: @bare_symbol,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -159,11 +141,8 @@ begin_child(
unique int child: @begin_child_type ref
);
#keyset[parent, parent_index]
begin_def(
unique int id: @begin,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -176,11 +155,8 @@ begin_block_child(
unique int child: @begin_block_child_type ref
);
#keyset[parent, parent_index]
begin_block_def(
unique int id: @begin_block,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -217,11 +193,8 @@ case @binary.operator of
@binary_right_type = @break | @call | @next | @return | @underscore_arg | @yield
#keyset[parent, parent_index]
binary_def(
unique int id: @binary,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int left: @binary_left_type ref,
int operator: int ref,
int right: @binary_right_type ref,
@@ -242,28 +215,19 @@ block_child(
unique int child: @block_child_type ref
);
#keyset[parent, parent_index]
block_def(
unique int id: @block,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
#keyset[parent, parent_index]
block_argument_def(
unique int id: @block_argument,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @underscore_arg ref,
int loc: @location ref
);
#keyset[parent, parent_index]
block_parameter_def(
unique int id: @block_parameter,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int name: @token_identifier ref,
int loc: @location ref
);
@@ -277,11 +241,8 @@ block_parameters_child(
unique int child: @block_parameters_child_type ref
);
#keyset[parent, parent_index]
block_parameters_def(
unique int id: @block_parameters,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -290,11 +251,8 @@ break_child(
unique int child: @argument_list ref
);
#keyset[parent, parent_index]
break_def(
unique int id: @break,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -319,11 +277,8 @@ call_receiver(
unique int receiver: @call_receiver_type ref
);
#keyset[parent, parent_index]
call_def(
unique int id: @call,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int method: @call_method_type ref,
int loc: @location ref
);
@@ -342,11 +297,8 @@ case_child(
unique int child: @case_child_type ref
);
#keyset[parent, parent_index]
case_def(
unique int id: @case__,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -357,11 +309,8 @@ chained_string_child(
unique int child: @string__ ref
);
#keyset[parent, parent_index]
chained_string_def(
unique int id: @chained_string,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -381,20 +330,14 @@ class_child(
unique int child: @class_child_type ref
);
#keyset[parent, parent_index]
class_def(
unique int id: @class,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int name: @class_name_type ref,
int loc: @location ref
);
#keyset[parent, parent_index]
conditional_def(
unique int id: @conditional,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int alternative: @underscore_arg ref,
int condition: @underscore_arg ref,
int consequence: @underscore_arg ref,
@@ -410,11 +353,8 @@ delimited_symbol_child(
unique int child: @delimited_symbol_child_type ref
);
#keyset[parent, parent_index]
delimited_symbol_def(
unique int id: @delimited_symbol,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -427,11 +367,8 @@ destructured_left_assignment_child(
unique int child: @destructured_left_assignment_child_type ref
);
#keyset[parent, parent_index]
destructured_left_assignment_def(
unique int id: @destructured_left_assignment,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -444,11 +381,8 @@ destructured_parameter_child(
unique int child: @destructured_parameter_child_type ref
);
#keyset[parent, parent_index]
destructured_parameter_def(
unique int id: @destructured_parameter,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -461,11 +395,8 @@ do_child(
unique int child: @do_child_type ref
);
#keyset[parent, parent_index]
do_def(
unique int id: @do,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -483,11 +414,8 @@ do_block_child(
unique int child: @do_block_child_type ref
);
#keyset[parent, parent_index]
do_block_def(
unique int id: @do_block,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -500,11 +428,8 @@ element_reference_child(
unique int child: @element_reference_child_type ref
);
#keyset[parent, parent_index]
element_reference_def(
unique int id: @element_reference,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int object: @underscore_primary ref,
int loc: @location ref
);
@@ -518,11 +443,8 @@ else_child(
unique int child: @else_child_type ref
);
#keyset[parent, parent_index]
else_def(
unique int id: @else,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -538,11 +460,8 @@ elsif_consequence(
unique int consequence: @then ref
);
#keyset[parent, parent_index]
elsif_def(
unique int id: @elsif,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int condition: @underscore_statement ref,
int loc: @location ref
);
@@ -556,11 +475,8 @@ end_block_child(
unique int child: @end_block_child_type ref
);
#keyset[parent, parent_index]
end_block_def(
unique int id: @end_block,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -573,19 +489,13 @@ ensure_child(
unique int child: @ensure_child_type ref
);
#keyset[parent, parent_index]
ensure_def(
unique int id: @ensure,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
#keyset[parent, parent_index]
exception_variable_def(
unique int id: @exception_variable,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @underscore_lhs ref,
int loc: @location ref
);
@@ -599,21 +509,15 @@ exceptions_child(
unique int child: @exceptions_child_type ref
);
#keyset[parent, parent_index]
exceptions_def(
unique int id: @exceptions,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@for_pattern_type = @left_assignment_list | @underscore_lhs
#keyset[parent, parent_index]
for_def(
unique int id: @for,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int body: @do ref,
int pattern: @for_pattern_type ref,
int value: @in ref,
@@ -629,19 +533,13 @@ hash_child(
unique int child: @hash_child_type ref
);
#keyset[parent, parent_index]
hash_def(
unique int id: @hash,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
#keyset[parent, parent_index]
hash_splat_argument_def(
unique int id: @hash_splat_argument,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @underscore_arg ref,
int loc: @location ref
);
@@ -651,11 +549,8 @@ hash_splat_parameter_name(
unique int name: @token_identifier ref
);
#keyset[parent, parent_index]
hash_splat_parameter_def(
unique int id: @hash_splat_parameter,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -668,11 +563,8 @@ heredoc_body_child(
unique int child: @heredoc_body_child_type ref
);
#keyset[parent, parent_index]
heredoc_body_def(
unique int id: @heredoc_body,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -688,32 +580,23 @@ if_consequence(
unique int consequence: @then ref
);
#keyset[parent, parent_index]
if_def(
unique int id: @if,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int condition: @underscore_statement ref,
int loc: @location ref
);
@if_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield
#keyset[parent, parent_index]
if_modifier_def(
unique int id: @if_modifier,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int body: @underscore_statement ref,
int condition: @if_modifier_condition_type ref,
int loc: @location ref
);
#keyset[parent, parent_index]
in_def(
unique int id: @in,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @underscore_arg ref,
int loc: @location ref
);
@@ -727,11 +610,8 @@ interpolation_child(
unique int child: @interpolation_child_type ref
);
#keyset[parent, parent_index]
interpolation_def(
unique int id: @interpolation,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -740,11 +620,8 @@ keyword_parameter_value(
unique int value: @underscore_arg ref
);
#keyset[parent, parent_index]
keyword_parameter_def(
unique int id: @keyword_parameter,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int name: @token_identifier ref,
int loc: @location ref
);
@@ -756,11 +633,8 @@ lambda_parameters(
unique int parameters: @lambda_parameters ref
);
#keyset[parent, parent_index]
lambda_def(
unique int id: @lambda,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int body: @lambda_body_type ref,
int loc: @location ref
);
@@ -774,11 +648,8 @@ lambda_parameters_child(
unique int child: @lambda_parameters_child_type ref
);
#keyset[parent, parent_index]
lambda_parameters_def(
unique int id: @lambda_parameters,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -791,11 +662,8 @@ left_assignment_list_child(
unique int child: @left_assignment_list_child_type ref
);
#keyset[parent, parent_index]
left_assignment_list_def(
unique int id: @left_assignment_list,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -813,11 +681,8 @@ method_child(
unique int child: @method_child_type ref
);
#keyset[parent, parent_index]
method_def(
unique int id: @method,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int name: @underscore_method_name ref,
int loc: @location ref
);
@@ -831,11 +696,8 @@ method_parameters_child(
unique int child: @method_parameters_child_type ref
);
#keyset[parent, parent_index]
method_parameters_def(
unique int id: @method_parameters,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -850,11 +712,8 @@ module_child(
unique int child: @module_child_type ref
);
#keyset[parent, parent_index]
module_def(
unique int id: @module,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int name: @module_name_type ref,
int loc: @location ref
);
@@ -864,11 +723,8 @@ next_child(
unique int child: @argument_list ref
);
#keyset[parent, parent_index]
next_def(
unique int id: @next,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -891,22 +747,16 @@ case @operator_assignment.operator of
@operator_assignment_right_type = @break | @call | @next | @return | @underscore_arg | @yield
#keyset[parent, parent_index]
operator_assignment_def(
unique int id: @operator_assignment,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int left: @underscore_lhs ref,
int operator: int ref,
int right: @operator_assignment_right_type ref,
int loc: @location ref
);
#keyset[parent, parent_index]
optional_parameter_def(
unique int id: @optional_parameter,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int name: @token_identifier ref,
int value: @underscore_arg ref,
int loc: @location ref
@@ -914,11 +764,8 @@ optional_parameter_def(
@pair_key_type = @string__ | @token_hash_key_symbol | @underscore_arg
#keyset[parent, parent_index]
pair_def(
unique int id: @pair,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int key__: @pair_key_type ref,
int value: @underscore_arg ref,
int loc: @location ref
@@ -933,21 +780,15 @@ parenthesized_statements_child(
unique int child: @parenthesized_statements_child_type ref
);
#keyset[parent, parent_index]
parenthesized_statements_def(
unique int id: @parenthesized_statements,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@pattern_child_type = @splat_argument | @underscore_arg
#keyset[parent, parent_index]
pattern_def(
unique int id: @pattern,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @pattern_child_type ref,
int loc: @location ref
);
@@ -961,11 +802,8 @@ program_child(
unique int child: @program_child_type ref
);
#keyset[parent, parent_index]
program_def(
unique int id: @program,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -985,22 +823,16 @@ case @range.operator of
;
#keyset[parent, parent_index]
range_def(
unique int id: @range,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int operator: int ref,
int loc: @location ref
);
@rational_child_type = @token_float | @token_integer
#keyset[parent, parent_index]
rational_def(
unique int id: @rational,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @rational_child_type ref,
int loc: @location ref
);
@@ -1010,11 +842,8 @@ redo_child(
unique int child: @argument_list ref
);
#keyset[parent, parent_index]
redo_def(
unique int id: @redo,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1027,11 +856,8 @@ regex_child(
unique int child: @regex_child_type ref
);
#keyset[parent, parent_index]
regex_def(
unique int id: @regex,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1050,21 +876,15 @@ rescue_variable(
unique int variable: @exception_variable ref
);
#keyset[parent, parent_index]
rescue_def(
unique int id: @rescue,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@rescue_modifier_handler_type = @break | @call | @next | @return | @underscore_arg | @yield
#keyset[parent, parent_index]
rescue_modifier_def(
unique int id: @rescue_modifier,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int body: @underscore_statement ref,
int handler: @rescue_modifier_handler_type ref,
int loc: @location ref
@@ -1075,11 +895,8 @@ rest_assignment_child(
unique int child: @underscore_lhs ref
);
#keyset[parent, parent_index]
rest_assignment_def(
unique int id: @rest_assignment,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1088,11 +905,8 @@ retry_child(
unique int child: @argument_list ref
);
#keyset[parent, parent_index]
retry_def(
unique int id: @retry,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1101,11 +915,8 @@ return_child(
unique int child: @argument_list ref
);
#keyset[parent, parent_index]
return_def(
unique int id: @return,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1118,11 +929,8 @@ right_assignment_list_child(
unique int child: @right_assignment_list_child_type ref
);
#keyset[parent, parent_index]
right_assignment_list_def(
unique int id: @right_assignment_list,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1133,20 +941,14 @@ scope_resolution_scope(
unique int scope: @underscore_primary ref
);
#keyset[parent, parent_index]
scope_resolution_def(
unique int id: @scope_resolution,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int name: @scope_resolution_name_type ref,
int loc: @location ref
);
#keyset[parent, parent_index]
setter_def(
unique int id: @setter,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int name: @token_identifier ref,
int loc: @location ref
);
@@ -1160,11 +962,8 @@ singleton_class_child(
unique int child: @singleton_class_child_type ref
);
#keyset[parent, parent_index]
singleton_class_def(
unique int id: @singleton_class,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int value: @underscore_arg ref,
int loc: @location ref
);
@@ -1185,21 +984,15 @@ singleton_method_child(
unique int child: @singleton_method_child_type ref
);
#keyset[parent, parent_index]
singleton_method_def(
unique int id: @singleton_method,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int name: @underscore_method_name ref,
int object: @singleton_method_object_type ref,
int loc: @location ref
);
#keyset[parent, parent_index]
splat_argument_def(
unique int id: @splat_argument,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @underscore_arg ref,
int loc: @location ref
);
@@ -1209,11 +1002,8 @@ splat_parameter_name(
unique int name: @token_identifier ref
);
#keyset[parent, parent_index]
splat_parameter_def(
unique int id: @splat_parameter,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1226,11 +1016,8 @@ string_child(
unique int child: @string_child_type ref
);
#keyset[parent, parent_index]
string_def(
unique int id: @string__,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1241,11 +1028,8 @@ string_array_child(
unique int child: @bare_string ref
);
#keyset[parent, parent_index]
string_array_def(
unique int id: @string_array,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1258,21 +1042,15 @@ subshell_child(
unique int child: @subshell_child_type ref
);
#keyset[parent, parent_index]
subshell_def(
unique int id: @subshell,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@superclass_child_type = @break | @call | @next | @return | @underscore_arg | @yield
#keyset[parent, parent_index]
superclass_def(
unique int id: @superclass,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @superclass_child_type ref,
int loc: @location ref
);
@@ -1284,11 +1062,8 @@ symbol_array_child(
unique int child: @bare_symbol ref
);
#keyset[parent, parent_index]
symbol_array_def(
unique int id: @symbol_array,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1301,11 +1076,8 @@ then_child(
unique int child: @then_child_type ref
);
#keyset[parent, parent_index]
then_def(
unique int id: @then,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1321,11 +1093,8 @@ case @unary.operator of
;
#keyset[parent, parent_index]
unary_def(
unique int id: @unary,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int operand: @unary_operand_type ref,
int operator: int ref,
int loc: @location ref
@@ -1338,11 +1107,8 @@ undef_child(
unique int child: @underscore_method_name ref
);
#keyset[parent, parent_index]
undef_def(
unique int id: @undef,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -1358,32 +1124,23 @@ unless_consequence(
unique int consequence: @then ref
);
#keyset[parent, parent_index]
unless_def(
unique int id: @unless,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int condition: @underscore_statement ref,
int loc: @location ref
);
@unless_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield
#keyset[parent, parent_index]
unless_modifier_def(
unique int id: @unless_modifier,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int body: @underscore_statement ref,
int condition: @unless_modifier_condition_type ref,
int loc: @location ref
);
#keyset[parent, parent_index]
until_def(
unique int id: @until,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int body: @do ref,
int condition: @underscore_statement ref,
int loc: @location ref
@@ -1391,11 +1148,8 @@ until_def(
@until_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield
#keyset[parent, parent_index]
until_modifier_def(
unique int id: @until_modifier,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int body: @underscore_statement ref,
int condition: @until_modifier_condition_type ref,
int loc: @location ref
@@ -1413,19 +1167,13 @@ when_pattern(
unique int pattern: @pattern ref
);
#keyset[parent, parent_index]
when_def(
unique int id: @when,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
#keyset[parent, parent_index]
while_def(
unique int id: @while,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int body: @do ref,
int condition: @underscore_statement ref,
int loc: @location ref
@@ -1433,11 +1181,8 @@ while_def(
@while_modifier_condition_type = @break | @call | @next | @return | @underscore_arg | @yield
#keyset[parent, parent_index]
while_modifier_def(
unique int id: @while_modifier,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int body: @underscore_statement ref,
int condition: @while_modifier_condition_type ref,
int loc: @location ref
@@ -1448,19 +1193,13 @@ yield_child(
unique int child: @argument_list ref
);
#keyset[parent, parent_index]
yield_def(
unique int id: @yield,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
#keyset[parent, parent_index]
tokeninfo(
unique int id: @token,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int kind: int ref,
int file: @file ref,
int idx: int ref,
@@ -1502,3 +1241,10 @@ case @token.kind of
@ast_node_parent = @ast_node | @file
#keyset[parent, parent_index]
ast_node_parent(
int child: @ast_node ref,
int parent: @ast_node_parent ref,
int parent_index: int ref
);

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +0,0 @@
class Superclass extends @superclass {
string toString() { result = "" }
}
class Class extends @class {
string toString() { result = "" }
}
class ClassChildType extends @class_child_type {
string toString() { result = "" }
}
// Select all non-superclass children.
// If the 0th child is a superclass, shuffle all the indexes down one. (Having
// superclass children at other indexes is allowed in the old dbscheme, but
// doesn't happen in practice, given the tree-sitter grammar).
from Class c, int oldIndex, ClassChildType child, int newIndex
where
class_child(c, oldIndex, child) and
(
if exists(Superclass sc | class_child(c, 0, sc))
then newIndex = oldIndex - 1
else newIndex = oldIndex
) and
not child instanceof Superclass
select c, newIndex, child

View File

@@ -1,12 +0,0 @@
class Superclass extends @superclass {
string toString() { result = "" }
}
class Class extends @class {
string toString() { result = "" }
}
// Select the 0th child if it's a @superclass
from Class c, Superclass sc
where class_child(c, 0, sc)
select c, sc

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +0,0 @@
description: moves class superclass nodes into their own table
compatibility: full
class_superclass.rel: run class_superclass.qlo
class_child.rel: run class_child.qlo

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +0,0 @@
class Range extends @range {
string toString() { result = "" }
}
class Child extends @underscore_arg {
string toString() { result = "" }
}
from Range range, Child begin
where range_child(range, 0, begin)
select range, begin

View File

@@ -1,17 +0,0 @@
class Range extends @range {
string toString() { result = "" }
}
class Parent extends @ast_node_parent {
string toString() { result = "" }
}
class Location extends @location {
string toString() { result = "" }
}
from Range range, Parent parent, int parentIndex, int operatorKind, Location loc
where
range_def(range, parent, parentIndex, loc) and
operatorKind = 0 // best we can do is assume it was .. and not ...
select range, parent, parentIndex, operatorKind, loc

View File

@@ -1,11 +0,0 @@
class Range extends @range {
string toString() { result = "" }
}
class Child extends @underscore_arg {
string toString() { result = "" }
}
from Range range, Child end
where range_child(range, 1, end)
select range, end

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +0,0 @@
description: split range_child table into range_begin and range_end
compatibility: partial
range_begin.rel: run range_begin.qlo
range_end.rel: run range_end.qlo
range_def.rel: run range_def.qlo
range_child.rel: delete

View File

@@ -1,13 +0,0 @@
class Stmt extends @underscore_statement {
string toString() { result = "" }
}
class Interpolation extends @interpolation {
string toString() { result = "" }
}
// The new table adds an index column, so any interpolation_child tables in the
// old dbscheme were implicitly index 0.
from Interpolation interpolation, int index, Stmt child
where interpolation_child(interpolation, child) and index = 0
select interpolation, index, child

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +0,0 @@
description: adds support for multiple statements in interpolations
compatibility: partial
interpolation_child.rel: run interpolation_child.qlo