Permalink
Browse files

make $ fully ungreedy and fix syntax of all uses in base

  • Loading branch information...
JeffBezanson committed Sep 14, 2012
1 parent 357ea1f commit fd6b6fc92ede46b00fd14a15d60990f3168ecad4
Showing with 108 additions and 113 deletions.
  1. +2 −2 base/abstractarray.jl
  2. +12 −12 base/array.jl
  3. +1 −1 base/base.jl
  4. +1 −1 base/char.jl
  5. +3 −3 base/dict.jl
  6. +1 −1 base/error.jl
  7. +2 −2 base/expr.jl
  8. +8 −8 base/float.jl
  9. +1 −1 base/grisu.jl
  10. +10 −10 base/linalg_blas.jl
  11. +22 −22 base/linalg_lapack.jl
  12. +10 −10 base/math_libm.jl
  13. +14 −14 base/multi.jl
  14. +1 −1 base/pointer.jl
  15. +4 −4 base/printf.jl
  16. +1 −1 base/process.jl
  17. +9 −9 base/sort.jl
  18. +1 −1 base/task.jl
  19. +2 −2 base/util.jl
  20. +3 −8 src/julia-parser.scm
View
@@ -235,7 +235,7 @@ function gen_cartesian_map(cache, genbodies, ranges, exargnames, exargs...)
quote
local _F_
function _F_($(dimargnames...), $(exargnames...))
- $make_loop_nest(ivars, dimargnames, body, bodies)
+ $(make_loop_nest(ivars, dimargnames, body, bodies))
end
_F_
end
@@ -333,7 +333,7 @@ function gen_array_index_map(cache, genbody, ranges, exargnames, exargs...)
fexpr = quote
local _F_
function _F_($(dimargnames...), $(exargnames...))
- $make_arrayind_loop_nest(loopvars, offsetvars, stridevars, linearind, dimargnames, body, exargnames[1])
+ $(make_arrayind_loop_nest(loopvars, offsetvars, stridevars, linearind, dimargnames, body, exargnames[1]))
end
return _F_
end
View
@@ -1269,7 +1269,7 @@ end
let findn_cache = nothing
function findn_one(ivars)
- s = { quote I[$i][count] = $ivars[i] end for i = 1:length(ivars)}
+ s = { quote I[$i][count] = $(ivars[i]) end for i = 1:length(ivars)}
quote
Aind = A[$(ivars...)]
if Aind != z
@@ -1353,27 +1353,27 @@ function gen_areduce_func(n, f)
setlims = { quote
# each dim of reduction is either 1:sizeA or ivar:ivar
if contains(region,$i)
- $lo[i] = 1
- $hi[i] = size(A,$i)
+ $(lo[i]) = 1
+ $(hi[i]) = size(A,$i)
else
- $lo[i] = $hi[i] = $ivars[i]
+ $(lo[i]) = $(hi[i]) = $(ivars[i])
end
end for i=1:n }
- rranges = { :( ($lo[i]):($hi[i]) ) for i=1:n } # lo:hi for all dims
+ rranges = { :( $(lo[i]):$(hi[i]) ) for i=1:n } # lo:hi for all dims
body =
quote
_tot = v0
$(setlims...)
- $make_loop_nest(rvars, rranges,
- :(_tot = ($f)(_tot, A[$(rvars...)])))
+ $(make_loop_nest(rvars, rranges,
+ :(_tot = ($f)(_tot, A[$(rvars...)]))))
R[_ind] = _tot
_ind += 1
end
quote
local _F_
function _F_(f, A, region, R, v0)
_ind = 1
- $make_loop_nest(ivars, { :(1:size(R,$i)) for i=1:n }, body)
+ $(make_loop_nest(ivars, { :(1:size(R,$i)) for i=1:n }, body))
end
_F_
end
@@ -1768,25 +1768,25 @@ function permute(A::StridedArray, perm)
tmp = counts[end]
toReturn[len+1] = quote
ind = 1
- $tmp = $stridenames[len]
+ $tmp = $(stridenames[len])
end
#inner most loop
toReturn[1] = quote
P[ind] = A[+($(counts...))+offset]
ind+=1
- $counts[1]+= $stridenames[1]
+ $(counts[1]) += $(stridenames[1])
end
for i = 1:len-1
tmp = counts[i]
val = i
toReturn[(i+1)] = quote
- $tmp = $stridenames[val]
+ $tmp = $(stridenames[val])
end
tmp2 = counts[i+1]
val = i+1
toReturn[(i+1)+(len+1)] = quote
- $tmp2 += $stridenames[val]
+ $tmp2 += $(stridenames[val])
end
end
toReturn
View
@@ -134,7 +134,7 @@ function append_any(xs...)
out
end
-macro thunk(ex); :(()->$esc(ex)); end
+macro thunk(ex); :(()->$(esc(ex))); end
macro L_str(s); s; end
function compile_hint(f, args::Tuple)
View
@@ -84,5 +84,5 @@ for f = (:iswalnum, :iswalpha, :iswblank, :iswcntrl, :iswdigit,
# these are BSD-only
#:iswhexnumber, :iswideogram, :iswnumber, :iswphonogram, :iswrune, :iswspecial,
)
- @eval ($f)(c::Char) = bool(ccall($expr(:quote,f), Int32, (Char,), c))
+ @eval ($f)(c::Char) = bool(ccall($(expr(:quote,f)), Int32, (Char,), c))
end
View
@@ -167,17 +167,17 @@ hash(x::Integer) = _jl_hash64(uint64(x))
# hash as integer if equal to some integer. note the result of
# float to int conversion is only defined for in-range values.
if x < 0
- if $float64(typemin(Int64)) <= x
+ if $(float64(typemin(Int64))) <= x
return hash(int64(x))
end
else
# note: float64(typemax(Uint64)) == 2^64
- if x < $float64(typemax(Uint64))
+ if x < $(float64(typemax(Uint64)))
return hash(uint64(x))
end
end
end
- isnan(x) ? $_jl_hash64(NaN) : _jl_hash64(float64(x))
+ isnan(x) ? $(_jl_hash64(NaN)) : _jl_hash64(float64(x))
end
function hash(t::Tuple)
View
@@ -21,5 +21,5 @@ assert(x) = assert(x,'?')
assert(x,labl) = x ? nothing : error("assertion failed: ", labl)
macro assert(ex)
- :($esc(ex) ? nothing : error("assertion failed: ", $string(ex)))
+ :($(esc(ex)) ? nothing : error("assertion failed: ", $(string(ex))))
end
View
@@ -16,7 +16,7 @@ gensym(ss::Union(ASCIIString, UTF8String)...) = map(gensym, ss)
macro gensym(names...)
blk = expr(:block)
for name in names
- push(blk.args, :($esc(name) = gensym($(string(name)))))
+ push(blk.args, :($(esc(name)) = gensym($(string(name)))))
end
push(blk.args, :nothing)
return blk
@@ -60,5 +60,5 @@ macroexpand(x) = ccall(:jl_macroexpand, Any, (Any,), x)
## misc syntax ##
macro eval(x)
- :(eval($expr(:quote,x)))
+ :(eval($(expr(:quote,x))))
end
View
@@ -190,8 +190,8 @@ const NaN = box(Float64,unbox(Uint64,0x7ff8000000000000))
inf{T<:FloatingPoint}(x::T) = inf(T)
nan{T<:FloatingPoint}(x::T) = nan(T)
- isdenormal(x::Float32) = (abs(x) < $box(Float32,unbox(Uint32,0x00800000)))
- isdenormal(x::Float64) = (abs(x) < $box(Float64,unbox(Uint64,0x0010000000000000)))
+ isdenormal(x::Float32) = (abs(x) < $(box(Float32,unbox(Uint32,0x00800000))))
+ isdenormal(x::Float64) = (abs(x) < $(box(Float64,unbox(Uint64,0x0010000000000000))))
typemin(::Type{Float32}) = $(-Inf32)
typemax(::Type{Float32}) = $(Inf32)
@@ -200,10 +200,10 @@ const NaN = box(Float64,unbox(Uint64,0x7ff8000000000000))
typemin{T<:Real}(x::T) = typemin(T)
typemax{T<:Real}(x::T) = typemax(T)
- realmin(::Type{Float32}) = $box(Float32,unbox(Uint32,0x00800000))
- realmin(::Type{Float64}) = $box(Float64,unbox(Uint64,0x0010000000000000))
- realmax(::Type{Float32}) = $box(Float32,unbox(Uint32,0x7f7fffff))
- realmax(::Type{Float64}) = $box(Float64,unbox(Uint64,0x7fefffffffffffff))
+ realmin(::Type{Float32}) = $(box(Float32,unbox(Uint32,0x00800000)))
+ realmin(::Type{Float64}) = $(box(Float64,unbox(Uint64,0x0010000000000000)))
+ realmax(::Type{Float32}) = $(box(Float32,unbox(Uint32,0x7f7fffff)))
+ realmax(::Type{Float64}) = $(box(Float64,unbox(Uint64,0x7fefffffffffffff)))
realmin{T<:FloatingPoint}(x::T) = realmin(T)
realmax{T<:FloatingPoint}(x::T) = realmax(T)
realmin() = realmin(Float64)
@@ -215,8 +215,8 @@ const NaN = box(Float64,unbox(Uint64,0x7ff8000000000000))
prevfloat(x::FloatingPoint) = nextfloat(x,-1)
eps(x::FloatingPoint) = isfinite(x) ? abs(nextfloat(x)-x) : nan(x)
- eps(::Type{Float32}) = $box(Float32,unbox(Uint32,0x34000000))
- eps(::Type{Float64}) = $box(Float64,unbox(Uint64,0x3cb0000000000000))
+ eps(::Type{Float32}) = $(box(Float32,unbox(Uint32,0x34000000)))
+ eps(::Type{Float64}) = $(box(Float64,unbox(Uint64,0x3cb0000000000000)))
eps() = eps(Float64)
end
View
@@ -16,7 +16,7 @@ macro grisu_ccall(value, mode, ndigits)
ccall(dlsym(Base.libgrisu, :grisu), Void,
(Float64, Int32, Int32, Ptr{Uint8}, Int32,
Ptr{Bool}, Ptr{Int32}, Ptr{Int32}),
- $esc(value), $esc(mode), $esc(ndigits),
+ $(esc(value)), $(esc(mode)), $(esc(ndigits)),
DIGITS, BUFLEN, NEG, LEN, POINT)
end
end
View
@@ -5,7 +5,7 @@ for (fname, elty) in ((:dcopy_,:Float64), (:scopy_,:Float32),
(:zcopy_,:Complex128), (:ccopy_,:Complex64))
@eval begin
function _jl_blas_copy(n::Integer, DX::Union(Ptr{$elty},Array{$elty}), incx::Integer, DY::Union(Ptr{$elty},Array{$elty}), incy::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
Void,
(Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}),
&n, DX, &incx, DY, &incy)
@@ -51,7 +51,7 @@ end
for (fname, elty) in ((:ddot_,:Float64), (:sdot_,:Float32))
@eval begin
function _jl_blas_dot(n::Integer, DX::Union(Ptr{$elty},Array{$elty}), incx::Integer, DY::Union(Ptr{$elty},Array{$elty}), incy::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
$elty,
(Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}),
&n, DX, &incx, DY, &incy)
@@ -82,7 +82,7 @@ for (fname, elty, ret_type) in ((:dnrm2_,:Float64,:Float64),
(:scnrm2_,:Complex64,:Float32))
@eval begin
function _jl_blas_nrm2(n::Integer, X::Union(Ptr{$elty},Array{$elty}), incx::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
$ret_type,
(Ptr{Int32}, Ptr{$elty}, Ptr{Int32}),
&n, X, &incx)
@@ -111,7 +111,7 @@ for (fname, elty) in ((:daxpy_,:Float64), (:saxpy_,:Float32),
function _jl_blas_axpy(n::Integer, a::($elty),
DX::Union(Ptr{$elty},Array{$elty}), incx::Integer,
DY::Union(Ptr{$elty},Array{$elty}), incy::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
Void,
(Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}),
&n, &a, DX, &incx, DY, &incy)
@@ -152,7 +152,7 @@ for (fname, elty) in ((:dsyrk_,:Float64), (:ssyrk_,:Float32),
function _jl_blas_syrk(uplo, trans, n::Integer, k::Integer,
alpha::($elty), A::StridedMatrix{$elty}, lda::Integer,
beta::($elty), C::StridedMatrix{$elty}, ldc::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
@@ -177,7 +177,7 @@ for (fname, elty) in ((:zherk_,:Complex128), (:cherk_,:Complex64))
function _jl_blas_herk(uplo, trans, n::Integer, k::Integer,
alpha::($elty), A::StridedMatrix{$elty}, lda::Integer,
beta::($elty), C::StridedMatrix{$elty}, ldc::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
@@ -204,7 +204,7 @@ for (fname, elty) in ((:dgbmv_,:Float64), (:sgbmv_,:Float32),
alpha::($elty), A::StridedMatrix{$elty}, lda::Integer,
x::StridedVector{$elty}, incx::Integer,
beta::($elty), y::StridedVector{$elty}, incy::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
@@ -234,7 +234,7 @@ for (fname, elty) in ((:dsbmv_,:Float64), (:ssbmv_,:Float32),
alpha::($elty), A::StridedMatrix{$elty}, lda::Integer,
x::StridedVector{$elty}, incx::Integer,
beta::($elty), y::StridedVector{$elty}, incy::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
@@ -263,7 +263,7 @@ for (fname, elty) in ((:dgemm_,:Float64), (:sgemm_,:Float32),
alpha::($elty), A::StridedMatrix{$elty}, lda::Integer,
B::StridedMatrix{$elty}, ldb::Integer,
beta::($elty), C::StridedMatrix{$elty}, ldc::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
@@ -465,7 +465,7 @@ for (fname, elty) in ((:dgemv_,:Float64), (:sgemv_,:Float32),
alpha::($elty), A::StridedMatrix{$elty}, lda::Integer,
X::StridedVector{$elty}, incx::Integer,
beta::($elty), Y::StridedVector{$elty}, incy::Integer)
- ccall(dlsym(_jl_libblas, $string(fname)),
+ ccall(dlsym(_jl_libblas, $(string(fname))),
Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
Oops, something went wrong.

0 comments on commit fd6b6fc

Please sign in to comment.