Merge pull request #71 from github/tausbn/more-yaml-hacking

"Parse" YAML without errors
This commit is contained in:
Taus
2021-10-13 13:51:20 +02:00
committed by GitHub
5 changed files with 103 additions and 9 deletions

2
Cargo.lock generated
View File

@@ -589,7 +589,7 @@ dependencies = [
[[package]]
name = "tree-sitter-ql"
version = "0.19.0"
source = "git+https://github.com/tausbn/tree-sitter-ql.git?rev=a9348d405de3b2dde0e6d7e59d476ae91516b7af#a9348d405de3b2dde0e6d7e59d476ae91516b7af"
source = "git+https://github.com/tausbn/tree-sitter-ql.git?rev=577c43d96c93915bd7ae9c2765d11be8db102952#577c43d96c93915bd7ae9c2765d11be8db102952"
dependencies = [
"cc",
"tree-sitter",

View File

@@ -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 = "a9348d405de3b2dde0e6d7e59d476ae91516b7af" }
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "577c43d96c93915bd7ae9c2765d11be8db102952" }
clap = "2.33"
tracing = "0.1"
tracing-subscriber = { version = "0.2", features = ["env-filter"] }

View File

@@ -10,4 +10,4 @@ edition = "2018"
node-types = { path = "../node-types" }
tracing = "0.1"
tracing-subscriber = { version = "0.2", features = ["env-filter"] }
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "a9348d405de3b2dde0e6d7e59d476ae91516b7af" }
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "577c43d96c93915bd7ae9c2765d11be8db102952" }

View File

@@ -1687,26 +1687,86 @@ module Generated {
override AstNode getAFieldOrChild() { variable_def(this, result, _) }
}
/** A class representing `yaml_comment` nodes. */
class YamlComment extends @yaml_comment, AstNode {
/** Gets the name of the primary QL class for this element. */
override string getAPrimaryQlClass() { result = "YamlComment" }
/** Gets the location of this element. */
override Location getLocation() { yaml_comment_def(this, _, result) }
/** Gets the child of this node. */
YamlValue getChild() { yaml_comment_def(this, result, _) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() { yaml_comment_def(this, result, _) }
}
/** A class representing `yaml_entry` nodes. */
class YamlEntry extends @yaml_entry, AstNode {
/** Gets the name of the primary QL class for this element. */
override string getAPrimaryQlClass() { result = "YamlEntry" }
/** Gets the location of this element. */
override Location getLocation() { yaml_entry_def(this, _, _, result) }
override Location getLocation() { yaml_entry_def(this, _, result) }
/** Gets the child of this node. */
AstNode getChild() { yaml_entry_def(this, result, _) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() { yaml_entry_def(this, result, _) }
}
/** A class representing `yaml_key` nodes. */
class YamlKey extends @yaml_key, AstNode {
/** Gets the name of the primary QL class for this element. */
override string getAPrimaryQlClass() { result = "YamlKey" }
/** Gets the location of this element. */
override Location getLocation() { yaml_key_def(this, result) }
/** Gets the `i`th child of this node. */
AstNode getChild(int i) { yaml_key_child(this, i, result) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() { yaml_key_child(this, _, result) }
}
/** A class representing `yaml_keyvaluepair` nodes. */
class YamlKeyvaluepair extends @yaml_keyvaluepair, AstNode {
/** Gets the name of the primary QL class for this element. */
override string getAPrimaryQlClass() { result = "YamlKeyvaluepair" }
/** Gets the location of this element. */
override Location getLocation() { yaml_keyvaluepair_def(this, _, _, result) }
/** Gets the node corresponding to the field `key`. */
SimpleId getKey() { yaml_entry_def(this, result, _, _) }
YamlKey getKey() { yaml_keyvaluepair_def(this, result, _, _) }
/** Gets the node corresponding to the field `value`. */
YamlValue getValue() { yaml_entry_def(this, _, result, _) }
YamlValue getValue() { yaml_keyvaluepair_def(this, _, result, _) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() {
yaml_entry_def(this, result, _, _) or yaml_entry_def(this, _, result, _)
yaml_keyvaluepair_def(this, result, _, _) or yaml_keyvaluepair_def(this, _, result, _)
}
}
/** A class representing `yaml_listitem` nodes. */
class YamlListitem extends @yaml_listitem, AstNode {
/** Gets the name of the primary QL class for this element. */
override string getAPrimaryQlClass() { result = "YamlListitem" }
/** Gets the location of this element. */
override Location getLocation() { yaml_listitem_def(this, _, result) }
/** Gets the child of this node. */
YamlValue getChild() { yaml_listitem_def(this, result, _) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() { yaml_listitem_def(this, result, _) }
}
/** A class representing `yaml_value` tokens. */
class YamlValue extends @token_yaml_value, Token {
/** Gets the name of the primary QL class for this element. */

View File

@@ -1042,13 +1042,47 @@ variable_def(
int loc: @location ref
);
yaml_comment_def(
unique int id: @yaml_comment,
int child: @token_yaml_value ref,
int loc: @location ref
);
@yaml_entry_child_type = @yaml_comment | @yaml_keyvaluepair | @yaml_listitem
yaml_entry_def(
unique int id: @yaml_entry,
int key__: @token_simple_id ref,
int child: @yaml_entry_child_type ref,
int loc: @location ref
);
@yaml_key_child_type = @token_simple_id | @yaml_key
#keyset[yaml_key, index]
yaml_key_child(
int yaml_key: @yaml_key ref,
int index: int ref,
unique int child: @yaml_key_child_type ref
);
yaml_key_def(
unique int id: @yaml_key,
int loc: @location ref
);
yaml_keyvaluepair_def(
unique int id: @yaml_keyvaluepair,
int key__: @yaml_key ref,
int value: @token_yaml_value ref,
int loc: @location ref
);
yaml_listitem_def(
unique int id: @yaml_listitem,
int child: @token_yaml_value ref,
int loc: @location ref
);
tokeninfo(
unique int id: @token,
int kind: int ref,
@@ -1120,7 +1154,7 @@ case @diagnostic.severity of
;
@ast_node = @add_expr | @aggregate | @annot_arg | @annotation | @arityless_predicate_expr | @as_expr | @as_exprs | @body | @bool | @call_body | @call_or_unqual_agg_expr | @charpred | @class_member | @classless_predicate | @comp_term | @conjunction | @dataclass | @datatype | @datatype_branch | @datatype_branches | @db_annotation | @db_args_annotation | @db_branch | @db_case_decl | @db_col_type | @db_column | @db_entry | @db_repr_type | @db_table | @db_table_name | @db_union_decl | @disjunction | @expr_aggregate_body | @expr_annotation | @field | @full_aggregate_body | @higher_order_term | @if_term | @implication | @import_directive | @import_module_expr | @in_expr | @instance_of | @literal | @member_predicate | @module | @module_alias_body | @module_expr | @module_member | @module_name | @mul_expr | @negation | @order_by | @order_bys | @par_expr | @predicate_alias_body | @predicate_expr | @prefix_cast | @ql | @qual_module_expr | @qualified_expr | @qualified_rhs | @quantified | @range | @select | @set_literal | @special_call | @super_ref | @token | @type_alias_body | @type_expr | @type_union_body | @unary_expr | @unqual_agg_body | @var_decl | @var_name | @variable | @yaml_entry
@ast_node = @add_expr | @aggregate | @annot_arg | @annotation | @arityless_predicate_expr | @as_expr | @as_exprs | @body | @bool | @call_body | @call_or_unqual_agg_expr | @charpred | @class_member | @classless_predicate | @comp_term | @conjunction | @dataclass | @datatype | @datatype_branch | @datatype_branches | @db_annotation | @db_args_annotation | @db_branch | @db_case_decl | @db_col_type | @db_column | @db_entry | @db_repr_type | @db_table | @db_table_name | @db_union_decl | @disjunction | @expr_aggregate_body | @expr_annotation | @field | @full_aggregate_body | @higher_order_term | @if_term | @implication | @import_directive | @import_module_expr | @in_expr | @instance_of | @literal | @member_predicate | @module | @module_alias_body | @module_expr | @module_member | @module_name | @mul_expr | @negation | @order_by | @order_bys | @par_expr | @predicate_alias_body | @predicate_expr | @prefix_cast | @ql | @qual_module_expr | @qualified_expr | @qualified_rhs | @quantified | @range | @select | @set_literal | @special_call | @super_ref | @token | @type_alias_body | @type_expr | @type_union_body | @unary_expr | @unqual_agg_body | @var_decl | @var_name | @variable | @yaml_comment | @yaml_entry | @yaml_key | @yaml_keyvaluepair | @yaml_listitem
@ast_node_parent = @ast_node | @file