@@ -68,7 +68,7 @@ function _expr_leaf_val(node::SyntaxNode)
6868 node. val
6969end
7070
71- function _leaf_to_Expr (source, txtbuf, head, srcrange, node)
71+ function _leaf_to_Expr (source, txtbuf, txtbuf_offset, head, srcrange, node)
7272 k = kind (head)
7373 if k == K " MacroName" && view (source, srcrange) == " ."
7474 return Symbol (" @__dot__" )
@@ -77,7 +77,9 @@ function _leaf_to_Expr(source, txtbuf, head, srcrange, node)
7777 Expr (:error ) :
7878 Expr (:error , " $(_token_error_descriptions[k]) : `$(source[srcrange]) `" )
7979 else
80- val = isnothing (node) ? parse_julia_literal (txtbuf, head, srcrange) : _expr_leaf_val (node)
80+ val = isnothing (node) ?
81+ parse_julia_literal (txtbuf, head, srcrange .+ txtbuf_offset) :
82+ _expr_leaf_val (node)
8183 if val isa Union{Int128,UInt128,BigInt}
8284 # Ignore the values of large integers and convert them back to
8385 # symbolic/textural form for compatibility with the Expr
@@ -547,7 +549,7 @@ function build_tree(::Type{Expr}, stream::ParseStream;
547549 end
548550 k = kind (head)
549551 if isnothing (nodechildren)
550- ex = _leaf_to_Expr (source, txtbuf, head, srcrange, nothing )
552+ ex = _leaf_to_Expr (source, txtbuf, 0 , head, srcrange, nothing )
551553 else
552554 resize! (childranges, length (nodechildren))
553555 resize! (childheads, length (nodechildren))
568570function _to_expr (node)
569571 file = sourcefile (node)
570572 if is_leaf (node)
571- offset , txtbuf = _unsafe_wrap_substring (sourcetext (file))
572- return _leaf_to_Expr (file, txtbuf, head (node), byte_range (node) .+ offset , node)
573+ txtbuf_offset , txtbuf = _unsafe_wrap_substring (sourcetext (file))
574+ return _leaf_to_Expr (file, txtbuf, txtbuf_offset, head (node), byte_range (node), node)
573575 end
574576 cs = children (node)
575577 args = Any[_to_expr (c) for c in cs]
0 commit comments