Inspect parsing and binding
The parse and bind commands expose two different stages of expression processing.
| Command | Stage | Question it answers |
|---|---|---|
parse | Syntax | How did the tokens and grammar form the syntax tree? |
bind | Syntax and semantics | Which functions, parameters, fields, and expression form were resolved? |
flowchart LR
A[Expression text] --> B[parse]
B --> C[Syntax tree]
C --> D[bind]
D --> E[Bound expression tree]
Inspect syntax
expressif parse '5 | add(3)'
The parse document describes each syntax node with:
Kind, the syntax-node kind;Text, the exact source text represented by the node;Span.Start, its zero-based character offset;Span.Length, its number of source characters;Children, its ordered child nodes.
Use parse when a diagnostic position, grammar interpretation, or shell-quoting result is surprising. The exact Text and Span values reveal what Expressif received.
Inspect binding
expressif bind '5 | add(3)'
Binding resolves the meaning of the parsed expression. Its output distinguishes open and closed roots and exposes resolved functions, argument positions, parameters, record fields, arrays, tuples, nested expressions, and intervals.
Use bind when parsing succeeds but a function, parameter, field, or open/closed classification is not what you expected.
Choose an output format
Both commands support three formats:
expressif parse '5 | add(3)' --output tree
expressif parse '5 | add(3)' --output json
expressif bind '5 | add(3)' --output yaml
| Format | Best use |
|---|---|
tree | Human inspection in a terminal or issue report. This is the default. |
json | Automated tooling and assertions. |
yaml | Readable structured output. |
Output-format names are matched without regard to case. Any other value is rejected.
Do not parse the human-oriented tree as a stable machine contract. Request JSON or YAML and use an appropriate parser.
Diagnose an expression step by step
- Run
parsewhen the grammar or reported source location is unexpected. - Check
TextandSpanto detect changes introduced by shell quoting. - Run
bindwhen syntax is valid but semantic resolution is wrong. - Use JSON for automated assertions and the tree view for human review.
- Use
validatewhen only pass/fail and a stable exit code are needed.
parse and bind accept an inline positional expression. They do not currently support --file.