Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement semantic of if statement #11

Open
meevee98 opened this issue Dec 18, 2019 · 0 comments
Open

Implement semantic of if statement #11

meevee98 opened this issue Dec 18, 2019 · 0 comments

Comments

@meevee98
Copy link
Owner

meevee98 commented Dec 18, 2019

If is one of the control flow statements that which perform different computations depending on the value of the given Boolean condition.

This is the syntax of the if statement in the PNP language:

se <condition> entao
    <block of instructions when the condition is true>
senao
    <block of instructions when the condition is false>
fim

The else branch can be omitted. An if statement can have multiple branches. Each branch can only be computed if its respective condition value is true and all the other branches won't be computed.

se <condition-1> entao
    <block of instructions when the condition-1 is true>
senao se <condition-2> entao
    <block of instructions when only the condition-2 is true>
senao se <condition-3> entao
    <block of instructions when only the condition-3 is true>
senao
    <block of instructions when all conditions are false>
fim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant