@@ -68,7 +68,7 @@ function _expr_leaf_val(node::SyntaxNode)
68
68
node. val
69
69
end
70
70
71
- function _leaf_to_Expr (source, txtbuf, head, srcrange, node)
71
+ function _leaf_to_Expr (source, txtbuf, txtbuf_offset, head, srcrange, node)
72
72
k = kind (head)
73
73
if k == K " MacroName" && view (source, srcrange) == " ."
74
74
return Symbol (" @__dot__" )
@@ -77,7 +77,9 @@ function _leaf_to_Expr(source, txtbuf, head, srcrange, node)
77
77
Expr (:error ) :
78
78
Expr (:error , " $(_token_error_descriptions[k]) : `$(source[srcrange]) `" )
79
79
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)
81
83
if val isa Union{Int128,UInt128,BigInt}
82
84
# Ignore the values of large integers and convert them back to
83
85
# symbolic/textural form for compatibility with the Expr
@@ -547,7 +549,7 @@ function build_tree(::Type{Expr}, stream::ParseStream;
547
549
end
548
550
k = kind (head)
549
551
if isnothing (nodechildren)
550
- ex = _leaf_to_Expr (source, txtbuf, head, srcrange, nothing )
552
+ ex = _leaf_to_Expr (source, txtbuf, 0 , head, srcrange, nothing )
551
553
else
552
554
resize! (childranges, length (nodechildren))
553
555
resize! (childheads, length (nodechildren))
568
570
function _to_expr (node)
569
571
file = sourcefile (node)
570
572
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)
573
575
end
574
576
cs = children (node)
575
577
args = Any[_to_expr (c) for c in cs]
0 commit comments