Skip to content

Commit

Permalink
support nested #= ... =# for #6128, as noted by @carlobaldassi
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Mar 13, 2014
1 parent 11ad1fa commit e4bcefc
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -357,20 +357,26 @@

; skip to end of comment, starting at #: either #...<eol> 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)
Expand Down

0 comments on commit e4bcefc

Please sign in to comment.