Merge pull request #49 from github/aibaars/parent

Add parent ref and parent_index fields to all AstNodes
This commit is contained in:
Arthur Baars
2020-11-25 18:25:03 +01:00
committed by GitHub
5 changed files with 951 additions and 270 deletions

View File

@@ -188,6 +188,7 @@ impl Extractor {
path: format!("{}", path.display()),
file_label: *file_label,
token_counter: 0,
toplevel_child_counter: 0,
stack: Vec::new(),
schema: &self.schema,
};
@@ -257,14 +258,17 @@ struct Visitor<'a> {
trap_writer: TrapWriter,
/// A counter for tokens
token_counter: usize,
/// A counter for top-level child nodes
toplevel_child_counter: usize,
/// A lookup table from type name to node types
schema: &'a NodeTypeMap,
/// A stack for gathering information from hild nodes. Whenever a node is entered
/// an empty list is pushed. All children append their data (field name, label, type) to
/// the the list. When the visitor leaves a node the list containing the child data is popped
/// from the stack and matched against the dbscheme for the node. If the expectations are met
/// the corresponding row definitions are added to the trap_output.
stack: Vec<Vec<(Option<&'static str>, Label, TypeName)>>,
/// A stack for gathering information from child nodes. Whenever a node is entered
/// the parent's [Label], child counter, and an empty list is pushed. All children append their data
/// (field name, label, type) to the the list. When the visitor leaves a node the list
/// containing the child data is popped from the stack and matched against the dbscheme
/// for the node. If the expectations are met the corresponding row definitions are
/// added to the trap_output.
stack: Vec<(Label, usize, Vec<(Option<&'static str>, Label, TypeName)>)>,
}
impl Visitor<'_> {
@@ -287,7 +291,9 @@ impl Visitor<'_> {
return false;
}
self.stack.push(Vec::new());
let id = self.trap_writer.fresh_id();
self.stack.push((id, 0, Vec::new()));
return true;
}
@@ -295,11 +301,10 @@ impl Visitor<'_> {
if node.is_error() || node.is_missing() {
return;
}
let child_nodes = self.stack.pop().expect("Vistor: empty stack");
let id = self.trap_writer.fresh_id();
let (id, _, child_nodes) = self.stack.pop().expect("Vistor: empty stack");
let (start_line, start_column, end_line, end_column) = location_for(&self.source, node);
let loc = self.trap_writer.location(
self.file_label.clone(),
self.file_label,
start_line,
start_column,
end_line,
@@ -313,12 +318,24 @@ impl Visitor<'_> {
})
.unwrap();
let mut valid = true;
let (parent_id, parent_index) = match self.stack.last_mut() {
Some(p) if !node.is_extra() => {
p.1 += 1;
(p.0, p.1 - 1)
}
_ => {
self.toplevel_child_counter += 1;
(self.file_label, self.toplevel_child_counter - 1)
}
};
match &table.kind {
EntryKind::Token { kind_id, .. } => {
self.trap_writer.add_tuple(
"tokeninfo",
vec![
Arg::Label(id),
Arg::Label(parent_id),
Arg::Int(parent_index),
Arg::Int(*kind_id),
Arg::Label(self.file_label),
Arg::Int(self.token_counter),
@@ -335,6 +352,8 @@ impl Visitor<'_> {
if let Some(args) = self.complex_node(&node, fields, child_nodes, id) {
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);
@@ -354,7 +373,7 @@ impl Visitor<'_> {
// Extra nodes are independent root nodes and do not belong to the parent node
// Therefore we should not register them in the parent vector
if let Some(parent) = self.stack.last_mut() {
parent.push((
parent.2.push((
field_name,
id,
TypeName {

View File

@@ -136,7 +136,6 @@ fn convert_nodes<'a>(nodes: &'a node_types::NodeTypeMap) -> Vec<dbscheme::Entry<
})
.collect();
ast_node_members.insert("token");
for (_, node) in nodes {
match &node.kind {
node_types::EntryKind::Union { members: n_members } => {
@@ -155,14 +154,30 @@ 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,
}],
keysets: None,
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"]),
};
ast_node_members.insert(&node.dbscheme_name);
@@ -227,6 +242,11 @@ fn convert_nodes<'a>(nodes: &'a node_types::NodeTypeMap) -> Vec<dbscheme::Entry<
members: ast_node_members,
}));
// Create the ast_node_parent union.
entries.push(dbscheme::Entry::Union(dbscheme::Union {
name: "ast_node_parent",
members: ["ast_node", "file"].iter().cloned().collect(),
}));
entries
}
@@ -235,7 +255,7 @@ fn create_tokeninfo<'a>(
) -> (dbscheme::Case<'a>, dbscheme::Table<'a>) {
let table = dbscheme::Table {
name: "tokeninfo",
keysets: None,
keysets: Some(vec!["parent", "parent_index"]),
columns: vec![
dbscheme::Column {
db_type: dbscheme::DbColumnType::Int,
@@ -244,6 +264,20 @@ fn create_tokeninfo<'a>(
ql_type: ql::Type::AtType("token"),
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,
},
dbscheme::Column {
unique: false,
db_type: dbscheme::DbColumnType::Int,

View File

@@ -46,31 +46,8 @@ 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 = ql::Predicate {
name: "getParent",
overridden: false,
return_type: Some(ql::Type::Normal("AstNode")),
formal_parameters: vec![],
body: ql::Expression::Equals(
Box::new(ql::Expression::Var("result")),
Box::new(ql::Expression::Aggregate(
"unique",
vec![ql::FormalParameter {
name: "parent",
param_type: ql::Type::Normal("AstNode"),
}],
Box::new(ql::Expression::Equals(
Box::new(ql::Expression::Var("this")),
Box::new(ql::Expression::Dot(
Box::new(ql::Expression::Var("parent")),
"getAFieldOrChild",
vec![],
)),
)),
Box::new(ql::Expression::Var("parent")),
)),
),
};
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 describe_ql_class = ql::Predicate {
name: "describeQlClass",
overridden: false,
@@ -90,6 +67,7 @@ fn create_ast_node_class<'a>() -> ql::Class<'a> {
to_string,
get_location,
get_parent,
get_parent_index,
get_a_field_or_child,
describe_ql_class,
],
@@ -97,39 +75,33 @@ 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("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("tokeninfo", 1, 8),
};
let get_value = ql::Predicate {
name: "getValue",
overridden: false,
return_type: Some(ql::Type::String),
formal_parameters: vec![],
body: ql::Expression::Pred(
"tokeninfo",
vec![
ql::Expression::Var("this"),
ql::Expression::Var("_"),
ql::Expression::Var("_"),
ql::Expression::Var("_"),
ql::Expression::Var("result"),
ql::Expression::Var("_"),
],
),
body: create_get_field_expr_for_column_storage("tokeninfo", 5, 8),
};
let get_location = ql::Predicate {
name: "getLocation",
overridden: true,
return_type: Some(ql::Type::Normal("Location")),
formal_parameters: vec![],
body: ql::Expression::Pred(
"tokeninfo",
vec![
ql::Expression::Var("this"),
ql::Expression::Var("_"),
ql::Expression::Var("_"),
ql::Expression::Var("_"),
ql::Expression::Var("_"),
ql::Expression::Var("result"),
],
),
body: create_get_field_expr_for_column_storage("tokeninfo", 6, 8),
};
let to_string = ql::Predicate {
name: "toString",
@@ -149,6 +121,8 @@ 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,
@@ -262,7 +236,7 @@ fn create_get_field_expr_for_column_storage<'a>(
column_index: usize,
arity: usize,
) -> ql::Expression<'a> {
let num_underscores_before = column_index - 1;
let num_underscores_before = column_index;
let num_underscores_after = arity - 2 - num_underscores_before;
ql::Expression::Pred(
table_name,
@@ -436,10 +410,12 @@ 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 = 2 + if fields.is_empty() {
let main_table_arity = 4 + if fields.is_empty() {
1
} else {
fields
@@ -470,7 +446,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 = 1;
let mut main_table_column_index: usize = 2;
let mut get_child_exprs: Vec<ql::Expression> = Vec::new();
// Iterate through the fields, creating:
@@ -489,6 +465,30 @@ pub fn convert_nodes<'a>(nodes: &'a node_types::NodeTypeMap) -> Vec<ql::TopLevel
get_child_exprs.push(get_child_expr);
}
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(
&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(
&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,8 +58,11 @@ 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
@@ -74,8 +77,11 @@ argument_list_child(
unique int argument_list_child_type: @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
);
@@ -88,8 +94,11 @@ array_child(
unique int array_child_type: @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
);
@@ -97,8 +106,11 @@ array_def(
@assignment_right_type = @break | @call | @method_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
@@ -113,8 +125,11 @@ bare_string_child(
unique int bare_string_child_type: @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
);
@@ -127,8 +142,11 @@ bare_symbol_child(
unique int bare_symbol_child_type: @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
);
@@ -141,8 +159,11 @@ begin_child(
unique int begin_child_type: @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
);
@@ -155,8 +176,11 @@ begin_block_child(
unique int begin_block_child_type: @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
);
@@ -166,8 +190,11 @@ begin_block_def(
@binary_right_type = @break | @call | @method_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: @binary_operator_type ref,
int right: @binary_right_type ref,
@@ -183,19 +210,28 @@ block_child(
unique int block_child_type: @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
);
@@ -209,8 +245,11 @@ block_parameters_child(
unique int block_parameters_child_type: @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
);
@@ -219,8 +258,11 @@ break_child(
unique int argument_list: @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
);
@@ -228,8 +270,11 @@ break_def(
@call_receiver_type = @method_call | @underscore_primary
#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 receiver: @call_receiver_type ref,
int loc: @location ref
@@ -249,8 +294,11 @@ case_child(
unique int case_child_type: @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
);
@@ -261,8 +309,11 @@ chained_string_child(
unique int string__: @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
);
@@ -277,14 +328,20 @@ class_child(
unique int class_child_type: @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,
@@ -300,8 +357,11 @@ destructured_left_assignment_child(
unique int destructured_left_assignment_child_type: @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
);
@@ -314,8 +374,11 @@ destructured_parameter_child(
unique int destructured_parameter_child_type: @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
);
@@ -328,8 +391,11 @@ do_child(
unique int do_child_type: @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
);
@@ -342,8 +408,11 @@ do_block_child(
unique int do_block_child_type: @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
);
@@ -356,8 +425,11 @@ element_reference_child(
unique int element_reference_child_type: @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
);
@@ -371,8 +443,11 @@ else_child(
unique int else_child_type: @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
);
@@ -388,8 +463,11 @@ elsif_consequence(
unique int then: @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
);
@@ -403,8 +481,11 @@ end_block_child(
unique int end_block_child_type: @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
);
@@ -417,13 +498,19 @@ ensure_child(
unique int ensure_child_type: @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
);
@@ -437,8 +524,11 @@ exceptions_child(
unique int exceptions_child_type: @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
);
@@ -451,8 +541,11 @@ for_pattern(
unique int for_pattern_type: @for_pattern_type ref
);
#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 value: @in ref,
int loc: @location ref
@@ -467,13 +560,19 @@ hash_child(
unique int hash_child_type: @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
);
@@ -483,8 +582,11 @@ hash_splat_parameter_name(
unique int token_identifier: @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
);
@@ -497,8 +599,11 @@ heredoc_body_child(
unique int heredoc_body_child_type: @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
);
@@ -514,29 +619,41 @@ if_consequence(
unique int then: @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 | @method_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
);
#keyset[parent, parent_index]
interpolation_def(
unique int id: @interpolation,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @underscore_statement ref,
int loc: @location ref
);
@@ -546,8 +663,11 @@ keyword_parameter_value(
unique int underscore_arg: @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
);
@@ -559,8 +679,11 @@ lambda_parameters(
unique int lambda_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
);
@@ -574,8 +697,11 @@ lambda_parameters_child(
unique int lambda_parameters_child_type: @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
);
@@ -588,8 +714,11 @@ left_assignment_list_child(
unique int left_assignment_list_child_type: @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
);
@@ -607,8 +736,11 @@ method_child(
unique int method_child_type: @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
);
@@ -627,8 +759,11 @@ method_call_block(
@method_call_method_type = @call | @scope_resolution | @underscore_variable
#keyset[parent, parent_index]
method_call_def(
unique int id: @method_call,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int method: @method_call_method_type ref,
int loc: @location ref
);
@@ -642,8 +777,11 @@ method_parameters_child(
unique int method_parameters_child_type: @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
);
@@ -658,8 +796,11 @@ module_child(
unique int module_child_type: @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
);
@@ -669,22 +810,31 @@ next_child(
unique int argument_list: @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
);
@operator_assignment_right_type = @break | @call | @method_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 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
@@ -692,8 +842,11 @@ optional_parameter_def(
@pair_key_type = @string__ | @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
@@ -708,15 +861,21 @@ parenthesized_statements_child(
unique int parenthesized_statements_child_type: @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
);
@@ -730,8 +889,11 @@ program_child(
unique int program_child_type: @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
);
@@ -742,13 +904,19 @@ range_child(
unique int underscore_arg: @underscore_arg ref
);
#keyset[parent, parent_index]
range_def(
unique int id: @range,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
#keyset[parent, parent_index]
rational_def(
unique int id: @rational,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int child: @token_integer ref,
int loc: @location ref
);
@@ -758,8 +926,11 @@ redo_child(
unique int argument_list: @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
);
@@ -772,8 +943,11 @@ regex_child(
unique int regex_child_type: @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
);
@@ -792,15 +966,21 @@ rescue_variable(
unique int exception_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 | @method_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
@@ -811,8 +991,11 @@ rest_assignment_child(
unique int underscore_lhs: @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
);
@@ -821,8 +1004,11 @@ retry_child(
unique int argument_list: @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
);
@@ -831,8 +1017,11 @@ return_child(
unique int argument_list: @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
);
@@ -845,8 +1034,11 @@ right_assignment_list_child(
unique int right_assignment_list_child_type: @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
);
@@ -857,14 +1049,20 @@ scope_resolution_scope(
unique int underscore_primary: @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 child: @token_identifier ref,
int loc: @location ref
);
@@ -878,8 +1076,11 @@ singleton_class_child(
unique int singleton_class_child_type: @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
);
@@ -900,15 +1101,21 @@ singleton_method_child(
unique int singleton_method_child_type: @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
);
@@ -918,8 +1125,11 @@ splat_parameter_name(
unique int token_identifier: @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
);
@@ -932,8 +1142,11 @@ string_child(
unique int string_child_type: @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
);
@@ -944,8 +1157,11 @@ string_array_child(
unique int bare_string: @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
);
@@ -958,15 +1174,21 @@ subshell_child(
unique int subshell_child_type: @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 | @method_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
);
@@ -980,8 +1202,11 @@ symbol_child(
unique int symbol_child_type: @symbol_child_type ref
);
#keyset[parent, parent_index]
symbol_def(
unique int id: @symbol,
int parent: @ast_node_parent ref,
int parent_index: int ref,
int loc: @location ref
);
@@ -992,8 +1217,11 @@ symbol_array_child(
unique int bare_symbol: @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
);
@@ -1006,8 +1234,11 @@ then_child(
unique int then_child_type: @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
);
@@ -1015,8 +1246,11 @@ then_def(
@unary_operator_type = @reserved_word
#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: @unary_operator_type ref,
int loc: @location ref
@@ -1029,8 +1263,11 @@ undef_child(
unique int underscore_method_name: @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
);
@@ -1046,23 +1283,32 @@ unless_consequence(
unique int then: @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 | @method_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
@@ -1070,8 +1316,11 @@ until_def(
@until_modifier_condition_type = @break | @call | @method_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
@@ -1091,13 +1340,19 @@ when_pattern(
unique int when_pattern_type: @when_pattern_type 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
@@ -1105,8 +1360,11 @@ while_def(
@while_modifier_condition_type = @break | @call | @method_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
@@ -1117,13 +1375,19 @@ yield_child(
unique int argument_list: @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,
@@ -1161,3 +1425,5 @@ case @token.kind of
@ast_node = @alias | @argument_list | @array | @assignment | @bare_string | @bare_symbol | @begin | @begin_block | @binary | @block | @block_argument | @block_parameter | @block_parameters | @break | @call | @case__ | @chained_string | @class | @conditional | @destructured_left_assignment | @destructured_parameter | @do | @do_block | @element_reference | @else | @elsif | @end_block | @ensure | @exception_variable | @exceptions | @for | @hash | @hash_splat_argument | @hash_splat_parameter | @heredoc_body | @if | @if_modifier | @in | @interpolation | @keyword_parameter | @lambda | @lambda_parameters | @left_assignment_list | @method | @method_call | @method_parameters | @module | @next | @operator_assignment | @optional_parameter | @pair | @parenthesized_statements | @pattern | @program | @range | @rational | @redo | @regex | @rescue | @rescue_modifier | @rest_assignment | @retry | @return | @right_assignment_list | @scope_resolution | @setter | @singleton_class | @singleton_method | @splat_argument | @splat_parameter | @string__ | @string_array | @subshell | @superclass | @symbol | @symbol_array | @then | @token | @unary | @undef | @unless | @unless_modifier | @until | @until_modifier | @when | @while | @while_modifier | @yield
@ast_node_parent = @ast_node | @file