Skip to content

Commit

Permalink
First attempt at enabling syntax for generators within parens
Browse files Browse the repository at this point in the history
Conflicts:
	src/julia-parser.scm
  • Loading branch information
mbauman authored and JeffBezanson committed Jan 26, 2016
1 parent 7ab542e commit bc3894e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,7 @@
(begin (take-token s) (loop (cons nxt lst))))
((eqv? c #\;) (loop (cons nxt lst)))
((equal? c closer) (loop (cons nxt lst)))
((eq? c 'for) (take-token s) (parse-generator s t closer))
;; newline character isn't detectable here
#;((eqv? c #\newline)
(error "unexpected line break in argument list"))
Expand Down Expand Up @@ -1523,6 +1524,13 @@
`(dict_comprehension ,@(cdr c))
(error "invalid dict comprehension"))))

(define (parse-generator s first closer)
(let ((r (parse-comma-separated-iters s)))
(if (not (eqv? (require-token s) closer))
(error (string "expected " closer))
(take-token s))
`(macrocall @generator ,first ,@r)))

(define (parse-matrix s first closer gotnewline)
(define (fix head v) (cons head (reverse v)))
(define (update-outer v outer)
Expand Down

0 comments on commit bc3894e

Please sign in to comment.