Skip to content

Commit

Permalink
fix ability to use .. as an infix operator (accidentally removed in J…
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Dec 27, 2016
1 parent d8a5718 commit 73d3cc9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/ast.scm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@
(cadr (caddr e))
e))

(define (dotop? o) (and (symbol? o) (eqv? (string.char (string o) 0) #\.)))
(define (dotop? o) (and (symbol? o) (eqv? (string.char (string o) 0) #\.)
(not (eq? o '|.|))
(not (eqv? (string.char (string o) 1) #\.))))

; convert '.xx to 'xx
(define (undotop op)
Expand All @@ -207,7 +209,9 @@
(define (maybe-undotop e)
(if (symbol? e)
(let ((str (string e)))
(if (eqv? (string.char str 0) #\.)
(if (and (eqv? (string.char str 0) #\.)
(not (eq? e '|.|))
(not (eqv? (string.char str 1) #\.)))
(symbol (string.sub str 1 (length str)))
#f))
(if (pair? e)
Expand Down
3 changes: 1 addition & 2 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@
(define dot-opchar? (Set
(delete-duplicates
(map (lambda (op) (string.char (string op) 1))
(filter (lambda (op) (and (dotop? op) (not (eq? op '|.|))))
operators)))))
(cons `|..| (filter dotop? operators))))))
(define operator? (Set operators))

(define initial-reserved-words '(begin while if for try return break continue
Expand Down
3 changes: 3 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -863,3 +863,6 @@ end

@test QualifiedStringMacro.SubModule.x"" === 1
@test QualifiedStringMacro.SubModule.y`` === 2

..(x,y) = x + y
@test 3 .. 4 === 7

0 comments on commit 73d3cc9

Please sign in to comment.