You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+10-2
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ A simplistic expression evaluator in Go.
5
5
This is a research project.\
6
6
It is work in progress and right now in a very early stage.
7
7
8
-
Check the tests in [`tree_test.go`](tree_test.go)for ideas of usage and capability, notably `TestTree_Eval*` tests.
8
+
Check the tests for ideas of usage and capability.
9
9
10
10
## Numbers
11
11
@@ -42,4 +42,12 @@ Expressions are parsed in two stages:
42
42
Notes:
43
43
44
44
- a Tree may contain one or more sub-Trees (recursively or not) to hold functions or to express associativity.
45
-
- Calculation is performed in successive executions of by decreased operator precedence.
45
+
- Calculation is performed in successive rounds of decreased operator precedence. This is to enforce natural associativity.
46
+
47
+
## Code structure
48
+
49
+
The main entry point is `Eval` in `gal.go`.
50
+
51
+
`Eval` instantiates a `TreeBuilder` optionally with configuration (notably to pass a map of variable names and values). It subsequently calls `TreeBuilder`'s `FromExpr` method to create a `Tree` from the expression to be evaluated.
52
+
53
+
Finally, `Tree`'s `Eval` method performs the evaluation of the `Tree` and returns the resultant `Value` to `gal.go`'s `Eval` function.
0 commit comments