Fix parsing of single hex-digits.

This commit is contained in:
KtorZ
2024-05-30 17:19:48 +02:00
parent 5694d9f9cb
commit 649e5163fc
4 changed files with 29 additions and 1 deletions

View File

@@ -112,7 +112,7 @@ pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, Error = ParseError> {
.ignore_then(
one_of("0123456789abcdefABCDEF")
.repeated()
.at_least(2)
.at_least(1)
.collect::<String>(),
)
.validate(|value: String, span, emit| {

View File

@@ -11,6 +11,18 @@ fn format_comment_at_end_of_file() {
);
}
#[test]
fn format_single_hex_digit() {
assert_format!(
r#"
const a = 0xa
const b = 0x0f
const c = 0x0000000f
const d = 0x123
"#
);
}
#[test]
fn format_simple_module() {
assert_format!(

View File

@@ -0,0 +1,11 @@
---
source: crates/aiken-lang/src/tests/format.rs
description: "Code:\n\nconst a = 0xa\nconst b = 0x0f\nconst c = 0x0000000f\nconst d = 0x123\n"
---
const a = 0xa
const b = 0xf
const c = 0xf
const d = 0x123