Yarnspinnex.Analysis (yarnspinnex v0.3.0)

Copy Markdown View Source

Static walks over parsed statements, for compile-time checks and tooling. bodies/1 is the one place that knows how statements nest; flatten/1 and the walks built on it follow from that.

Summary

Functions

The statement lists nested directly inside statement: <<if>> branches, else, option bodies.

The expressions statement evaluates itself, without nested statements, with their lines.

Every statement, depth first, including those nested in branches and options.

Every <<jump>> target, with its line, including inside options and <<if>> branches.

Every $name read, with the line of the statement reading it.

The statements with their source lines removed. A script's fingerprint is taken over this, so editing comments or blank lines does not invalidate stored cursors while changing a statement does.

Every $name assigned by <<set>> or <<declare>>, anywhere in the statements.

Functions

bodies(arg1)

The statement lists nested directly inside statement: <<if>> branches, else, option bodies.

expressions(arg1)

The expressions statement evaluates itself, without nested statements, with their lines.

flatten(statements)

Every statement, depth first, including those nested in branches and options.

jump_targets(statements)

Every <<jump>> target, with its line, including inside options and <<if>> branches.

reads(statements)

Every $name read, with the line of the statement reading it.

strip_lines(statements)

@spec strip_lines([Yarnspinnex.Parser.Body.statement()]) :: [tuple() | :stop]

The statements with their source lines removed. A script's fingerprint is taken over this, so editing comments or blank lines does not invalidate stored cursors while changing a statement does.

writes(statements)

@spec writes([Yarnspinnex.Parser.Body.statement()]) :: [String.t()]

Every $name assigned by <<set>> or <<declare>>, anywhere in the statements.