Skip to content

Commit

Permalink
fix #9617, 2p+1 is not a hex float literal
Browse files Browse the repository at this point in the history
also re-disable debug printing code in front end
  • Loading branch information
JeffBezanson committed Jan 6, 2015
1 parent 1af2871 commit 5f20d22
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/jlfrontend.scm
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
`(incomplete ,msg)
e))
(begin
(newline)
(display "unexpected error: ")
(prn e)
(print-stack-trace (stacktrace))
;;(newline)
;;(display "unexpected error: ")
;;(prn e)
;;(print-stack-trace (stacktrace))
'(error "malformed expression"))))
thk))

Expand Down
26 changes: 14 additions & 12 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,14 @@
(begin (write-char (read-char port) str)
(set! leadingzero #t)
(cond ((allow #\x)
(begin
(set! leadingzero #f)
(set! pred char-hex?)))
(begin (set! leadingzero #f)
(set! pred char-hex?)))
((allow #\o)
(begin
(set! leadingzero #f)
(set! pred char-oct?)))
(begin (set! leadingzero #f)
(set! pred char-oct?)))
((allow #\b)
(begin
(set! leadingzero #f)
(set! pred char-bin?)))))
(begin (set! leadingzero #f)
(set! pred char-bin?)))))
(allow #\.)))
(read-digs leadingzero)
(if (eqv? (peek-char port) #\.)
Expand All @@ -281,15 +278,20 @@
(io.ungetc port #\.)
(begin (write-char #\. str)
(read-digs #f)
(if (eq? pred char-hex?)
(set! is-hex-float-literal #t))
(disallow-dot)))))
(let ((c (peek-char port)))
(if (or (eqv? c #\e) (eqv? c #\E) (eqv? c #\f) (eqv? c #\p) (eqv? c #\P))
(let* ((c (peek-char port))
(ispP (or (eqv? c #\p) (eqv? c #\P))))
(if (or (and is-hex-float-literal (or ispP (error "hex float literal must contain \"p\" or \"P\"")))
(and (eq? pred char-hex?) ispP)
(memv c '(#\e #\E #\f)))
(begin (read-char port)
(let ((d (peek-char port)))
(if (and (not (eof-object? d))
(or (char-numeric? d) (eqv? d #\+) (eqv? d #\-)))
(begin (set! is-float32-literal (eqv? c #\f))
(set! is-hex-float-literal (or (eqv? c #\p) (eqv? c #\P)))
(set! is-hex-float-literal ispP)
(write-char c str)
(write-char (read-char port) str)
(read-digs #f)
Expand Down
6 changes: 6 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2083,3 +2083,9 @@ f9535() = (global counter9535; counter9535 += 1; counter9535)
g9535() = (f9535(),f9535())
@assert g9535() == (1,2)
@assert g9535() == (3,4)

# issue #9617
let p = 15
@test 2p+1 == 31 # not a hex float literal
end
@test_throws ParseError parse("0x0.1") # must have p or P

0 comments on commit 5f20d22

Please sign in to comment.