From 0eb81bf43a4c06948913b24825ca6b8f808cba3f Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 13 Nov 2023 09:31:31 +0800 Subject: [PATCH] refactor: optimize parser --- src/parser.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index a16b7951..10e554bf 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -674,14 +674,32 @@ fn create_err(input: &str, kind: ErrorKind) -> nom::Err> } fn is_name_char(c: char) -> bool { - c.is_ascii_alphanumeric() || matches!(c, '_' | '-' | '.' | ':') + c.is_ascii_alphanumeric() || matches!(c, '_' | '-' | '.' | ':' | '@') } fn is_short_char(c: char) -> bool { - c.is_ascii_graphic() - || !matches!( + c.is_ascii_alphanumeric() + || matches!( c, - '"' | '&' | '\'' | '(' | ')' | '-' | ';' | '<' | '>' | '\\' | '`' | '|' + '!' | '#' + | '$' + | '%' + | '*' + | '+' + | ',' + | '.' + | '/' + | ':' + | '=' + | '?' + | '@' + | '[' + | ']' + | '^' + | '_' + | '{' + | '}' + | '~' ) }