diff options
| author | s-ol <s+removethis@s-ol.nu> | 2021-01-02 22:32:12 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-02 14:24:49 +0000 |
| commit | 69a63e7d8e71132fbd986fd4463536de700a7f93 (patch) | |
| tree | d47b812f03537869278fe13ee1aea8ff5d6ae0e1 | |
| parent | docs/guide: fixes (diff) | |
| download | alive-69a63e7d8e71132fbd986fd4463536de700a7f93.tar.gz alive-69a63e7d8e71132fbd986fd4463536de700a7f93.zip | |
syntax: more whitelisted special chars, comment parsing
| -rw-r--r-- | alv/parsing.moon | 4 | ||||
| -rw-r--r-- | docs/guide/07_defining-symbols.md | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/alv/parsing.moon b/alv/parsing.moon index 2e01efb..78ed7d1 100644 --- a/alv/parsing.moon +++ b/alv/parsing.moon @@ -14,12 +14,12 @@ comment = P { expr: (P '(') * ((V 'expr') + (1 - P ')'))^0 * (P ')') comment: (P '#(') * ((V 'expr') + (1 - P ')'))^0 * (P ')') } -space = (wc^1 * (comment * wc^1)^0) / 1 -- required whitespace mspace = (comment + wc)^0 / 1 -- optional whitespace +space = (wc^1 * (comment^0 * wc)^0) / 1 -- required whitespace -- atoms digit = R '09' -first = (R 'az', 'AZ') + S '-_+*/.=~!?%><' +first = (R 'az', 'AZ') + S '-_+*/.,=~!?%$><' sym = first * (first + digit)^0 / Constant\parse 'sym' strd = '"' * (C ((P '\\"') + (P '\\\\') + (1 - P '"'))^0) * '"' / Constant\parse 'str', '\"' diff --git a/docs/guide/07_defining-symbols.md b/docs/guide/07_defining-symbols.md index c25d34e..488270a 100644 --- a/docs/guide/07_defining-symbols.md +++ b/docs/guide/07_defining-symbols.md @@ -19,7 +19,13 @@ symbol `result`, and then refer to it by that symbol in the [trace][] operator: (def result (+ 1 2)) (trace result) -Symbols need to start with a letter or one of the characters `-_+*/.=~!?%`. +Symbols need to start with a letter or one of the following special characters: + + - + * / + _ . , = + ! ? % $ + > < ~ + After the first character, numbers are also allowed. There are two types of symbols that are treated specially: symbols containing a slash (`math/+`), and symbols starting and ending with asterisks (`*clock*`): |
