Skip to content

Commit

Permalink
fix clippy check
Browse files Browse the repository at this point in the history
  • Loading branch information
NTTVy03 committed Dec 30, 2024
1 parent 7753149 commit 40268bf
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crates/lsp/src/handler/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ template Y() {
let file = FileDB::create(&source, Url::from_file_path(Path::new("/tmp")).unwrap());

let syntax_node = SyntaxTreeBuilder::syntax_tree(&source);

if let Some(program_ast) = AstCircomProgram::cast(syntax_node) {
for template in program_ast.template_list() {
println!("{template:?}");
Expand Down
2 changes: 1 addition & 1 deletion crates/parser/src/grammar/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ pub(super) fn declaration(p: &mut Parser) {
ComponentKw => component_declaration(p),
_ => unreachable!(),
}
}
}
2 changes: 1 addition & 1 deletion crates/parser/src/grammar/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ fn circom_expression(p: &mut Parser) {
p.close(m, TenaryConditional);
}
}
}
}
8 changes: 4 additions & 4 deletions crates/parser/src/grammar/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(super) fn statement(p: &mut Parser) {
/*
if (expr)
<statement>
else
else
<statement>
*/
fn if_statement(p: &mut Parser) {
Expand Down Expand Up @@ -81,7 +81,7 @@ fn for_statement(p: &mut Parser) {
p.close(m, ForLoop);
}

/*
/*
while (<expression>)
<statement>
*/
Expand All @@ -93,7 +93,7 @@ fn while_statement(p: &mut Parser) {
statement(p);
}

/*
/*
assert(<expression>)
*/
fn assert_statement(p: &mut Parser) {
Expand Down Expand Up @@ -181,4 +181,4 @@ fn assignment_statement(p: &mut Parser) {
} else {
p.close(m, Error);
}
}
}
2 changes: 1 addition & 1 deletion crates/parser/src/grammar/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ pub fn template(p: &mut Parser) {
block::block(p);

p.close(m, TemplateDef);
}
}
2 changes: 1 addition & 1 deletion crates/parser/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ mod tests {
}
return r;
}"#;
test(source, "test_function");
test(source, "test_function");
}
}
12 changes: 7 additions & 5 deletions crates/parser/src/token_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub enum TokenKind {
LBracket,
#[token("]")]
RBracket,
// Punctuation
// Punctuation
#[token(";")]
Semicolon,
#[token(",")]
Expand Down Expand Up @@ -123,7 +123,7 @@ pub enum TokenKind {
ShiftR,
#[token("<<")]
ShiftL,
// Combined bitwise assignments
// Combined bitwise assignments
#[token("&=")]
BitAndAssign,
#[token("|=")]
Expand Down Expand Up @@ -276,9 +276,11 @@ impl TokenKind {
Self::Mul | Self::Div | Self::IntDiv | Self::Mod => Some((94, 95)),
Self::Power => Some((96, 97)),
// TODO: review
Self::AddAssign | Self::SubAssign => Some((98,99)),
Self::MulAssign | Self::DivAssign | Self::IntDivAssign | Self::ModAssign => Some((100,101)),
Self::PowerAssign => Some((102,103)),
Self::AddAssign | Self::SubAssign => Some((98, 99)),
Self::MulAssign | Self::DivAssign | Self::IntDivAssign | Self::ModAssign => {
Some((100, 101))
}
Self::PowerAssign => Some((102, 103)),
_ => None,
}
}
Expand Down
23 changes: 19 additions & 4 deletions crates/syntax/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ mod grammar_tests {
}"#;

let syntax = syntax_node_from_source(&SOURCE, Scope::Template);

// cast syntax node into ast node to retrieve more information
let template =
AstTemplateDef::cast(syntax).expect("Can not cast syntax node into ast template");
Expand Down Expand Up @@ -349,19 +349,34 @@ mod grammar_tests {
insta::assert_yaml_snapshot!("template_happy_test_statements", statements);

// input signal
let input_signal = template.find_input_signal("in").unwrap().syntax().text().to_string();
let input_signal = template
.find_input_signal("in")
.unwrap()
.syntax()
.text()
.to_string();
insta::assert_yaml_snapshot!(input_signal, @"signal input in[N];");

// output signal
let output_signal = template.find_output_signal("out").unwrap().syntax().text().to_string();
let output_signal = template
.find_output_signal("out")
.unwrap()
.syntax()
.text()
.to_string();
insta::assert_yaml_snapshot!(output_signal, @"signal output out;");

// internal signal
let internal_signal = template.find_internal_signal("in").is_none();
insta::assert_yaml_snapshot!(internal_signal, @"true");

// component
let component = template.find_component("comp").unwrap().syntax().text().to_string();
let component = template
.find_component("comp")
.unwrap()
.syntax()
.text()
.to_string();
insta::assert_yaml_snapshot!(component, @"component comp[N-1];");
}

Expand Down

0 comments on commit 40268bf

Please sign in to comment.