The @internal/psl-parser package provides a reusable parser for Prisma Schema Language (PSL). It is designed for use in a provider-based authoring model where a provider needs to transform PSL source into a machine-readable format.
The typical workflow for a PSL provider is:
- Call
parse(schema) to obtain a Concrete Syntax Tree (CST) (DocumentAst) and a SourceFile. - Call
buildSymbolTable(...) using the parsed CST to obtain a scope-aware SymbolTable. - Return the resulting contract and diagnostics to the framework emit pipeline.
Note: This package handles syntax, structure, and spans. It does not perform semantic normalization, file I/O, or emit contract IR/files (like contract.json).
```ts
// Conceptual workflow for a PSL provider
const { document, sourceFile, diagnostics: parseDiagnostics } = parse(schema);
const { symbolTable, diagnostics: symbolDiagnostics } = buildSymbolTable({
document,
sourceFile,
scalarTypes,
pslBlockDescriptors
});
// Combine diagnostics and return to framework
// Result<Contract, ContractSourceDiagnostics>
```埋