1- __precompile__ (true )
21""" "
32Add C, Python and type-based formatting to Str string literals
43
5- Copyright 2016-2018 Gandalf Software, Inc., Scott P. Jones
4+ Copyright 2016-2020 Gandalf Software, Inc., Scott P. Jones
65Licensed under MIT License, see LICENSE.md
76"""
87module StrFormat
@@ -11,6 +10,9 @@ using ModuleInterfaceTools
1110
1211@api extend! Format, StrLiterals
1312
13+ # Export from here as well so that people can do just `using StrFormat`
14+ export @f_str , @pr_str , @F_str , @PR_str , @sym_str
15+
1416function _parse_format (str, pos, fun)
1517 ex, j = parse (Expr, str, pos; greedy= false )
1618 check_expr (ex)
2426function _parse_fmt (sx:: Vector{Any} , s:: AbstractString , unescape:: Function ,
2527 i:: Integer , j:: Integer , k:: Integer )
2628 # Move past \\, k should point to '%'
27- c, k = str_next (s, k)
29+ c, k = iterate (s, k)
2830 check_done (s, k, " Incomplete % expression" )
2931 # Handle interpolation
3032 isempty (s[i: j- 1 ]) || push! (sx, unescape (s[i: j- 1 ]))
@@ -35,7 +37,7 @@ function _parse_fmt(sx::Vector{Any}, s::AbstractString, unescape::Function,
3537 # Move past %, c should point to letter
3638 beg = k
3739 while true
38- c, k = str_next (s, k)
40+ c, k = iterate (s, k)
3941 check_done (s, k, " Incomplete % expression" )
4042 s[k] == ' (' && break
4143 end
4951function _parse_pyfmt (sx:: Vector{Any} , s:: AbstractString , unescape:: Function ,
5052 i:: Integer , j:: Integer , k:: Integer )
5153 # Move past \\, k should point to '{'
52- c, k = str_next (s, k)
54+ c, k = iterate (s, k)
5355 check_done (s, k, " Incomplete {...} Python format expression" )
5456 # Handle interpolation
5557 isempty (s[i: j- 1 ]) || push! (sx, unescape (s[i: j- 1 ]))
5658 beg = k # start location
57- c, k = str_next (s, k)
59+ c, k = iterate (s, k)
5860 while c != ' }'
5961 check_done (s, k, string (" \\ { missing closing } in " , c))
60- c, k = str_next (s, k)
62+ c, k = iterate (s, k)
6163 end
6264 check_done (s, k, " Missing (expr) in Python format expression" )
63- c, k = str_next (s, k)
65+ c, k = iterate (s, k)
6466 c == ' (' || parse_error (string (" Missing (expr) in Python format expression: " , c))
6567 # Need to find end to parse to
6668 ex, j = _parse_format (s, k- 1 , Format. pyfmt)
0 commit comments