From 4097d1edb2932b68ff9185089565908f0133c18b Mon Sep 17 00:00:00 2001 From: KtorZ Date: Mon, 4 Mar 2024 23:27:23 +0100 Subject: [PATCH] Fix negative integer literal parsing in fuzzer DSL. --- .../aiken-lang/src/parser/definition/test.rs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/aiken-lang/src/parser/definition/test.rs b/crates/aiken-lang/src/parser/definition/test.rs index 9c7f0482..627d7df2 100644 --- a/crates/aiken-lang/src/parser/definition/test.rs +++ b/crates/aiken-lang/src/parser/definition/test.rs @@ -5,7 +5,7 @@ use crate::{ annotation, chain::{call::parser as call, field_access, tuple_index::parser as tuple_index, Chain}, error::ParseError, - expr::{self, bytearray, int, list, string, tuple, var}, + expr::{self, bytearray, int as uint, list, string, tuple, var}, token::Token, }, }; @@ -88,9 +88,25 @@ pub fn fuzzer<'a>() -> impl Parser + 'a call(expression.clone()), )); + let int = || { + just(Token::Minus) + .to(ast::UnOp::Negate) + .map_with_span(|op, span| (op, span)) + .or_not() + .then(uint()) + .map(|(op, value)| match op { + None => value, + Some((op, location)) => UntypedExpr::UnOp { + op, + location, + value: Box::new(value), + }, + }) + }; + choice(( - string(), int(), + string(), bytearray(), tuple(expression.clone()), list(expression.clone()),