Changed way of String lexing
This commit is contained in:
parent
c567341775
commit
5a5403a8df
|
@ -112,7 +112,7 @@ pub enum Token {
|
||||||
|
|
||||||
// Literals
|
// Literals
|
||||||
/// String
|
/// String
|
||||||
#[regex(r"/\*([^\*]*\*+[^\*/])*([^\*]*\*+|[^\*]*\*/)", get_string)]
|
#[token("/*", get_string)]
|
||||||
String(String),
|
String(String),
|
||||||
|
|
||||||
/// Integer
|
/// Integer
|
||||||
|
@ -135,12 +135,12 @@ fn get_value<T: std::str::FromStr>(lexer: &mut Lexer<Token>) -> Option<T> {
|
||||||
lexer.slice().parse().ok()
|
lexer.slice().parse().ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_string(lexer: &mut Lexer<Token>) -> String {
|
fn get_string(lexer: &mut Lexer<Token>) -> Option<String> {
|
||||||
lexer
|
lexer.bump(lexer.remainder().find("*/")?);
|
||||||
.slice()
|
let string = lexer.slice()[2..].to_owned();
|
||||||
.trim_start_matches("/*")
|
lexer.bump(2);
|
||||||
.trim_end_matches("*/")
|
|
||||||
.to_owned()
|
Some(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_ident(lexer: &mut Lexer<Token>) -> String {
|
fn get_ident(lexer: &mut Lexer<Token>) -> String {
|
||||||
|
|
Loading…
Reference in a new issue