Skip to content

Commit

Permalink
rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
TomSkarabis committed Jan 27, 2025
1 parent fca4043 commit 87472ca
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions src/flattening/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,24 +1112,24 @@ impl<'l, 'errs> FlatteningContext<'l, 'errs> {

fn flatten_if_statement(&mut self, cursor: &mut Cursor) {
cursor.go_down(kind!("if_statement"), |cursor| {
cursor.field(field!("if_literal"));
let is_if_literal = cursor.kind() == kw!("if");
let position_if_literal = cursor.span();
cursor.field(field!("statement_type"));
let keyword_is_if = cursor.kind() == kw!("if");
let position_statement_keyword = cursor.span();
cursor.field(field!("condition"));
let (condition, condition_is_generative) = self.flatten_expr(cursor);
match(is_if_literal, condition_is_generative){
match(keyword_is_if, condition_is_generative){
(true, false) => {
self.errors.warn(position_if_literal, "Used 'if' in a non generative context, use 'when' instead");
self.errors.warn(position_statement_keyword, "Used 'if' in a non generative context, use 'when' instead");
},
(false, true) => {
self.errors.error(position_if_literal, "Used 'when' in a generative context, use 'if' instead");
self.errors.error(position_statement_keyword, "Used 'when' in a generative context, use 'if' instead");
},
(_, _) => ()
}

let if_id = self.instructions.alloc(Instruction::IfStatement(IfStatement {
condition,
is_generative: is_if_literal,
is_generative: keyword_is_if,
then_start: FlatID::PLACEHOLDER,
then_end_else_start: FlatID::PLACEHOLDER,
else_end: FlatID::PLACEHOLDER,
Expand Down
2 changes: 1 addition & 1 deletion src/flattening/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'linker> InitializationContext<'linker> {

fn gather_ports_in_if_stmt(&mut self, cursor: &mut Cursor) {
cursor.go_down_no_check(|cursor| {
cursor.field(field!("if_literal"));
cursor.field(field!("statement_type"));
cursor.field(field!("condition"));
cursor.field(field!("then_block"));
self.gather_all_ports_in_block(cursor);
Expand Down
2 changes: 1 addition & 1 deletion tree-sitter-sus/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ module.exports = grammar({
),

if_statement: $ => seq(
field('if_literal',choice(
field('statement_type',choice(
'when',
'if'
)),
Expand Down
2 changes: 1 addition & 1 deletion tree-sitter-sus/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tree-sitter-sus/src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions tree-sitter-sus/src/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 87472ca

Please sign in to comment.