Update README.md

This commit is contained in:
Anton Medvedev
2019-05-28 12:05:21 +07:00
parent 62a9339264
commit ef1c09900f
2 changed files with 10 additions and 19 deletions
+10 -19
View File
@@ -74,16 +74,16 @@ Static type checker with struct as environment.
```go
type Env struct {
Foo int
Bar bar
Bar *Bar
}
type Bar struct {
Value int
}
program, err := expr.Compile("Foo + Bar.Value", expr.Env(Env{}))
program, err := expr.Compile("Foo + Bar.Value", expr.Env(&Env{}))
out, err := expr.Run(program, Env{1, Bar{2}})
out, err := expr.Run(program, &Env{1, &Bar{2}})
```
Using env's methods as functions inside expressions.
@@ -102,25 +102,16 @@ program, err := expr.Compile(`"Hello " + Title()`, expr.Env(&Env{}))
out, err := expr.Run(program, &Env{"world"})
```
Using embedded structs to construct env.
## Contributing
```go
type Env struct {
Helpers
Name string
}
**Expr** consist of a few packages for parsing source code to AST, type checking AST, compiling to bytecode and VM for running bytecode program.
type Helpers struct{}
Also expr provides powerful tool [exp](cmd/exp) for debugging. It has interactive terminal debugger for our bytecode virtual machine.
func (Helpers) Title(s string) string {
return strings.Title(s)
}
program, err := expr.Compile(`"Hello " + Title(Name)`, expr.Env(Env{}))
out, err := expr.Run(program, Env{"world"})
```
<p align="center">
<img src="docs/images/debug.gif" alt="debugger" width="605">
</p>
## Who is using Expr?
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB