Skip to content

Commit

Permalink
throw an error for {} array / dict syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebolewski committed Oct 5, 2014
1 parent c7d0069 commit 09fa3b0
Showing 1 changed file with 3 additions and 39 deletions.
42 changes: 3 additions & 39 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@
(loop lst nxt)
(let ((params (parse-arglist s closer)))
`(vcat ,@params ,@lst ,nxt))))
((#\] #\})
((#\])
(error (string "unexpected \"" t "\"")))
(else
(error "missing separator in array expression")))))))
Expand Down Expand Up @@ -1758,45 +1758,9 @@
(else
(error "missing separator in tuple")))))))))

;; cell expression
;; TODO this awaits a decision on {} syntax in 0.4
((eqv? t #\{ )
(take-token s)
(if (eqv? (require-token s) #\})
(begin (take-token s) '(cell1d))
(let ((vex (parse-cat s #\})))
(if (null? vex)
'(cell1d)
(case (car vex)
((comprehension)
`(typed_comprehension (top Any) ,@(cdr vex)))
((dict_comprehension)
`(typed_dict_comprehension (=> (top Any) (top Any)) ,@(cdr vex)))
((dict)
`(typed_dict (=> (top Any) (top Any)) ,@(cdr vex)))
((hcat)
`(cell2d 1 ,(length (cdr vex)) ,@(cdr vex)))
(else ; (vcat ...)
(if (and (pair? (cadr vex)) (eq? (caadr vex) 'row))
(let ((nr (length (cdr vex)))
(nc (length (cdadr vex))))
;; make sure all rows are the same length
(if (not (every
(lambda (x)
(and (pair? x)
(eq? (car x) 'row)
(length= (cdr x) nc)))
(cddr vex)))
(error "inconsistent shape in cell expression"))
`(cell2d ,nr ,nc
,@(apply append
;; transpose to storage order
(apply map list
(map cdr (cdr vex))))))
(if (any (lambda (x) (and (pair? x)
(eq? (car x) 'row)))
(cddr vex))
(error "inconsistent shape in cell expression")
`(cell1d ,@(cdr vex))))))))))
(error "{} syntax for Any arrays / dicts has been removed in 0.4dev"))

;; cat expression
((eqv? t #\[ )
Expand Down

0 comments on commit 09fa3b0

Please sign in to comment.