Skip to content

Commit

Permalink
Review feedback and other corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
webbnh committed Mar 5, 2024
1 parent 9d476c9 commit 9cfa6af
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 118 deletions.
21 changes: 10 additions & 11 deletions docs/arcaflow/contributing/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,37 @@ The [expressions library](https://github.com/arcalot/arcaflow-expressions/) prov

The library consists of two parts: the internal [parser/AST](https://github.com/arcalot/arcaflow-expressions/tree/main/internal/ast) and the [API layer](https://github.com/arcalot/arcaflow-expressions).

## The parser / AST
## The Parser / AST

The expressions parser constructs an [Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) from the expression which can then be walked by the API layer. The AST consists of the following node types:

### Dot notation
### Dot Notation

Let's say you have an expression `foo.bar`. The dot notation node is the dot in the middle. The left subtree of the dot will be the entire expression left of the dot, while the right subtree will be everything to the right.

### Map accessor
### Bracket Expression

Map accessors are expressions in the form of `foo[bar]`. The left subtree will represent the expression to the left of the brackets (`foo` in the example), while the right subtree will represent the subexpression within the brackets (`bar` in the example).
Bracket expressions are expressions in the form of `foo[bar]`. The left subtree will represent the expression to the left of the brackets (`foo` in the example), while the right subtree will represent the subexpression within the brackets (`bar` in the example).

### Binary Operations

Binary operations include all of the operations that have a left and right sub-tree that do not have a special node representing them (dot notation is an example of a special case).
They are represented as a node that has a left and right subtree, and an operator that describes which binary operation type is being applied.
Binary operations include all of the operations that have a left and right subtree that do not have a special node representing them (dot notation and bracket expression are examples of special cases).
Binary operations are represented by a node containing an operation and the subtrees to which the operation is applied.

### Unary Operations

Unary operations include boolean complement `!` and numeric negation `-`.
Unary operations are represented as a node that has one child node (the tree it's applied to) and one operator that describes the operation being applied to the child node.

Unary operations are represented by a node containing an operation and the subtree to which the operation is applied.
Unlike binary operations, unary operations have only one subtree.

### Identifiers

Identifiers come in two forms:

1. `$` references the root of the data structure.
2. A plain string identifier from a token matching the regular expression `^\w+$`.
a. This may be used for accessing object fields or as function identifiers.
2. A plain string identifier from a token matching the regular expression `^\w+$`. This may be used for accessing object fields or as function identifiers.

## The API layer
## The API Layer

The API layer provides three functions:

Expand Down
Loading

0 comments on commit 9cfa6af

Please sign in to comment.