diff options
Diffstat (limited to 'stdlib/source/lux/compiler/default/syntax.lux')
-rw-r--r-- | stdlib/source/lux/compiler/default/syntax.lux | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux index 41c11ee2d..1378e37c0 100644 --- a/stdlib/source/lux/compiler/default/syntax.lux +++ b/stdlib/source/lux/compiler/default/syntax.lux @@ -482,18 +482,18 @@ (wrap [where' [where (#.Record elems)]]))) -## The parts of an identifier are separated by a single mark. -## E.g. module.name. -## Only one such mark may be used in an identifier, since there -## can only be 2 parts to an identifier (the module [before the -## mark], and the name [after the mark]). -## There are also some extra rules regarding identifier syntax, +## The parts of an name are separated by a single mark. +## E.g. module.short. +## Only one such mark may be used in an name, since there +## can only be 2 parts to an name (the module [before the +## mark], and the short [after the mark]). +## There are also some extra rules regarding name syntax, ## encoded on the parser. -(def: identifier-separator Text ".") +(def: name-separator Text ".") -## A Lux identifier is a pair of chunks of text, where the first-part -## refers to the module that gives context to the identifier, and the -## second part corresponds to the name of the identifier itself. +## A Lux name is a pair of chunks of text, where the first-part +## refers to the module that gives context to the name, and the +## second part corresponds to the short of the name itself. ## The module part may be absent (by being the empty text ""), but the ## name part must always be present. ## The rules for which characters you may use are specified in terms @@ -502,13 +502,13 @@ ## In particular, no white-space can be used, and neither can other ## characters which are already used by Lux as delimiters for other ## Code nodes (thereby reducing ambiguity while parsing). -## Additionally, the first character in an identifier's part cannot be +## Additionally, the first character in an name's part cannot be ## a digit, to avoid confusion with regards to numbers. -(def: ident-part^ +(def: name-part^ (l.Lexer Text) (do p.Monad<Parser> [#let [digits "0123456789" - delimiters (format "()[]{}#\"" identifier-separator) + delimiters (format "()[]{}#\"" name-separator) space (format white-space new-line) head-lexer (l.none-of (format digits delimiters space)) tail-lexer (l.some (l.none-of (format delimiters space)))] @@ -516,45 +516,45 @@ tail tail-lexer] (wrap (format head tail)))) -(def: current-module-mark Text (format identifier-separator identifier-separator)) +(def: current-module-mark Text (format name-separator name-separator)) -(def: (ident^ current-module aliases) - (-> Text Aliases (l.Lexer [Ident Nat])) +(def: (name^ current-module aliases) + (-> Text Aliases (l.Lexer [Name Nat])) ($_ p.either - ## When an identifier starts with 2 marks, its module is + ## When an name starts with 2 marks, its module is ## taken to be the current-module being compiled at the moment. - ## This can be useful when mentioning identifiers and tags + ## This can be useful when mentioning names and tags ## inside quoted/templated code in macros. (do p.Monad<Parser> [_ (l.this current-module-mark) - def-name ident-part^] + def-name name-part^] (wrap [[current-module def-name] (n/+ +2 (text.size def-name))])) - ## If the identifier is prefixed by the mark, but no module + ## If the name is prefixed by the mark, but no module ## part, the module is assumed to be "lux" (otherwise known as ## the 'prelude'). ## This makes it easy to refer to definitions in that module, ## since it is the most fundamental module in the entire ## standard library. (do p.Monad<Parser> - [_ (l.this identifier-separator) - def-name ident-part^] + [_ (l.this name-separator) + def-name name-part^] (wrap [["lux" def-name] (inc (text.size def-name))])) - ## Not all identifiers must be specified with a module part. - ## If that part is not provided, the identifier will be created + ## Not all names must be specified with a module part. + ## If that part is not provided, the name will be created ## with the empty "" text as the module. - ## During program analysis, such identifiers tend to be treated + ## During program analysis, such names tend to be treated ## as if their context is the current-module, but this only - ## applies to identifiers for tags and module definitions. + ## applies to names for tags and module definitions. ## Function arguments and local-variables may not be referred-to - ## using identifiers with module parts, so being able to specify - ## identifiers with empty modules helps with those use-cases. + ## using names with module parts, so being able to specify + ## names with empty modules helps with those use-cases. (do p.Monad<Parser> - [first-part ident-part^] + [first-part name-part^] (p.either (do @ - [_ (l.this identifier-separator) - second-part ident-part^] + [_ (l.this name-separator) + second-part name-part^] (wrap [[(|> aliases (dict.get first-part) (maybe.default first-part)) second-part] ($_ n/+ @@ -568,14 +568,14 @@ (-> Text Aliases Cursor (l.Lexer [Cursor Code])) (do p.Monad<Parser> [[value length] (p.after (l.this "#") - (ident^ current-module aliases))] + (name^ current-module aliases))] (wrap [(update@ #.column (|>> ($_ n/+ +1 length)) where) [where (#.Tag value)]]))) (def: #export (symbol current-module aliases where) (-> Text Aliases Cursor (l.Lexer [Cursor Code])) (do p.Monad<Parser> - [[value length] (ident^ current-module aliases)] + [[value length] (name^ current-module aliases)] (wrap [(update@ #.column (|>> (n/+ length)) where) [where (case value (^template [<name> <value>] |