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 {