Changed way of String lexing

pull/6/head
ondra05 2022-03-13 13:18:51 +01:00
parent 6ea380f3a0
commit 8b5be3d90f
1 changed files with 7 additions and 7 deletions

View File

@ -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<T: std::str::FromStr>(lexer: &mut Lexer<Token>) -> Option<T> {
lexer.slice().parse().ok()
}
fn get_string(lexer: &mut Lexer<Token>) -> String {
lexer
.slice()
.trim_start_matches("/*")
.trim_end_matches("*/")
.to_owned()
fn get_string(lexer: &mut Lexer<Token>) -> Option<String> {
lexer.bump(lexer.remainder().find("*/")?);
let string = lexer.slice()[2..].to_owned();
lexer.bump(2);
Some(string)
}
fn get_ident(lexer: &mut Lexer<Token>) -> String {