Abstract syntax tree source location (source code)

= Abstract syntax tree source location

An <abstract syntax tree> can retain source locations even while omitting punctuation nodes. <Python> records one-based line numbers and zero-based UTF-8 byte offsets, with the end offset exclusive. In `x=2+3*4`, the <multiplication> node spans offsets $4$ through $7$, and `ast.get_source_segment` returns `3*4`. A copied location on a folded `12` describes the original span, not text newly present in the source. Such metadata supports error messages and editing tools without making an <abstract syntax tree> a lossless record of formatting. <Python 3.14 documentation/ast — Abstract syntax trees, Python 3.14 documentation>[Node classes: lineno, col_offset, end_lineno and end_col_offset; get_source_segment and copy_location]{ref}

// Target: computer-science.bigb