-
Notifications
You must be signed in to change notification settings - Fork 57
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
Naive compilation of complex pattern matches with match-expressions to decision trees with case-expressions #1531
Labels
Milestone
Comments
lukaszcz
added
enhancement
New feature or request
pending-review
pattern-matching
core
Related to JuvixCore
labels
Sep 13, 2022
Merged
lukaszcz
added a commit
that referenced
this issue
Jan 9, 2023
An implementation of the translation from JuvixCore to JuvixAsm. After merging this PR, the only remaining step to complete the basic compilation pipeline (#1556) is the compilation of complex pattern matching (#1531). * Fixes several bugs in lambda-lifting. * Fixes several bugs in the RemoveTypeArgs transformation. * Fixes several bugs in the TopEtaExpand transformation. * Adds the ConvertBuiltinTypes transformation which converts the builtin bool inductive type to Core primitive bool. * Adds the `juvix dev core strip` command. * Adds the `juvix dev core asm` command. * Adds the `juvix dev core compile` command. * Adds two groups of tests: - JuvixCore to JuvixAsm translation: translate JuvixCore tests to JuvixAsm and run the results with the JuvixAsm interpreter, - JuvixCore compilation: compile JuvixCore tests to native code and WASM and execute the results. * Closes #1520 * Closes #1549
paulcadman
added a commit
that referenced
this issue
Feb 1, 2023
Core transformations apply to the whole InfoTable, the REPL needs to apply Core transformations to the single node that it compiles from the user input string. The solution in this commit is to: 1. Compile the input string as before to obtain a Core Node. 2. Add this Node to a copy of the Core InfoTable for the loaded file. 3. Apply the (CLI specified) Core transformations to this InfoTable. 4. Extract the (now transformed) Node from the InfoTable. We can think of a way to improve this, maybe when we tackle allowing the user to make new definitions in the REPL. As soon as compilation of pattern matching is complete we should enable some (all?) Core transformations by default. Example: At the moment we get the following result in the REPL: ``` juvix repl ... Stdlib.Prelude> 1 + 1 suc (suc zero) ``` After this commit we can turn on `nat-to-int` transformation: ``` juvix repl -t nat-to-int Stdlib.Prelude> 1 + 1 2 ``` * Part of #1531
lukaszcz
changed the title
Compile complex pattern matching with match-expressions to decision trees with case-expressions
Naive compilation of complex pattern matches with match-expressions to decision trees with case-expressions
Feb 1, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should be implemented as a transformation on the core which compiles the 'Match' nodes into multiple 'Case' nodes. At first, we may implement an inefficient naive algorithm. A more efficient version will be implemented later (issue #1798).
The text was updated successfully, but these errors were encountered: