Class: ExpressionParser

ExpressionParser(configopt)

ExpressionParser is responsible for extracting state, computed properties, and methods from Avenx component source code.

Constructor

new ExpressionParser(configopt)

Parameters:
Name Type Attributes Default Description
config object <optional>
null

Project configuration object.

Source:

Methods

parseActionModifiers(content) → {Object:.<string:, {atomic:: boolean:, onConflict:: string:=}>}

Extracts Avenx Rewind modifiers from <action> tags.

Deliberately a second pass rather than a wider return type on ExpressionParser#parseMethods: that method's {name: body} shape is consumed by the code generator, by Atlas and by a dozen tests, and widening it to carry attributes would ripple through all of them for the sake of two optional flags.

atomic is a bare boolean in the same style as <contract static pure />. onConflict selects what a rewind does when it finds a value the transaction did not write; omitting it falls back to the project's rewind.onConflict, which is why an absent value is left undefined here rather than defaulted.

Parameters:
Name Type Description
content string

The component source code.

Source:
Throws:

When onConflict names an unknown policy.

Type
TemplateValidationError
Returns:

Modifiers by action name. Only actions that declare one appear.

Type
Object:.<string:, {atomic:: boolean:, onConflict:: string:=}>

parseComputed(content) → {object}

Extracts computed property definitions from tags.

Parameters:
Name Type Description
content string

The component source code.

Source:
Returns:

A map of computed property names to their expressions.

Type
object

parseContracts(content) → {Set:.<string:>}

Extracts declared component-level compiler contracts from tags. Supports attributes: static, pure, deterministic, isolated (boolean or valueless).

Parameters:
Name Type Description
content string

The component source code.

Source:
Returns:

The set of active contracts for the component.

Type
Set:.<string:>

parseDynamicAttribute(attrName, attrValueopt) → {object|null}

Parses dynamic attribute name binding expressions matching ^:[(.*)]$.

Parameters:
Name Type Attributes Description
attrName string

The attribute name (e.g. ":[dynamicAttr]").

attrValue string <optional>

The attribute value expression.

Source:
Returns:

Metadata object containing expression details or null if not a dynamic attribute.

Type
object | null

parseMethods(content) → {object}

Extracts method definitions from tags.

Parameters:
Name Type Description
content string

The component source code.

Source:
Returns:

A map of method names to their source code.

Type
object

parseResources(content) → {object}

Extracts resource definitions from tags.

Parameters:
Name Type Description
content string

The component source code.

Source:
Returns:

A map of resource names to their handler expressions.

Type
object

parseState(content, configopt) → {object}

Extracts the initial state from tags.

Parameters:
Name Type Attributes Default Description
content string

The component source code.

config object <optional>
null

Optional override configuration object.

Source:
Returns:

The extracted state object.

Type
object