OpenUI.Parser (OpenUI v0.1.1)

Copy Markdown View Source

Parses OpenUI Lang into an OpenUI.Program (language.md, sections 1, 2 and 8).

parse/2 reads a complete response, which is the same as the end of a stream. It expects the program content: read a stored message with OpenUI.Message.parse/2 first. Parsing never raises: a mistake in the program drops the smallest unit and is reported in errors, and a failure of the parser itself becomes a parse-exception error.

Summary

Functions

Builds a program from statements. A later statement with a name already seen replaces it in place.

Parses a complete response.

Reads one statement text, closing it first when it was cut off. Returns nil when the text is not a statement.

Functions

build(statements, library, opts \\ [])

Builds a program from statements. A later statement with a name already seen replaces it in place.

Options:

  • :final (default true): the stream has ended, so no-root is reported and enum checks run;
  • :incomplete (default false): the text ended inside a string or a bracket;
  • :ignore_state (default []): state names not to declare yet, such as a $name still growing at the end of a stream.

parse(text, library)

@spec parse(String.t(), OpenUI.Library.t() | module()) :: OpenUI.Program.t()

Parses a complete response.

statement(text)

@spec statement(String.t()) :: OpenUI.Statement.t() | nil

Reads one statement text, closing it first when it was cut off. Returns nil when the text is not a statement.