X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/7524b4b2da30055e98de7f86507bec081b419f83..e046c3f65a8f7241889fb9b6005aac21e2aad1a8:/src/lexer-proto.lisp diff --git a/src/lexer-proto.lisp b/src/lexer-proto.lisp index 8f19401..122da75 100644 --- a/src/lexer-proto.lisp +++ b/src/lexer-proto.lisp @@ -85,7 +85,8 @@ (cerror*-with-location (or location char-scanner) "Lexical error: ~ ~:[unexpected~;~ - expected ~:*~{~#[~;~A~;~A or ~A~:;~A, ~]~} ~ + expected ~:*~{~#[~;~A~;~A or ~A~:;~ + ~@{~A, ~#[~;or ~A~]~}~]~} ~ but found~] ~ ~/sod::show-char/" (mapcar (lambda (exp) @@ -149,14 +150,31 @@ The result isn't interesting." (with-parser-context (character-scanner-context :scanner char-scanner) - (parse (or (and "/*" - (and (skip-many () - (and (skip-many () (not #\*)) - (label "*/" (skip-many (:min 1) #\*))) - (not #\/)) - #\/)) - (and "//" - (skip-many () (not #\newline)) - (? #\newline)))))) + (let ((start (file-location char-scanner))) + (parse (or (and "/*" + (lisp (let ((state nil)) + (loop (cond ((scanner-at-eof-p char-scanner) + (lexer-error char-scanner + (list "*/")) + (info-with-location + start "Comment started here") + (return (values nil t t))) + ((char= (scanner-current-char + char-scanner) + #\*) + (setf state '*) + (scanner-step char-scanner)) + ((and (eq state '*) + (char= (scanner-current-char + char-scanner) + #\/)) + (scanner-step char-scanner) + (return (values nil t t))) + (t + (setf state nil) + (scanner-step char-scanner))))))) + (and "//" + (skip-many () (not #\newline)) + (? #\newline))))))) ;;;----- That's all, folks --------------------------------------------------