From b6b01bf6d480e42b46ff1baf2a4ed2ee94b18873 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 10 Feb 2017 20:15:25 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Disallow=20names=20that=20start?= =?UTF-8?q?=20with=20'-'=20(#154)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is done for two reasons: 1. Such names cannot be given on the command line, since clap will intercept them and wrongly interpret them as flags. 2. The name '---' can conflict with yaml document delimiters. Kind of speculative, but I was thinking that it would be nice to make sure that '---' and '...' are illegal in a justfile, so that that one can be included in a yaml document stream. Is this silly? I am really not sure. This is backwards incompatible, but I don't think anyone will notice, since names that start with '-' are likely to be rare. --- GRAMMAR.md | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GRAMMAR.md b/GRAMMAR.md index 2970d7a..9fa3bea 100644 --- a/GRAMMAR.md +++ b/GRAMMAR.md @@ -17,7 +17,7 @@ NEWLINE = \n|\r\n EQUALS = = INTERPOLATION_START = {{ INTERPOLATION_END = }} -NAME = [a-zA-Z_-][a-zA-Z0-9_-]* +NAME = [a-zA-Z_][a-zA-Z0-9_-]* PLUS = + RAW_STRING = '[^'\r\n]*' STRING = "[^"]*" # also processes \n \r \t \" \\ escapes diff --git a/src/lib.rs b/src/lib.rs index 8645d14..9dc8ca8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1530,7 +1530,7 @@ fn tokenize(text: &str) -> Result, CompileError> { 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 NAME: Regex = token(r"([a-zA-Z_][a-zA-Z0-9_-]*)" ); static ref PLUS: Regex = token(r"[+]" ); static ref STRING: Regex = token("\"" ); static ref RAW_STRING: Regex = token(r#"'[^']*'"# );