Skip to main content

Crate ruprizzle_parser

Crate ruprizzle_parser 

Source
Expand description

schema.ruprizzle parser.

The public surface is deliberately one function, parse. Everything else — the Pest grammar, the loose AST, the five lowering passes, the validation rule table — is an implementation detail behind it. That narrowness is what makes replacing the parser a contained change rather than a schedule risk (see the fallback note in ImplPlan02SchemaDslParser.md).

let schema = ruprizzle_parser::parse(
    "schema.ruprizzle",
    r#"
    datasource db {
      provider = "postgres"
      url      = env("DATABASE_URL")
    }

    model User {
      id    Uuid   @id @default(uuid7())
      email String @unique
    }
    "#,
)
.expect("valid schema");

assert_eq!(schema.model("User").unwrap().table, "users");

Errors accumulate: one call reports every problem it can find, each with a span and a suggested fix.

Re-exports§

pub use ast::Ast;

Modules§

ast
The loose syntax tree, one step away from the grammar.
naming
The naming convention: how a declaration becomes a physical name.

Functions§

parse
Parses and validates a schema.
parse_ast
Parses a schema without validating it, for tests and tooling that need the syntax tree rather than the IR.
parse_with_warnings
Like parse, but also returns the advisory diagnostics.