From 0836df1c192e9586bb6b54795ebd69cbeb127715 Mon Sep 17 00:00:00 2001 From: Tab Atkins-Bittner Date: Fri, 6 Oct 2023 14:32:01 -0700 Subject: [PATCH] Restrict idents from looking like raw strings. Closes #200, closes #204, closes #241 --- CHANGELOG.md | 1 + SPEC.md | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3bc032..cd30307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Single line comments (`//`) can now be immediately followed by a newline. * All literal whitespace following a `\` in a string is now discarded. * Vertical tabs (`U+000B`) are now considered to be whitespace. +* Identifiers can't start with `r#`, so they're easy to distinguish from raw strings. (They already similarly can't start with a digit, or a sign+digit, so they're easy to distinguish from numbers.) ### KQL diff --git a/SPEC.md b/SPEC.md index 55a4d1a..cbd90c7 100644 --- a/SPEC.md +++ b/SPEC.md @@ -482,7 +482,10 @@ node-space := ws* escline ws* | ws+ node-terminator := single-line-comment | newline | ';' | eof identifier := string | bare-identifier -bare-identifier := ((identifier-char - digit - sign) identifier-char* | sign ((identifier-char - digit) identifier-char*)?) - keyword +bare-identifier := (unambiguous-ident | numberish-ident | stringish-ident) - keyword +unambiguous-ident := (identifier-char - digit - sign - "r") identifier-char* +numberish-ident := sign ((identifier-char - digit) identifier-char*)? +stringish-ident := "r" ((identifier-char - "#") identifier-char*)? identifier-char := unicode - linespace - [\/(){}<>;[]=,"] keyword := boolean | 'null' prop := identifier '=' value