From 10d62eb1f712bfac5b4214a8520d4e76d18d12b3 Mon Sep 17 00:00:00 2001 From: sofia Date: Mon, 21 Jul 2025 19:36:44 +0300 Subject: [PATCH] Allow_identifiers_to_have_underscores --- reid/lib/std.reid | 6 +++--- reid/src/lexer.rs | 2 +- reid_src/std_test.reid | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reid/lib/std.reid b/reid/lib/std.reid index 4cf7f15..f55b9f9 100644 --- a/reid/lib/std.reid +++ b/reid/lib/std.reid @@ -1,18 +1,18 @@ extern fn puts(message: *str) -> i32; -struct DivT { +struct div_t { quotient: i32, remainder: i32, } -extern fn div(numerator: i32, denominator: i32) -> DivT; +extern fn div(numerator: i32, denominator: i32) -> div_t; pub fn print(message: *str) { puts(message); } -pub fn intdiv(numerator: i32, denominator: i32) -> DivT { +pub fn int_div(numerator: i32, denominator: i32) -> div_t { return div(numerator, denominator); } diff --git a/reid/src/lexer.rs b/reid/src/lexer.rs index 5eaec8f..919f27e 100644 --- a/reid/src/lexer.rs +++ b/reid/src/lexer.rs @@ -265,7 +265,7 @@ pub fn tokenize>(to_tokenize: T) -> Result, Error c if c.is_alphabetic() => { let mut value = character.to_string(); while let Some(c) = cursor.first() { - if !c.is_ascii_alphanumeric() { + if !(c.is_ascii_alphanumeric() || c == '_') { break; } value += &c.to_string(); diff --git a/reid_src/std_test.reid b/reid_src/std_test.reid index 334ac09..6bfbe66 100644 --- a/reid_src/std_test.reid +++ b/reid_src/std_test.reid @@ -1,11 +1,11 @@ import std::print; -import std::intdiv; +import std::int_div; fn main() -> i32 { let hello = "hello world"; print(hello); - return intdiv(15, 5).quotient; + return int_div(15, 5).quotient; }