Skip to content

Commit

Permalink
Allow interpolation in using and export statement. Fix #11332
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed May 22, 2015
1 parent 8d10b60 commit c7690bb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
(define syntactic-op? (Set syntactic-operators))
(define syntactic-unary-op? (Set syntactic-unary-operators))

(define (symbol-or-interpolate? ex)
(or (symbol? ex)
(and (pair? ex)
(eq? '$ (car ex)))))

(define trans-op (string->symbol ".'"))
(define ctrans-op (string->symbol "'"))
(define vararg-op (string->symbol "..."))
Expand Down Expand Up @@ -1240,8 +1245,8 @@
body))))
((export)
(let ((es (map macrocall-to-atsym
(parse-comma-separated s parse-atom))))
(if (not (every symbol? es))
(parse-comma-separated s parse-unary-prefix))))
(if (not (every symbol-or-interpolate? es))
(error "invalid \"export\" statement"))
`(export ,@es)))
((import using importall)
Expand Down Expand Up @@ -1322,17 +1327,17 @@
(begin (take-token s)
(loop (list* '|.| '|.| '|.| '|.| l) (peek-token s))))
(else
(cons (macrocall-to-atsym (parse-atom s)) l)))))
(cons (macrocall-to-atsym (parse-unary-prefix s)) l)))))

(define (parse-import s word)
(let loop ((path (parse-import-dots s)))
(if (not (symbol? (car path)))
(if (not (symbol-or-interpolate? (car path)))
(error (string "invalid \"" word "\" statement: expected identifier")))
(let ((nxt (peek-token s)))
(cond
((eq? nxt '|.|)
(take-token s)
(loop (cons (macrocall-to-atsym (parse-atom s)) path)))
(loop (cons (macrocall-to-atsym (parse-unary-prefix s)) path)))
((or (memv nxt '(#\newline #\; #\, :))
(eof-object? nxt))
`(,word ,@(reverse path)))
Expand Down

0 comments on commit c7690bb

Please sign in to comment.