From e4bcefc40a3615e8c04aebfdcd9291d2559a0122 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Wed, 12 Mar 2014 21:11:37 -0400 Subject: [PATCH] support nested #= ... =# for #6128, as noted by @carlobaldassi --- src/julia-parser.scm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 5f96e36963aa4..a8057b068b56b 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -357,20 +357,26 @@ ; skip to end of comment, starting at #: either #... or #= .... =#. (define (skip-comment port) - (define (skip-multiline-comment port) + (define (skip-multiline-comment port count) (let ((c (read-char port))) (if (eof-object? c) (error "unterminated multi-line comment #= ... =#") (begin (if (eqv? c #\=) (let ((c (peek-char port))) (if (eqv? c #\#) - (read-char port) - (skip-multiline-comment port))) - (skip-multiline-comment port)))))) + (begin + (read-char port) + (if (> count 1) + (skip-multiline-comment port (- count 1)))) + (skip-multiline-comment port count))) + (if (eqv? c #\#) + (skip-multiline-comment port + (if (eqv? (peek-char port) #\=) (+ count 1) count)) + (skip-multiline-comment port count))))))) (read-char port) ; read # that was already peeked (if (eqv? (peek-char port) #\=) - (skip-multiline-comment port) + (skip-multiline-comment port 1) (skip-to-eol port))) (define (skip-ws-and-comments port)