diff --git a/src/expr.jl b/src/expr.jl index 638e0b75..0a6f16a7 100644 --- a/src/expr.jl +++ b/src/expr.jl @@ -140,7 +140,7 @@ function _string_to_Expr(args) # """\n a\n b""" ==> "a\nb" return only(args2) else - # This only happens when the kind is K"string" or when an error has occurred. + # This only happens when the kind is K"string" or when an error has occurred. return Expr(:string, args2...) end end @@ -159,7 +159,7 @@ function _fixup_Expr_children!(head, loc, args) arg = args[i] was_parens = @isexpr(arg, :parens) arg = _strip_parens(arg) - if @isexpr(arg, :(=)) && eq_to_kw_in_call && i > 1 + if @isexpr(arg, :(=)) && eq_to_kw_in_call && i > 1 arg = Expr(:kw, arg.args...) elseif k != K"parens" && @isexpr(arg, :., 1) && arg.args[1] isa Tuple h, a = arg.args[1]::Tuple{SyntaxHead,Any} diff --git a/src/hooks.jl b/src/hooks.jl index 914c0c1b..1c31030f 100644 --- a/src/hooks.jl +++ b/src/hooks.jl @@ -290,6 +290,9 @@ end _default_system_parser = _has_v1_6_hooks ? Core._parse : nothing +# hook into InteractiveUtils.@activate +activate!(enable=true) = enable_in_core!(enable) + """ enable_in_core!([enable=true; freeze_world_age=true, debug_filename=nothing]) diff --git a/src/syntax_tree.jl b/src/syntax_tree.jl index aa3d4009..7f7776e7 100644 --- a/src/syntax_tree.jl +++ b/src/syntax_tree.jl @@ -131,7 +131,8 @@ numchildren(node::TreeNode) = (isnothing(node.children) ? 0 : length(node.childr Base.getindex(node::AbstractSyntaxNode, i::Int) = children(node)[i] Base.getindex(node::AbstractSyntaxNode, rng::UnitRange) = view(children(node), rng) Base.firstindex(node::AbstractSyntaxNode) = 1 -Base.lastindex(node::AbstractSyntaxNode) = length(children(node)) +Base.length(node::AbstractSyntaxNode) = length(children(node)) +Base.lastindex(node::AbstractSyntaxNode) = length(node) function Base.setindex!(node::SN, x::SN, i::Int) where {SN<:AbstractSyntaxNode} children(node)[i] = x