I am writing an interpreter and have come that far that I need to identify or-stataments( || ).
Just for fundamental analysis. The code is not a problem. Only the thinking here.
My problem is that I am not quite sure how I have to think. I know how it works if I write it in C++, how to use parantheses ((...)) and so. That is not a problem.
The problem I have now is to identify both sides of an or statment in words.
In order to do this I understand that I have to think in parantheses in any way.
For ex:
if any of either sides in this statement is true, the whole statment is true. This is easy.
What I will do here is to create 2 .txtfiles with each statement because this gives 2 alternatives.
m > m2 || n > n2
A worse example will be if I put an && and an || to it like this with parantheses ((...))
Now the or statement wont have the same meening as above. This will also give 2 alternatives regarding the || statement but the whole statement will only create 1 file.
(m > m2 && (n > n2 || o > o2))
I am not sure if the idéa is cathed.
I am doing some examples below.
I might be interested to catch some fundamental idéas to how to think here.
I am quite stuck.
I have to find a red line to follow that will work for all possible scenarios.
For all these examples. 2 scenarios/colors can be true but how to identify one || from the other || to be more sure I will think right.
//Clean statement with one ||
((m > m2 && n > n2) || (o > o2 && p > p2))
//Added one more ||
((m > m2 && (n > n2 || o > o2)) || (p > p2))
//Added 2 ((...)) for the Whole statement
((((m > m2 && (n > n2 || o > o2)) || (p > p2))))
//Added 1 (..) for first || statement
((((m > m2 && ((n > n2 || o > o2))) || (p > p2))))