Skip to content

Commit c39ccce

Browse files
Support parenthesized expressions
1 parent f1e7a31 commit c39ccce

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎native/src/parser.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,12 @@ impl Parser {
455455
self.consume(TokenKind::RBracket, "expected ']'")?;
456456
Expression::Array(elements)
457457
}
458+
TokenKind::LParen => {
459+
self.position += 1;
460+
let expression = self.expression()?;
461+
self.consume(TokenKind::RParen, "expected ')' ")?;
462+
expression
463+
}
458464
_ => return Err(self.error("expected literal")),
459465
};
460466
while self.check(TokenKind::LBracket) {

‎native/tests/cli_errors.rs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ fn less_than_runs_in_source_and_compiled_artifact() {
125125
fn unary_negation_runs_in_source_and_compiled_artifact() {
126126
let source_path = temp_path("negate_source.ax");
127127
let artifact_path = temp_path("negate_output.axm");
128-
std::fs::write(
129-
&source_path,
130-
"fn main() { let total: Int = 2 + 3; print(-total); print(-2 * 3) }",
131-
)
132-
.unwrap();
128+
std::fs::write(&source_path, "fn main() { print(-(2 + 3)); print(-2 * 3) }").unwrap();
133129

134130
let source_run = run_axiom(&["run", source_path.to_str().unwrap()]);
135131
assert!(

0 commit comments

Comments
 (0)