forked from AbleScript/ablescript
Changed way of String lexing
This commit is contained in:
parent
c567341775
commit
5a5403a8df
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue