Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SpecialBrands/goexpression

Repository files navigation

Go Expression

Version: 0.01 Alpha MIT License (MIT)

go expression is a basic math expression parser and evaluator. This project is in alpha phase and may change significantly in the near future.

The purpose is to learn go and use the expression parser in other projects.

Status

Supported

  • Basic Math Operators like '+', '-', '*', '/'
  • Operator precedence, Ex: 1+2*3 = 1+6 = 7
  • grouping () Ex: (1+2)*3
  • variables Ex: 1+x where x is passed as a variable to Eval.
  • only parsing works for;
  • Define a variable Ex: x=6

Parsing only

  • Text values inclused in qoutes.
  • Functions with arguments, ex: myfunc(1,2)
  • Boolean types and expressions like '==', '<', '>', '!', 'and', 'or'

Planned

  • Special keywords like. if, each, etc
  • Calling go functions from the expression

Basic usage

context := map[string]interface{}{
"x": 5,
"y": 21,
"z": 12.5,
}
ans:=goexpression.Eval("1+x*(50-y)/z", context)
fmt.Printf("=%v",ans)

About

expression parser and evaluator in golang

Resources

Readme

License

MIT license

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

  • Go 100.0%