From 5cbcf47038139e82c4e0d38b8cafa32e00b2400c Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 23 Jan 2018 08:17:14 +0100 Subject: [PATCH] Allow ! in comments (#296) --- src/lexer.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lexer.rs b/src/lexer.rs index cd98163..6db8dcb 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -129,22 +129,22 @@ impl<'a> Lexer<'a> { pub fn inner(mut self) -> CompilationResult<'a, Vec>> { lazy_static! { + static ref AT: Regex = token(r"@" ); static ref BACKTICK: Regex = token(r"`[^`\n\r]*`" ); static ref COLON: Regex = token(r":" ); - static ref PAREN_L: Regex = token(r"[(]" ); - static ref PAREN_R: Regex = token(r"[)]" ); - static ref AT: Regex = token(r"@" ); static ref COMMA: Regex = token(r"," ); - static ref COMMENT: Regex = token(r"#([^!\n\r]*)?\r?$" ); + static ref COMMENT: Regex = token(r"#([^!\n\r][^\n\r]*)?\r?$" ); static ref EOF: Regex = token(r"\z" ); static ref EOL: Regex = token(r"\n|\r\n" ); static ref EQUALS: Regex = token(r"=" ); static ref INTERPOLATION_END: Regex = token(r"[}][}]" ); static ref INTERPOLATION_START_TOKEN: Regex = token(r"[{][{]" ); static ref NAME: Regex = token(r"([a-zA-Z_][a-zA-Z0-9_-]*)" ); + static ref PAREN_L: Regex = token(r"[(]" ); + static ref PAREN_R: Regex = token(r"[)]" ); static ref PLUS: Regex = token(r"[+]" ); - static ref STRING: Regex = token(r#"["]"# ); static ref RAW_STRING: Regex = token(r#"'[^']*'"# ); + static ref STRING: Regex = token(r#"["]"# ); static ref UNTERMINATED_RAW_STRING: Regex = token(r#"'[^']*"# ); static ref INTERPOLATION_START: Regex = re(r"^[{][{]" ); static ref LEADING_TEXT: Regex = re(r"^(?m)(.+?)[{][{]" ); @@ -502,6 +502,12 @@ bob: "N:=#." } + summary_test! { + tokenize_comment_with_bang, + "a:=#foo!", + "N:=#." + } + summary_test! { tokenize_order, r"