Skip to main content

parse_to_ast

Function parse_to_ast 

Source
pub fn parse_to_ast(input: &str) -> Result<AstPattern, ParseError>
Expand description

Parse gram notation to AST (Abstract Syntax Tree).

Returns a single AstPattern representing the file-level pattern.

For the stable cross-language boundary used by the native TypeScript and Python packages, prefer the JSON array helpers in crate::json (gram_parse_to_json, gram_stringify_from_json, gram_validate_to_json).

§Why AST?

  • Language-agnostic: Pure JSON, works everywhere.
  • Complete: No information loss.
  • Simple: Just patterns and subjects (no graph concepts).

§Arguments

  • input - Gram notation text to parse

§Returns

  • Ok(AstPattern) - The parsed pattern as AST
  • Err(ParseError) - If parsing fails