makth

Math Lexer

To use the math lexer, you should define a context first:

val context = Context()

Then, call the lexer with this context:

val result = MathLexer("1 + 2").execute(context) // 3

Thanks to the context, you can pass variables:

val context = Context(mapOf(
    "x" to IntegerFactory.instantiate(2)
))
val result = MathLexer("x + 3").execute(context) // 5