mtparser

MySQL mysqltest / MariaDB mariadb-test file parser.

Parses .test / .inc files into an AST.

Architecture

mysqltest syntax is line-oriented, so the parser runs in three stages:

  1. Lines — split the source into lines, each tagged with a byte offset (mtparser/lines)
  2. Classify — decide what each line is (blank / comment / command / delimiter-terminated statement)
  3. Parse — parse command arguments within the statement text (mtparser/parser)

Parser state (current delimiter) is threaded explicitly through function calls; there is no mutable state. The command set is the union of all supported MySQL/MariaDB versions (maximum compatibility, no version gating), and unrecognized -- commands degrade to SQL text, so parse succeeds on any input.

Gleam rewrite of the Rust/winnow version (../mtparser-rs), which hit complexity issues from the mismatch between winnow’s pure-combinator model and line-oriented mutable-delimiter parsing.

Values

pub fn parse(
  input: String,
) -> Result(List(ast.Statement), error.ParserError)

Parse a complete test file into an AST.

✨ Search Document