For example, I pass an expression string and a context table and it return a boolean value whether it was true/false. Can I do this using LPEG?
Something similar to this:
context = {
x = 3,
y = 3
}
local result = eval("x==y", context)
For example, I pass an expression string and a context table and it return a boolean value whether it was true/false. Can I do this using LPEG?
Something similar to this:
context = {
x = 3,
y = 3
}
local result = eval("x==y", context)
Copyright © 2021 Jogjafile Inc.
You can write an LPeg grammar that parses the expression into AST, and your eval function reads the AST and evaluates it using the context. See lpeg.re doc for how to get an AST using LPeg.