Building a grammar/parser for a calculator and then a more advanced one for a custom software language.
The technology used was ANTLR (ANother Tool for Language Recognition) which is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
For this purpose Java was used as a software language.
Mathematical Calculator
The following pictures show a grammar for a simple calculator, as well an example along with a parse tree.
Take the input: k=5, m=3+k*k. The answer 28 would be computed and printed to the console.
Custom Programming Language
To create a (simple) custom programming language a much more complicated grammar and parser logic is needed.
The following pictures show a (simple) example of a function and print statements. Note that the functions work just like in programming languages and can call each other, resulting in a very complex parse tree.