func main() { scanner := bufio.NewScanner(os.Stdin) for { fmt.Print("> ") if !scanner.Scan() { break } expr, err := eval.Parse(scanner.Text()) if err != nil { fmt.Println(err) continue } if err = expr.Check(map[eval.Var]bool{}); err != nil { fmt.Println(err) continue } fmt.Println(expr.Eval(eval.Env{})) } }
func main() { expr, _ := eval.Parse("x ? y") fmt.Println(expr.Eval(eval.Env{"x": 10, "y": 20})) }
func main() { expr, _ := eval.Parse("pow(x + pow(y))") fmt.Println(expr.String()) }