Skip to content

Commit bb9e996

Browse files
committed
Shared: Do not emit ReservedWord class when there are no unnamed tokens
1 parent c3a9218 commit bb9e996

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

  • shared/tree-sitter-extractor/src/generator

shared/tree-sitter-extractor/src/generator/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,19 @@ pub fn generate(
115115
&node_parent_table_name,
116116
)),
117117
ql::TopLevel::Class(ql_gen::create_token_class(&token_name, &tokeninfo_name)),
118-
ql::TopLevel::Class(ql_gen::create_reserved_word_class(&reserved_word_name)),
119118
];
119+
// Only emit the ReservedWord class when there are actually unnamed token
120+
// types in the schema (i.e., @{prefix}_reserved_word exists in the dbscheme).
121+
// When converting from a YEAST YAML schema that has no unnamed tokens, this
122+
// type is absent and referencing it would cause a QL compilation error.
123+
let has_reserved_words = nodes
124+
.values()
125+
.any(|n| n.dbscheme_name == reserved_word_name);
126+
if has_reserved_words {
127+
body.push(ql::TopLevel::Class(ql_gen::create_reserved_word_class(
128+
&reserved_word_name,
129+
)));
130+
}
120131

121132
// Overlay discard predicates
122133
body.push(ql::TopLevel::Predicate(

0 commit comments

Comments
 (0)