From 7bd9769cd8cc25539e4d31a8358c4b8a40e30559 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 19 Feb 2015 00:04:17 -0500 Subject: [PATCH] remove _mstr macros. closes #10228 --- NEWS.md | 5 +++++ base/basedocs.jl | 2 -- base/docs.jl | 22 ++++++---------------- base/exports.jl | 6 +----- base/markdown/Markdown.jl | 12 +----------- base/regex.jl | 1 - src/julia-parser.scm | 9 ++++----- src/julia-syntax.scm | 7 ++++++- 8 files changed, 23 insertions(+), 41 deletions(-) diff --git a/NEWS.md b/NEWS.md index 445e712dc9679..5502f06a23fe7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -62,6 +62,10 @@ Language changes * `round` rounds to the nearest integer using the default rounding mode, which is ties to even by default ([#8750]). + * A custom triple-quoted string like `x"""..."""` no longer invokes an `x_mstr` + macro. Instead, the string is first unindented and then `x_str` is invoked, + as if the string had been single-quoted ([#10228]). + Compiler improvements --------------------- @@ -1222,3 +1226,4 @@ Too numerous to mention. [#10075]: https://github.com/JuliaLang/julia/issues/10075 [#10117]: https://github.com/JuliaLang/julia/issues/10117 [#10180]: https://github.com/JuliaLang/julia/issues/10180 +[#10228]: https://github.com/JuliaLang/julia/issues/10228 diff --git a/base/basedocs.jl b/base/basedocs.jl index f168f3f03e11b..c7c9d81db1c3f 100644 --- a/base/basedocs.jl +++ b/base/basedocs.jl @@ -229,8 +229,6 @@ keywords[:...] = doc""" RegexMatch("angry,\nBad world") """ r"" -@doc (@doc r"") @r_mstr - @doc doc""" push!(collection, items...) → collection diff --git a/base/docs.jl b/base/docs.jl index 137c31759edcc..9a65d11971cb7 100644 --- a/base/docs.jl +++ b/base/docs.jl @@ -1,6 +1,6 @@ module Docs -import Base.Markdown: @doc_str, @doc_mstr, MD +import Base.Markdown: @doc_str, MD export doc, @doc @@ -149,9 +149,9 @@ namify(sy::Symbol) = sy function mdify(ex) if isa(ex, AbstractString) - :(@doc_str $(esc(ex))) + :(@doc_str $ex) elseif isexpr(ex, :macrocall) && namify(ex) == symbol("@mstr") - :(@doc_mstr $(esc(ex.args[2]))) + :(@doc_str $(Expr(:triple_quoted_string, ex.args[2]))) else esc(ex) end @@ -258,7 +258,7 @@ end import Base: print, writemime -export HTML, @html_str, @html_mstr +export HTML, @html_str export HTML, Text @@ -289,15 +289,10 @@ writemime(io::IO, ::MIME"text/html", h::HTML) = print(io, h.content) writemime(io::IO, ::MIME"text/html", h::HTML{Function}) = h.content(io) @doc "Create an `HTML` object from a literal string." -> -macro html_str (s) +macro html_str(s) :(HTML($s)) end -@doc (@doc html"") -> -macro html_mstr (s) - :(HTML($(Base.triplequoted(s)))) -end - function catdoc(xs::HTML...) HTML() do io for x in xs @@ -306,7 +301,7 @@ function catdoc(xs::HTML...) end end -export Text, @text_str, @text_mstr +export Text, @text_str # @doc """ # `Text(s)`: Create an object that renders `s` as plain text. @@ -332,11 +327,6 @@ macro text_str (s) :(Text($s)) end -@doc (@doc text"") -> -macro text_mstr (s) - :(Text($(Base.triplequoted(s)))) -end - function catdoc(xs::Text...) Text() do io for x in xs diff --git a/base/exports.jl b/base/exports.jl index 82705808c98ae..e10bb4459c83b 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -1383,12 +1383,9 @@ export @__FILE__, @b_str, @r_str, - @r_mstr, @v_str, @text_str, - @text_mstr, @html_str, - @html_mstr, @int128_str, @uint128_str, @bigint_str, @@ -1447,5 +1444,4 @@ export @inline, @noinline, @doc, - @doc_str, - @doc_mstr + @doc_str diff --git a/base/markdown/Markdown.jl b/base/markdown/Markdown.jl index 58bf035e839ae..831accb29d104 100644 --- a/base/markdown/Markdown.jl +++ b/base/markdown/Markdown.jl @@ -19,7 +19,7 @@ include("render/html.jl") include("render/terminal/render.jl") -export readme, license, @md_str, @md_mstr, @doc_str, @doc_mstr +export readme, license, @md_str, @doc_str parse(markdown::String; flavor = julia) = parse(IOBuffer(markdown), flavor = flavor) parse_file(file::String; flavor = julia) = parse(readall(file), flavor = flavor) @@ -49,20 +49,10 @@ macro md_str(s, t...) mdexpr(s, t...) end -macro md_mstr(s, t...) - s = Base.triplequoted(s) - mdexpr(s, t...) -end - macro doc_str(s, t...) docexpr(s, t...) end -macro doc_mstr(s, t...) - s = Base.triplequoted(s) - docexpr(s, t...) -end - function Base.display(d::Base.REPL.REPLDisplay, md::Vector{MD}) for md in md display(d, md) diff --git a/base/regex.jl b/base/regex.jl index 615364ac7128c..08ae023613664 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -53,7 +53,6 @@ function compile(regex::Regex) end macro r_str(pattern, flags...) Regex(pattern, flags...) end -macro r_mstr(pattern, flags...) Regex(pattern, flags...) end copy(r::Regex) = r diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 0d5b9d77d9dc4..ac64a29be3274 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -998,15 +998,14 @@ (let* ((str (begin (take-token s) (parse-string-literal s #t))) (nxt (peek-token s)) - (suffix (if (triplequote-string-literal? str) '_mstr '_str)) - (macname (symbol (string #\@ ex suffix))) - (macstr (cdr str))) + (macname (symbol (string #\@ ex '_str))) + (macstr (if (triplequote-string-literal? str) str (cadr str)))) (if (and (symbol? nxt) (not (operator? nxt)) (not (ts:space? s))) ;; string literal suffix, "s"x - (loop `(macrocall ,macname ,@macstr + (loop `(macrocall ,macname ,macstr ,(string (take-token s)))) - (loop `(macrocall ,macname ,@macstr)))) + (loop `(macrocall ,macname ,macstr)))) ex)) (else ex)))))) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 573f63b05e4fc..8d184badda38b 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -3303,7 +3303,12 @@ So far only the second case can actually occur. ((eq? (car e) 'macrocall) ;; expand macro (let ((form - (apply invoke-julia-macro (cadr e) (cddr e)))) + (if (and (length> e 2) (pair? (caddr e)) (eq? (caaddr e) 'triple_quoted_string)) + ;; for a custom triple-quoted string literal, first invoke mstr + ;; to handle unindenting + (invoke-julia-macro (cadr e) + (julia-expand-macros `(macrocall @mstr ,(cadr (caddr e))))) + (apply invoke-julia-macro (cadr e) (cddr e))))) (if (not form) (error (string "macro \"" (cadr e) "\" not defined"))) (if (and (pair? form) (eq? (car form) 'error))