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 "match" control flow structure #6

Open
6 tasks
alexdovzhanyn opened this issue Jun 30, 2024 · 0 comments
Open
6 tasks

Implement "match" control flow structure #6

alexdovzhanyn opened this issue Jun 30, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@alexdovzhanyn
Copy link
Collaborator

alexdovzhanyn commented Jun 30, 2024

Add a pattern matching control flow structure, as shown below:

match (variable) {
  when :ok >> something()
  when :error >> something_else()
  default >> some_default_thing()
}
  • Update the lexer to recognize match, when, default, and >> as language keywords and operators, respectively.
  • Update the parser to recognize the match statement.
  • Modify the AST to accommodate the match statement and its branches. This can be modeled with the ControlFlowNode, though it may need to be modified to add flexibility.
  • Implement the necessary changes in the type checker and code generator.
  • Ensure that match can handle various patterns and data types.
  • Ensure that typechecking is honored during the pattern match
@alexdovzhanyn alexdovzhanyn added enhancement New feature or request good first issue Good for newcomers labels Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant