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

Draft: Make Case studies work in JIT #295

Closed
wants to merge 16 commits into from

Conversation

marzipankaiser
Copy link
Contributor

Only for discussion. The case studies are broken for other backends by this, due to stdlib incompatibilities.

@marzipankaiser
Copy link
Contributor Author

marzipankaiser commented Oct 19, 2023

The lexer/parser/anf/pretty case studies now run fine with the newest (few minute old) version of the JIT, with this modified version.

Most notable changes:

  • JIT does not have generic infixEq/println, so the necessary overloads are added inline
  • Use a "Regex" type that only works with the restricted stuff we need here.
  • Some minor changes in how the stdlib works/is used (e.g. don't use mutable arrays)
  • Make all toplevel variables lazy/thunked (since machine does not support them)

cc @b-studios

@marzipankaiser
Copy link
Contributor Author

Problem in ML:
Screenshot 2023-10-19 at 19 23 32

@marzipankaiser
Copy link
Contributor Author

IIUC, this refers to:

def parseCalls(): Int / Parser =
  or { number(); 1 } {
    var count = 1;
    ident();
    punct("(");
    count = count + parseCalls();
    many {
        punct(",");
        count = count + parseCalls()
    };
    punct(")");
    count
  }

@b-studios
Copy link
Collaborator

yes that makes sense, the scope of mutable variable extends over the recursive call. You need to rewrite the example, potentially not using mutable variables

@marzipankaiser
Copy link
Contributor Author

Ah, thanks - I will try to do so. Afterwards (i.e. when commenting out the above), we will still have this:
Screenshot 2023-10-19 at 21 18 23

Is there a way to make mutually recursive definitions for the ML backend?

@marzipankaiser
Copy link
Contributor Author

So, Effekt now compiles it to ML when commenting out the parseExpr calls (that still have a "polymorphic recursion" error in or), but then mlton fails with:

sbt:effekt> run --backend ml examples/casestudies/parser.md
[info] running effekt.Server --backend ml examples/casestudies/parser.md
Error: /Users/gaisseml/dev/effekt/effekt/out/examples_casestudies_parser.sml 630.77-637.17.
  Function applied to incorrect argument.
    expects: [(TokenKind_799, string, (int, int, int) Position_794) Token_805]
             -> _
    but got: [unit] -> _
    in: ((member2of2 (NondetDollarcapabil  ...  58 tok_1228))) k2965
[error] java.lang.RuntimeException: Nonzero exit value: 1

@marzipankaiser marzipankaiser deleted the feature/jit-casestudies branch January 29, 2024 10:18
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.

2 participants