From 0ab89cafdae2e4f2e613658dcdad04667f40c077 Mon Sep 17 00:00:00 2001 From: Aspirational Date: Tue, 30 Jun 2026 09:46:10 +0300 Subject: [PATCH] parse hyphenated quoted symbols --- src/lang/parse.c | 3 ++- test/rfl/cmp/gt.rfl | 1 - test/rfl/lang/parse_branch_cov.rfl | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lang/parse.c b/src/lang/parse.c index ef2bf24f..b59febf5 100644 --- a/src/lang/parse.c +++ b/src/lang/parse.c @@ -460,7 +460,8 @@ static ray_t* parse_symbol(ray_parser_t *p) { } /* Regular symbol */ - while (PA(*p->pos) == PA_ALPHA || PA(*p->pos) == PA_DIGIT || *p->pos == '_' || *p->pos == '.') + while (PA(*p->pos) == PA_ALPHA || PA(*p->pos) == PA_DIGIT + || *p->pos == '_' || *p->pos == '.' || *p->pos == '-') p->pos++; size_t len = (size_t)(p->pos - start); int64_t id = (len == 0) ? 0 : ray_sym_intern(start, len); /* empty symbol — sym 0 */ diff --git a/test/rfl/cmp/gt.rfl b/test/rfl/cmp/gt.rfl index 5bb1e5f7..51500e95 100644 --- a/test/rfl/cmp/gt.rfl +++ b/test/rfl/cmp/gt.rfl @@ -55,7 +55,6 @@ (> ['b 'b 'b] ['a 'b 'c]) -- [true false false] ;; mixed inline (≤ 12 bytes) and pooled (> 12 bytes) — exercises SSO. -;; Note: hyphens in symbols would be parsed as ops, so use underscore. ;; 's' > 'l' so 'short > 'longer_… (> 'short 'longer_than_twelve_bytes_symbol) -- true (> 'longer_than_twelve_bytes_symbol 'short) -- false diff --git a/test/rfl/lang/parse_branch_cov.rfl b/test/rfl/lang/parse_branch_cov.rfl index b0dc432b..3498452b 100644 --- a/test/rfl/lang/parse_branch_cov.rfl +++ b/test/rfl/lang/parse_branch_cov.rfl @@ -225,6 +225,9 @@ ;; dotted / underscored symbol chars (parse_symbol loop :456) (as 'STR 'a.b.c) -- "a.b.c" (as 'STR 'a_b) -- "a_b" +;; hyphenated quoted symbol chars match the documented symbol syntax +(as 'STR 'a-b) -- "a-b" +(== 'a-b 'a-b) -- true ;; empty symbol before a closing bracket / brace / paren ;; (parse_symbol terminator guard :408-409) (count (list ')) -- 1