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

Add dictionaries and desugar rules for match #133

Merged
merged 5 commits into from Jun 28, 2019
Merged

Conversation

JSAbrahams
Copy link
Owner

@JSAbrahams JSAbrahams commented Jun 2, 2019

Relevant issues

Resolves #98

Summary

Add desugar rules for match statements.

  • Matches are usually desugared as calls to a dictionary
  • Underscore conditions in a match arm is treated as the default
    • If there are multiple default cases then panic is thrown.
  • For sqrt import math is added to the top of a file if encountered, and for default dictionaries from collections import defaultdict is added.
  • Make Context a mutable reference in the desugar stage so we can modify it, for instance, we can now add imports. We should take care to discard it/refresh the context if need be, though currently there is no such situation where we do not want to propagate up the context.

If default dictionary is used then we add import;
from collections import defaultdict

@JSAbrahams JSAbrahams added enhancement: desugar enhancement: generate New feature in the core module labels Jun 2, 2019
@JSAbrahams JSAbrahams added this to the v0.1.0 milestone Jun 2, 2019
@JSAbrahams JSAbrahams added this to In progress in Implementing Language Features via automation Jun 2, 2019
@JSAbrahams JSAbrahams changed the title Add dictionaries and desugar rules for match WIP Add dictionaries and desugar rules for match Jun 2, 2019
@JSAbrahams JSAbrahams changed the title WIP Add dictionaries and desugar rules for match Add dictionaries and desugar rules for match Jun 28, 2019
@JSAbrahams JSAbrahams merged commit 2ab4641 into master Jun 28, 2019
Implementing Language Features automation moved this from In progress to Done Jun 28, 2019
@JSAbrahams JSAbrahams deleted the desugar-match branch June 28, 2019 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement: generate New feature in the core module
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Add desugaring of match statements (without pattern matching)
1 participant