From 4295ff3a08dae2d1a31284d752c2e955456d9a32 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 15 Apr 2017 19:41:38 -0400 Subject: - Fixed a bug with multi-line comments. --- new-luxc/source/luxc/parser.lux | 50 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'new-luxc/source') diff --git a/new-luxc/source/luxc/parser.lux b/new-luxc/source/luxc/parser.lux index 7670d72c7..25f9af46a 100644 --- a/new-luxc/source/luxc/parser.lux +++ b/new-luxc/source/luxc/parser.lux @@ -46,30 +46,32 @@ (def: (multi-line-comment^ where) (-> Cursor (Lexer [Text Cursor])) (do Monad - [_ (l;text "#(") - [comment end] (loop [comment "" - where (|> where - (update@ #;column (n.+ +2)))] - ($_ l;either - (do @ - [_ (l;one-of "\n")] - (recur (format comment "\n") - (|> where - (update@ #;line n.inc) - (set@ #;column +0)))) - (do @ - [chunk (l;some' (l;not comment-bound^))] - (recur (format comment chunk) - (|> where - (update@ #;column (n.+ (text;size chunk)))))) - (do @ - [[sub-comment sub-where] (multi-line-comment^ where)] - (wrap [(format comment "#(" sub-comment ")#") - sub-where])))) - _ (l;text ")#")] - (wrap [comment - (|> end - (update@ #;column (n.+ +2)))]))) + [_ (l;text "#(")] + (loop [comment "" + where (|> where + (update@ #;column (n.+ +2)))] + ($_ l;either + (do @ + [chunk (l;many' (l;not comment-bound^))] + (recur (format comment chunk) + (|> where + (update@ #;column (n.+ (text;size chunk)))))) + (do @ + [_ (l;one-of "\n")] + (recur (format comment "\n") + (|> where + (update@ #;line n.inc) + (set@ #;column +0)))) + (do @ + [[sub-comment sub-where] (multi-line-comment^ where)] + (recur (format comment "#(" sub-comment ")#") + sub-where)) + (do @ + [_ (l;text ")#")] + (wrap [comment + (|> where + (update@ #;column (n.+ +2)))])) + )))) (def: (comment^ where) (-> Cursor (Lexer [Text Cursor])) -- cgit v1.2.3