Skip to content

Commit

Permalink
allow numbers as string macro suffixes (JuliaLang#38336)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Nov 16, 2020
1 parent 7d8d768 commit bcad840
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1272,11 +1272,13 @@
(parse-raw-literal s t)))
(nxt (peek-token s))
(macname (macroify-name ex (macsuffix t))))
(if (and (symbol? nxt) (not (operator? nxt))
(if (and (or (symbol? nxt) (number? nxt) (large-number? nxt)) (not (operator? nxt))
(not (ts:space? s)))
;; string literal suffix, "s"x
(loop `(macrocall ,macname ,startloc ,macstr
,(string (take-token s))))
,(if (symbol? nxt)
(string (take-token s))
(take-token s))))
(loop `(macrocall ,macname ,startloc ,macstr))))
ex))
(else ex))))))
Expand Down
3 changes: 3 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ macro test999_str(args...); args; end
a
b""" == ("a\nb",)

# make sure a trailing integer, not just a symbol, is allowed also
@test test999"foo"123 == ("foo", 123)

# issue #5997
@test_throws ParseError Meta.parse(": x")
@test_throws ParseError Meta.parse("""begin
Expand Down

0 comments on commit bcad840

Please sign in to comment.