How do I define an if statement?

En
- in Nintendo
7

I'm writing on Nintendo switch with a program that is not working, so I'm trying to write a python interpreter, but now there's a question, how do I define or assign the if statement. You can also send me examples in other programming languages so I can see how you would define an if statement.

fa

So how do you write an if? If so

python
if x == y:
#then
else:
#otherwise
Php Java c JavaScript
if (x == y) {
#then
}
else {
#otherwise
}

En

Yes, I know that is exactly what it was not about.
it's about how I write an if stament myself, so define it.
As it were, like an if function

fa

What for?

En

To write an interpreter.

fa

Your interpreter recognizes the if in the code and the interpreter then uses if to check the expression.

Fe

Such a structure usually consists of start and end marks for the condition and the body. Let's take a look at such an expression in Visual Basic (because this language regulates more with words than with characters - I think it is easier to see for visual clarification):

IF condition THEN
'do something
END IF

IF and THEN serve as a grouping of the condition.
THEN and END IF serve as a grouping of the instructions to be executed
The IF makes it clear that this expression is a branch, not another control structure like the loop, which also requires a condition.

You can also find this in Python:

if condition:
# do something

Only here the colon takes the role of THEN and the indentations or a semicolon indicate when the hull was finished.

An expression tree could be created for the condition. First the condition has to be broken down into individual tokens and the as yet unknown symbols have to be decrypted. Then the structure can be gradually dissolved / converted to FUZE BASIC.

En

Thank you very much