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

(#74) Basic switch-case support #139

Closed
wants to merge 1 commit into from

Conversation

gsomix
Copy link
Contributor

@gsomix gsomix commented Jul 21, 2022

Closes #74

  • Add labeled and switch statements to parser
  • Add switch statement to IR
  • Write codegen for switch-case
  • Add samples

private static Statement MakeLabelStatement(IToken identifier, IToken _, Statement block) =>
new LabelStatement(identifier.Text, block);

// TODO: constant or constant-expression? What's difference? gsomix.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsomix constant is just 5 , constant-expression can be 4+5

@kant2002
Copy link
Collaborator

kant2002 commented Oct 8, 2022

After #302 lands we can model if/for/switch/while as goto statements. Also it slightly interferes with this PR in label parser area. I actually borrow code from this PR for these parts.

kant2002 added a commit to kant2002/Cesium that referenced this pull request Oct 13, 2022
A lot of noise comes from fact that I distiguish between constant literals and constant expressions. We incorrectly name ConstantExpresion the expression which works with constants, but that's more broad concept.
In the spec names are `constant` and `constant-expression` and because we have suffix Expression to all expression we have a clash.

Closes ForNeVeR#74 and superseeds ForNeVeR#139
@kant2002 kant2002 mentioned this pull request Oct 13, 2022
@ForNeVeR
Copy link
Owner

Superseded by #316.

@ForNeVeR ForNeVeR closed this Oct 13, 2022
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.

Compiler: basic switch-case support
3 participants