From 485bfdd94bfaca8b74a646af38b650ae287834ac Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Mon, 2 Nov 2020 18:30:38 -0500 Subject: [PATCH 1/5] Fix string macro parsing --- src/julia-parser.scm | 2 +- test/syntax.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index febb3a269a46f..0d7ae7d8fa32f 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -1272,7 +1272,7 @@ (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)) (not (operator? nxt)) (not (ts:space? s))) ;; string literal suffix, "s"x (loop `(macrocall ,macname ,startloc ,macstr diff --git a/test/syntax.jl b/test/syntax.jl index 75c70112044fd..9c9c6f0fe6b2e 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -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 From c0e6aa2ad04724c3b7cf98a5860cacda0a3f4ce5 Mon Sep 17 00:00:00 2001 From: "Scott P. Jones" Date: Fri, 6 Nov 2020 06:39:13 -0500 Subject: [PATCH 2/5] Update src/julia-parser.scm Co-authored-by: Jeff Bezanson --- src/julia-parser.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 0d7ae7d8fa32f..ca617a2b4a485 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -1272,7 +1272,7 @@ (parse-raw-literal s t))) (nxt (peek-token s)) (macname (macroify-name ex (macsuffix t)))) - (if (and (or (symbol? nxt) (number? 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 From c8ece9f25d4999ae916ecbbb63a994ebafb78ca4 Mon Sep 17 00:00:00 2001 From: "Scott P. Jones" Date: Fri, 6 Nov 2020 15:57:19 -0500 Subject: [PATCH 3/5] Update julia-parser.scm Change to not stringify things that aren't a Symbol --- src/julia-parser.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index ca617a2b4a485..734b983661185 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -1276,7 +1276,9 @@ (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)))))) From f3637e679d81d9ac3fd5e5d1b113c35f1bd630b9 Mon Sep 17 00:00:00 2001 From: "Scott P. Jones" Date: Fri, 6 Nov 2020 15:58:38 -0500 Subject: [PATCH 4/5] Update julia-parser.scm --- src/julia-parser.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 734b983661185..770d21d893c44 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -1278,7 +1278,7 @@ (loop `(macrocall ,macname ,startloc ,macstr ,(if (symbol? nxt) (string (take-token s)) - (take-token s)))) + (take-token s)))) (loop `(macrocall ,macname ,startloc ,macstr)))) ex)) (else ex)))))) From 3aa6d7a680485f25f220552bc303de61eda86078 Mon Sep 17 00:00:00 2001 From: "Scott P. Jones" Date: Sat, 7 Nov 2020 09:21:25 -0500 Subject: [PATCH 5/5] Update test/syntax.jl Co-authored-by: Jeff Bezanson --- test/syntax.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/syntax.jl b/test/syntax.jl index 9c9c6f0fe6b2e..e20037a6859c0 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -61,7 +61,7 @@ macro test999_str(args...); args; end b""" == ("a\nb",) # make sure a trailing integer, not just a symbol, is allowed also -@test test999"foo"123 == ("foo", "123") +@test test999"foo"123 == ("foo", 123) # issue #5997 @test_throws ParseError Meta.parse(": x")