File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,44 @@ func main() {
98
98
}
99
99
```
100
100
101
+ [ Play Online] ( https://play.golang.org/p/4S4brsIvU4i )
102
+
103
+ ``` go
104
+ package main
105
+
106
+ import (
107
+ " fmt"
108
+ " github.com/antonmedv/expr"
109
+ )
110
+
111
+ type Tweet struct {
112
+ Len int
113
+ }
114
+
115
+ type Env struct {
116
+ Tweets []Tweet
117
+ }
118
+
119
+ func main () {
120
+ code := ` all(Tweets, {.Len <= 240})`
121
+
122
+ program , err := expr.Compile (code, expr.Env (Env{}))
123
+ if err != nil {
124
+ panic (err)
125
+ }
126
+
127
+ env := Env{
128
+ Tweets: []Tweet{{42 }, {98 }, {69 }},
129
+ }
130
+ output , err := expr.Run (program, env)
131
+ if err != nil {
132
+ panic (err)
133
+ }
134
+
135
+ fmt.Println (output)
136
+ }
137
+ ```
138
+
101
139
## Contributing
102
140
103
141
** Expr** consist of a few packages for parsing source code to AST, type checking AST, compiling to bytecode and VM for running bytecode program.
You can’t perform that action at this time.
0 commit comments