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

Implemented else if, closes #27 #133

Merged
merged 1 commit into from
Jan 26, 2019
Merged

Implemented else if, closes #27 #133

merged 1 commit into from
Jan 26, 2019

Conversation

odino
Copy link
Collaborator

@odino odino commented Jan 26, 2019

This commit adds the ability to add multiple IF
conditions in an IF block by using if else:

if x {
  ...
} else if y {
  ...
} else if z {
  ...
} else {
  ...
}

I decided to change the data structure that represents
IFs because it was very limited, only allowing for
a condition, a consequence and an alternative consequence.

Now IFs are a list of Scenario, made of conditions and
consequences. If we encounter a bare else we set the condition
of that scenario to true, so that it always evaluates to true.

One funny thing that this structure does is that it allows
for code like this:

if x {
  ...
} else {
  ...
} else if y {
  ...
}

(else before else if)

I honestly don't mind having this (it's a fun easter egg), but
we might want to raise a parser error later on if users find it
annoying.

This commit adds the ability to add multiple IF
conditions in an IF block by using `if else`:

```
if x {
  ...
} else if y {
  ...
} else if z {
  ...
} else {
  ...
}
```

I decided to change the data structure that represents
IFs because it was very limited, only allowing for
a condition, a consequence and an alternative consequence.

Now IFs are a list of `Scenario`, made of conditions and
consequences. If we encounter a bare `else` we set the condition
of that scenario to true, so that it always evaluates to true.

One funny thing that this structure does is that it allows
for code like this:

```
if x {
  ...
} else {
  ...
} else if y {
  ...
}
```

(`else` before `else if`)

I honestly don't mind having this (it's a fun easter egg), but
we might want to raise a parser error later on if users find it
annoying.
@odino odino added this to the 1.0 milestone Jan 26, 2019
@odino odino merged commit 3ac32fa into 1.0 Jan 26, 2019
odino added a commit that referenced this pull request Jan 27, 2019
Issue #133 introduced a leftover in the code that
has gone unnoticed since our tests are very brief:
long-story short, if you had any working code after
and if-else, the  parser would skip a token, resulting
in *fun times*.

This removes the leftover code that was there by mistake.
Preparing to rollout `1.0.1` as this is kind of a big deal.
odino added a commit that referenced this pull request Jan 27, 2019
Issue #133 introduced a leftover in the code that
has gone unnoticed since our tests are very brief:
long-story short, if you had any working code after
and if-else, the  parser would skip a token, resulting
in *fun times*.

This removes the leftover code that was there by mistake.
Preparing to rollout `1.0.1` as this is kind of a big deal.
@odino odino deleted the elseif branch February 24, 2019 05:48
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

Successfully merging this pull request may close these issues.

1 participant