Introduction
What this example shows:
- how to take input string and execute it as expression
- how to tokenize a string into tokens (lexer class implemented as Tokenizer.cs)
- how to take series of tokens from lexer and build abstract syntax tree (AST).
This is a very simple parser, implemented as AParser.cs
- how to take AST and evaluate it as expression. This also allows
variable assignment and usage and function calls.
- how to build pretty printer class to print back expressions
Operators supported:
binary operators: +, -, *, /
unary operators: +, -
parenthesis grouping
built in functions: sin, cos, abs, pow, sqrt, exp, log (easy to add more functions in Evaluator.cs)
type: exit to quit program
Example usage:
x = sin(3.3) + 6 * sqrt(23)
y = cos(0.343)
pow(x, 3) + y / 3
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.