Open RCHowell opened 1 week ago
Alternative modeling could follow what we do in partiql-lang-rust
. That is, create a parser result which stores the AST along with a source location map https://github.com/partiql/partiql-lang-rust/blob/3f9d17fb38edafb23c1908af27b06c78d66680cd/partiql-parser/src/lib.rs#L81-L86.
Modeling with a map should offer the same functionality as spans on every node and not require additional fields.
Something like https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
But it would make sense to have these be lazy so that we don't create many needless objects until the locations are actually used .. just to cut down on object creation for ASTs. Really, a node should only need its line/column pair and can compute a span from the children.