Skip to content

Commit

Permalink
move internals to a new Internals module
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Doris committed Jan 16, 2025
1 parent b33e851 commit 22e953a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/Chevy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ if VERSION ≥ v"1.11"
eval(Expr(:public, :enable_repl))
end

function enable_repl end

function chevy end

macro chevy end

module Internals

import ..Chevy: enable_repl, chevy, @chevy

const tmp_index = Ref(0)

"""
Expand Down Expand Up @@ -97,6 +107,10 @@ Also replaces `<<` in the other direction.
- `f(y, z) << x` becomes `f(x, y, z)`
- `f(y, __, z) << x` becomes `f(y, x, z)` (note the double underscore)
- `x >> f(y) << z` becomes `f(z, x, y)`
Also `>>>` can be used to keep the previous value.
- `x >>> f() >> g()` becomes `tmp = x; f(tmp); g(tmp)`
"""
macro chevy(ex)
return esc(chevy(ex))
Expand Down Expand Up @@ -216,4 +230,6 @@ function truncate(ex)
end
end

end

end # module Chevy
8 changes: 4 additions & 4 deletions test/unit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ end
b
end)),
]
@assert Chevy.tmp_index[] == 0
Chevy.tmp_index[] = 1
@assert Chevy.Internals.tmp_index[] == 0
Chevy.Internals.tmp_index[] = 1
try
@test chevy(case.input) == case.output
finally
Chevy.tmp_index[] = 0
Chevy.Internals.tmp_index[] = 0
end
@assert Chevy.tmp_index[] == 0
@assert Chevy.Internals.tmp_index[] == 0
end

# syntax errors
Expand Down

0 comments on commit 22e953a

Please sign in to comment.