From 77c201476bf1980ccbbfa6b8ccc1c64a2990ddb2 Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 13 Mar 2022 13:18:51 +0100 Subject: [PATCH] Changed way of String lexing --- ablescript/src/lexer.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ablescript/src/lexer.rs b/ablescript/src/lexer.rs index 15522c2..6a6df61 100644 --- a/ablescript/src/lexer.rs +++ b/ablescript/src/lexer.rs @@ -112,7 +112,7 @@ pub enum Token { // Literals /// String - #[regex(r"/\*([^\*]*\*+[^\*/])*([^\*]*\*+|[^\*]*\*/)", get_string)] + #[token("/*", get_string)] String(String), /// Integer @@ -135,12 +135,12 @@ fn get_value(lexer: &mut Lexer) -> Option { lexer.slice().parse().ok() } -fn get_string(lexer: &mut Lexer) -> String { - lexer - .slice() - .trim_start_matches("/*") - .trim_end_matches("*/") - .to_owned() +fn get_string(lexer: &mut Lexer) -> Option { + lexer.bump(lexer.remainder().find("*/")?); + let string = lexer.slice()[2..].to_owned(); + lexer.bump(2); + + Some(string) } fn get_ident(lexer: &mut Lexer) -> String {