diff options
Diffstat (limited to 'stdlib/source/lux/compiler/default/syntax.lux')
-rw-r--r-- | stdlib/source/lux/compiler/default/syntax.lux | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux index 5f2d6d93b..322035fd8 100644 --- a/stdlib/source/lux/compiler/default/syntax.lux +++ b/stdlib/source/lux/compiler/default/syntax.lux @@ -55,20 +55,19 @@ ## It operates recursively in order to produce the longest continuous ## chunk of white-space. (def: (space^ where) - (-> Cursor (Lexer [Cursor Text])) + (-> Cursor (Lexer [Cursor Any])) (p.either (do p.Monad<Parser> - [content (l.many (l.one-of white-space))] - (wrap [(update@ #.column (n/+ (text.size content)) where) - content])) + [content (l.many! (l.one-of! white-space))] + (wrap [(update@ #.column (n/+ (get@ #l.distance content)) where) + []])) ## New-lines must be handled as a separate case to ensure line ## information is handled properly. (do p.Monad<Parser> - [content (l.many (l.one-of new-line))] + [content (l.many! (l.one-of! new-line))] (wrap [(|> where - (update@ #.line (n/+ (text.size content))) + (update@ #.line (n/+ (get@ #l.distance content))) (set@ #.column 0)) - content])) - )) + []])))) ## Single-line comments can start anywhere, but only go up to the ## next new-line. @@ -76,7 +75,7 @@ (-> Cursor (Lexer [Cursor Text])) (do p.Monad<Parser> [_ (l.this "##") - comment (l.some (l.none-of new-line)) + comment (l.slice (l.some! (l.none-of! new-line))) _ (l.this new-line)] (wrap [(|> where (update@ #.line inc) @@ -157,7 +156,7 @@ [[where comment] (comment^ where)] (left-padding^ where)) (do p.Monad<Parser> - [[where white-space] (space^ where)] + [[where _] (space^ where)] (left-padding^ where)) (:: p.Monad<Parser> wrap where))) @@ -365,7 +364,7 @@ ## the text's body's column, ## to ensure they are aligned. (do @ - [offset (l.many (l.one-of " ")) + [offset (l.slice (l.many! (l.one-of! " "))) #let [offset-size (text.size offset)]] (if (n/>= offset-column offset-size) ## Any extra offset @@ -385,7 +384,7 @@ ($_ p.either ## Normal text characters. (do @ - [normal (l.many (l.none-of "\\\"\n"))] + [normal (l.slice (l.many! (l.none-of! "\\\"\n")))] (recur (format text-read normal) (|> where (update@ #.column (n/+ (text.size normal)))) @@ -512,8 +511,8 @@ [#let [digits "0123456789" 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)))] + head-lexer (l.slice (l.none-of! (format digits delimiters space))) + tail-lexer (l.slice (l.some! (l.none-of! (format delimiters space))))] head head-lexer tail tail-lexer] (wrap (format head tail)))) |