aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2018-08-22 17:40:33 -0400
committerEduardo Julian2018-08-22 17:40:33 -0400
commit6c896325238b63b6fc09f774968be6da0b9c89c1 (patch)
tree390b2bf37968d29a035d9ca9259ab1f65793c012 /stdlib/source
parentd4f1c93801003d68cb15e792f81784be1d488020 (diff)
No more multi-line comments.
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/compiler/default/syntax.lux63
1 files changed, 1 insertions, 62 deletions
diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux
index 6a52687ec..3b3b3e411 100644
--- a/stdlib/source/lux/compiler/default/syntax.lux
+++ b/stdlib/source/lux/compiler/default/syntax.lux
@@ -132,7 +132,7 @@
## Single-line comments can start anywhere, but only go up to the
## next new-line.
-(def: (single-line-comment^ where)
+(def: (comment^ where)
(-> Cursor (Lexer Cursor))
(do p.Monad<Parser>
[_ (l.this ..single-line-comment-marker)
@@ -142,67 +142,6 @@
(update@ #.line inc)
(set@ #.column 0)))))
-## This is just a helper parser to find text which doesn't run into
-## any special character sequences for multi-line comments.
-(def: multi-line-comment-start^ (l.this (format ..sigil open-form)))
-(def: multi-line-comment-end^ (l.this (format close-form ..sigil)))
-
-(def: multi-line-comment-bound^
- (Lexer Any)
- ($_ p.either
- ..new-line^
- ..multi-line-comment-start^
- ..multi-line-comment-end^))
-
-## Multi-line comments are bounded by #( these delimiters, #(and, they may
-## also be nested)# )#.
-## Multi-line comment syntax must be balanced.
-## That is, any nested comment must have matched delimiters.
-## Unbalanced comments ought to be rejected as invalid code.
-(def: (multi-line-comment^ where)
- (-> Cursor (Lexer Cursor))
- (do p.Monad<Parser>
- [_ ..multi-line-comment-start^]
- (loop [where (update@ #.column (n/+ 2) where)]
- ($_ p.either
- ## These are normal chunks of commented text.
- (do @
- [chunk (l.many! (l.not! multi-line-comment-bound^))]
- (recur (|> where
- (update@ #.column (n/+ (get@ #l.distance chunk))))))
- ## This is a special rule to handle new-lines within
- ## comments properly.
- (do @
- [_ ..new-line^]
- (recur (|> where
- (update@ #.line inc)
- (set@ #.column 0))))
- ## This is the rule for handling nested sub-comments.
- ## Ultimately, the whole comment is just treated as text
- ## (the comment must respect the syntax structure, but the
- ## output produced is just a block of text).
- ## That is why the sub-comment is covered in delimiters
- ## and then appended to the rest of the comment text.
- (do @
- [sub-where (multi-line-comment^ where)]
- (recur sub-where))
- ## Finally, this is the rule for closing the comment.
- (do @
- [_ ..multi-line-comment-end^]
- (wrap (update@ #.column (n/+ 2) where)))
- ))))
-
-## This is the only parser that should be used directly by other
-## parsers, since all comments must be treated as either being
-## single-line or multi-line.
-## That is, there is no syntactic rule prohibiting one type of comment
-## from being used in any situation (alternatively, forcing one type
-## of comment to be the only usable one).
-(def: (comment^ where)
- (-> Cursor (Lexer Cursor))
- (p.either (single-line-comment^ where)
- (multi-line-comment^ where)))
-
## To simplify parsing, I remove any left-padding that a Code token
## may have prior to parsing the token itself.
## Left-padding is assumed to be either white-space or a comment.