Skip to content

Commit 4e3179f

Browse files
committed
Avoid extracting default alias for extras
Fixes tree-sitter#1834
1 parent 0113bd2 commit 4e3179f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cli/src/generate/prepare_grammar/extract_default_aliases.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ pub(super) fn extract_default_aliases(
6262
}
6363
}
6464

65+
for symbol in syntax_grammar.extra_symbols.iter() {
66+
let mut status = match symbol.kind {
67+
SymbolType::External => &mut external_status_list[symbol.index],
68+
SymbolType::NonTerminal => &mut non_terminal_status_list[symbol.index],
69+
SymbolType::Terminal => &mut terminal_status_list[symbol.index],
70+
SymbolType::End | SymbolType::EndOfNonTerminalExtra => {
71+
panic!("Unexpected end token")
72+
}
73+
};
74+
status.appears_unaliased = true;
75+
}
76+
6577
let symbols_with_statuses = (terminal_status_list
6678
.iter_mut()
6779
.enumerate()

test/fixtures/test_grammars/aliased_rules/corpus.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Method calls
77
---
88

99
(statement
10-
(star_aliased)
10+
(star)
1111
(call_expression
1212
(member_expression
1313
(variable_name)

0 commit comments

Comments
 (0)