@@ -74,16 +74,16 @@ Static type checker with struct as environment.
74
74
``` go
75
75
type Env struct {
76
76
Foo int
77
- Bar bar
77
+ Bar *Bar
78
78
}
79
79
80
80
type Bar struct {
81
81
Value int
82
82
}
83
83
84
- program , err := expr.Compile (" Foo + Bar.Value" , expr.Env (Env{}))
84
+ program , err := expr.Compile (" Foo + Bar.Value" , expr.Env (& Env{}))
85
85
86
- out , err := expr.Run (program, Env {1 , Bar {2 }})
86
+ out , err := expr.Run (program, & Env{1 , & Bar{2 }})
87
87
```
88
88
89
89
Using env's methods as functions inside expressions.
@@ -102,25 +102,16 @@ program, err := expr.Compile(`"Hello " + Title()`, expr.Env(&Env{}))
102
102
out , err := expr.Run (program, &Env{" world" })
103
103
```
104
104
105
- Using embedded structs to construct env.
105
+ ## Contributing
106
106
107
- ``` go
108
- type Env struct {
109
- Helpers
110
- Name string
111
- }
107
+ ** Expr** consist of a few packages for parsing source code to AST, type checking AST, compiling to bytecode and VM for running bytecode program.
112
108
113
- type Helpers struct {}
109
+ Also expr provides powerful tool [ exp ] ( cmd/exp ) for debugging. It has interactive terminal debugger for our bytecode virtual machine.
114
110
115
- func (Helpers ) Title (s string ) string {
116
- return strings.Title (s)
117
- }
118
-
119
-
120
- program , err := expr.Compile (` "Hello " + Title(Name)` , expr.Env (Env{}))
121
-
122
- out , err := expr.Run (program, Env {" world" })
123
- ```
111
+ <p align =" center " >
112
+ <img src="docs/images/debug.gif" alt="debugger" width="605">
113
+ </p >
114
+
124
115
125
116
## Who is using Expr?
126
117
0 commit comments