Skip to content

Commit

Permalink
Merge pull request JuliaLang#16675 from JuliaLang/jb/parserfixes
Browse files Browse the repository at this point in the history
fix some parsing issues
  • Loading branch information
JeffBezanson committed May 31, 2016
2 parents 301156b + 9970edc commit 375dead
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,10 @@
r is-float32-literal)))
(if (and (eqv? #\. (string.char s (string.dec s (length s))))
(let ((nxt (peek-char port)))
(or (identifier-start-char? nxt)
(memv nxt '(#\( #\[ #\{ #\@ #\` #\~ #\")))))
(error (string "invalid numeric constant \"" s (peek-char port) "\"")))
(and (not (eof-object? nxt))
(or (identifier-start-char? nxt)
(memv nxt '(#\( #\[ #\{ #\@ #\` #\~ #\"))))))
(error (string "numeric constant \"" s "\" cannot be implicitly multiplied because it ends with \".\"")))
;; n is #f for integers > typemax(UInt64)
(cond (is-hex-float-literal (numchk n s) (double n))
((eq? pred char-hex?) (fix-uint-neg neg (sized-uint-literal n s 4)))
Expand Down Expand Up @@ -635,7 +636,9 @@
(and (eqv? (car ops) #\,)
(eq? (peek-token s) '=)))
(loop ex #f (peek-token s))
(if add-linenums
(if (and add-linenums
(not (and (pair? (car ex))
(eq? (caar ex) 'line))))
(let ((loc (line-number-node s)))
(loop (list* (down s) loc ex) #f (peek-token s)))
(loop (cons (down s) ex) #f (peek-token s))))))))))
Expand Down
11 changes: 11 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,14 @@ add_method_to_glob_fn!()
@test (try error(); catch 0; end) === 0
@test (try error(); catch false; end) === false # false and true are Bool literals, not variables
@test (try error(); catch true; end) === true

# issue #16671
@test parse("1.") === 1.0

# issue #16672
let isline(x) = isa(x,Expr) && x.head === :line
@test count(isline, parse("begin end").args) == 1
@test count(isline, parse("begin; end").args) == 1
@test count(isline, parse("begin; x+2; end").args) == 1
@test count(isline, parse("begin; x+2; y+1; end").args) == 2
end

0 comments on commit 375dead

Please sign in to comment.