I am slowly creating a simple programming language (a bit like Lua).
The interpreter has 2 important methods, exec and evaluate.
exec reads the tokens 1 by 1 and does stuff as it says like creating new variables, etc.
evaluate basically interprets a bit differently.
It understands ==, new numbers (5.3), +-*/^% and new strings with "".
It also understands variables and takes their value to be used.
In the end of evaluate, it returns one value for exec to use.
A ginormous design hole in this interpreter is the fact that you cannot create new strings in exec without creating a variable.
Meaning:
string a = "some string";
a.someStringMethod();
Works, but this:
"some string".someStringMethod();
does not.
This also means multidimensional arrays do not work, although I plan to use . instead of [ and ].
If you still do not understand how the interpreter right now here is the GitHub page on it:
https://github.com/lvivtotoro/mau/blob/master/Mau/src/org/midnightas/mau/Mau.java#L56
So the overall question is: How would I merge these 2 methods?
execis for interpreting,evaluateis for mathematical/expressions that returns a value forexecto use. Ifexecever foundnumber a = 5 + 5;, it would askexecwhat5 + 5is, then setato the result.