Skip to main content

Rust · WebAssembly · in this tab

One grammar, compiled to Rust, running in this page.

The grammar that drives our JVM parser also drives a Rust parser: no second grammar, no hand-written port. Below, it runs in your browser as a 1.1 MB WebAssembly module. No server, no API call. Type, and watch it read.

Starting the parser…

What you are looking at

The parser’s own tree, as it read your text.

01

Named by the grammar

No names were invented for the tree. Each node is called what the grammar definition that read it is called, and each child by its field. The condition of a query’s WHERE sits at Select.where › Where.condition here, in the JVM library, and in the Rust crates.

02

Pinned to your text

Every token keeps its place in the input, counted in the units a JavaScript string counts. The editor’s colours, the highlight when you point at a node, and the node under your caret are all read off that tree. There is no separate highlighter to disagree with the parser.

03

Broken SQL still has a tree

A mistake becomes a problem in the answer, not an error page. It says where it is, what the grammar expected there, and where in the tree it stands. Everything around it is read as usual, so one typo does not cost you the rest of the file.

The same parser, everywhere

43,953 statements, zero failures.

Every PostgreSQL statement in our corpus is parsed by this Rust parser and rendered back byte for byte, whitespace and comments included. The grammar compiles to a parse plan: data, not code. The JVM parser and this one both read it, and both write the tree you see as the same JSON, byte for byte, which a parity suite checks on every change. What this page shows is what a Java program gets from the library.

Parsing PostgreSQL in your product?

The Rust parser will be open source. We are getting the first integrations right before opening the doors. If you build a data tool, a SQL editor, an agent or an edge runtime, tell us what you need.