[GSP-1] Feature: Add support for extracting the full AST via means _other than_ encoding/json #13
Labels
documentation
Improvements or additions to documentation
enhancement
New feature or request
linear
Sync issue with linear
Context
Currently, compiling this library to WASM provides an awesome resource for downstream consumers. The way the parser and AST are constructed makes it easy to parse SQL statements, and then return a normalized/parsed version of the string(s), as well as catch any errors along the way. However, since current WASM build tools in Go do not support Reflect properly, things like encoding/JSON to easily export the AST to WASM and beyond are stymied. There are some proposed solutions: tinygo-org/tinygo#447, but these don't work for our AST, because we take advantage of anonymous interfaces and other custom interfaces, for which there is no clean solution without reflect.
Ideal Solution
Ideally, our AST would either a) avoid custom interfaces (lame!), or b) would have a custom marshaling solution that could be used instead of relying on any form of reflection to extract structure. That way, a WASM build could simple (recursively) call the marshal function on the statements, and then return this to the JS side as bytes or a map[string]interface{} or other.
Ideas for marshaling could include real JSON bytes marshaling, or even simply outputting a set of JSON compatible values (map, int, float, nil, array) style solution.
GSP-1
The text was updated successfully, but these errors were encountered: