Skip to main content

parse_str

Function parse_str 

Source
pub fn parse_str<'arena, A>(
    arena: &'arena A,
    span: Span,
    input: &'arena [u8],
) -> Result<Type<'arena>, ParseError>
where A: Arena,
👎Deprecated:

use mago_phpdoc_syntax::parse_type instead

Expand description

Parses a string representation of a PHPDoc type into an arena-allocated Abstract Syntax Tree.

All AST nodes are allocated in the caller-supplied arena, so no per-node heap allocation happens during parsing. The resulting Type borrows from input (for textual slices) and from arena (for nested sub-trees) for the duration of 'arena.

§Arguments

  • arena - The arena that will own every AST node.
  • span - The original Span of the input string slice within its source file; used to anchor every produced span.
  • input - The type string to parse (e.g. "int|string", "array<int, MyClass>").

§Errors

Returns a ParseError if any lexing or parsing error occurs.