Skip to content

Commit 14f3136

Browse files
committed
Remove JuliaLowering parsing hook
Moved to [JuliaLowering](c42f/JuliaLowering.jl#10) instead (the data structure we need is defined there).
1 parent 77eaac3 commit 14f3136

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/expr.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,6 @@ function build_tree(::Type{Expr}, stream::ParseStream;
577577
only(_fixup_Expr_children!(SyntaxHead(K"None",EMPTY_FLAGS), loc, Any[entry.ex]))
578578
end
579579

580-
581-
function build_tree(::Type{Tuple{Expr, SyntaxNode}}, stream::ParseStream;
582-
filename=nothing, first_line=1, kws...)
583-
syntaxtree = build_tree(SyntaxNode, stream; filename, first_line, kws...)
584-
Expr(:toplevel, map(Expr, syntaxtree))
585-
end
586-
587580
function _to_expr(node)
588581
file = sourcefile(node)
589582
if is_leaf(node)

src/hooks.jl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ end
136136
# Debug log file for dumping parsed code
137137
const _debug_log = Ref{Union{Nothing,IO}}(nothing)
138138

139-
function core_parser_hook_for_lowering(code, filename::String, lineno::Int, offset::Int, options::Symbol)
140-
core_parser_hook(code, filename::String, lineno::Int, offset::Int, options::Symbol, true)
141-
end
142-
143139
function core_parser_hook(code, filename::String, lineno::Int, offset::Int, options::Symbol, for_lowering=false)
144140
try
145141
# TODO: Check that we do all this input wrangling without copying the
@@ -237,7 +233,7 @@ function core_parser_hook(code, filename::String, lineno::Int, offset::Int, opti
237233
#
238234
# show_diagnostics(stdout, stream.diagnostics, code)
239235
#
240-
ex = build_tree(for_lowering ? Tuple{Expr, SyntaxNode} : Expr, stream; filename=filename, first_line=lineno)
236+
ex = build_tree(Expr, stream; filename=filename, first_line=lineno)
241237
end
242238

243239
# Note the next byte in 1-based indexing is `last_byte(stream) + 1` but
@@ -294,9 +290,8 @@ end
294290

295291
_default_system_parser = _has_v1_6_hooks ? Core._parse : nothing
296292

297-
298293
# hook into InteractiveUtils.@activate
299-
activate!(enable=true; for_lowering=false) = enable_in_core!(enable, for_lowering)
294+
activate!(enable=true) = enable_in_core!(enable)
300295

301296
"""
302297
enable_in_core!([enable=true; freeze_world_age=true, debug_filename=nothing])
@@ -312,7 +307,7 @@ Keyword arguments:
312307
* `debug_filename` - File name of parser debug log (defaults to `nothing` or
313308
the value of `ENV["JULIA_SYNTAX_DEBUG_FILE"]`).
314309
"""
315-
function enable_in_core!(enable=true, for_lowering=false; freeze_world_age = true,
310+
function enable_in_core!(enable=true; freeze_world_age = true,
316311
debug_filename = get(ENV, "JULIA_SYNTAX_DEBUG_FILE", nothing))
317312
if !_has_v1_6_hooks
318313
error("Cannot use JuliaSyntax as the main Julia parser in Julia version $VERSION < 1.6")
@@ -324,9 +319,8 @@ function enable_in_core!(enable=true, for_lowering=false; freeze_world_age = tru
324319
_debug_log[] = nothing
325320
end
326321
if enable
327-
hook = for_lowering ? core_parser_hook_for_lowering : core_parser_hook
328322
world_age = freeze_world_age ? Base.get_world_counter() : typemax(UInt)
329-
_set_core_parse_hook(fix_world_age(hook, world_age))
323+
_set_core_parse_hook(fix_world_age(core_parser_hook, world_age))
330324
else
331325
@assert !isnothing(_default_system_parser)
332326
_set_core_parse_hook(_default_system_parser)

0 commit comments

Comments
 (0)