gram/packages/parser
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-06-14 19:54:26 +02:00
..
scripts refactor(parser): make parser universal and clean up playground build 2026-06-13 23:42:24 +02:00
src refactor(parser): make parser universal and clean up playground build 2026-06-13 23:42:24 +02:00
CHANGELOG.md feat: release v.0.10.1 - implement Turborepo & updated dependencies 2026-06-14 19:54:26 +02:00
expected_JSON.json refactor: Moved source code to new packages folder 2026-01-02 20:16:03 +01:00
grammar.ohm refactor: extract analyzer logic into its own package and remove legacy ingredient data files 2026-06-07 13:31:15 +02:00
package.json feat: release v.0.10.1 - implement Turborepo & updated dependencies 2026-06-14 19:54:26 +02:00
README.md docs: Fixed mandatory usage of bun instead of npm 2026-06-14 10:58:02 +02:00
tsconfig.json refactor: Moved source code to new packages folder 2026-01-02 20:16:03 +01:00

@gram/parser

A robust, 3-stage parser for the GRAM recipe language. It is part of the GRAM monorepo and is strictly limited to text-to-AST parsing.


📚 General Documentation

For full syntax specifications, grammar details, cheatsheets, and best practices, please refer to the central GRAM Documentation Index.


Building

To build the project from source (TypeScript):

bun install
bun run build

This will generate the compiled JavaScript in the dist/ directory.


⚡ Usage

The package exports getAST() to convert GRAM source strings into a typed Recipe AST.

const { getAST } = require('@gram/parser');

const source = `
## My Recipe
Mix @flour{200g} and @water{100ml}.
`;

try {
    const ast = getAST(source);
    console.log(JSON.stringify(ast, null, 2));
} catch (e) {
    console.error("Parsing error:", e.message);
}

🏗️ Structure

  • src/index.ts: Orchestrates parsing and Ohm Semantics to AST conversions.
  • src/types.ts: Declares strictly-typed AST node definitions.
  • grammar.ohm: The official OhmJS grammar defining the GRAM language structure.

📄 License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.