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

Feature: menhir support in exercises #587

Open
dm0n3y opened this issue Feb 19, 2024 · 0 comments
Open

Feature: menhir support in exercises #587

dm0n3y opened this issue Feb 19, 2024 · 0 comments
Labels
kind: feature New user-facing feature.

Comments

@dm0n3y
Copy link
Contributor

dm0n3y commented Feb 19, 2024

Related user(s):

No response

Related issue(s) or PR(s):

No response

Related project scope(s):

build

The problem:

I'm a TA for an undergraduate programming languages course at the University of Michigan, where students use LearnOCaml to implement various typecheckers and evaluators. To help with test writing, we provide a menhir-generated parser for each assignment's language in the prepare.ml files.

Currently, setting this up involves a slow, tedious feedback loop due to various incidental limitations:

  • I use ocamllex and menhir to generate a parser, typically using a copied form of the language syntax datatype I've defined in the exercise prelude.ml file, which I have to make sure stays synchronized.
  • These tools generate line number directives in their outputs. As far as I can tell, these are not optional (cf this comment in menhir's source), and LearnOCaml does not accept such directives in its exercise files (albeit last I checked was a year or two ago). So first I remove the directives, using a regex find-and-replace.
  • I can't distribute exercise implementations over files other than the recognized ones, so I copy and paste over the generated lexer and parser into submodules of the recognized prepare.ml file. The generated implementations are very large, so this tends to require a lot of scrolling and/or careful code folding, especially when updating an existing large implementation.
  • These large implementations show up again in LearnOCaml's exercise build error messages, necessitating additional scrolling to reach the actual message, and continue to do so beyond parser development.

Wanted solution:

I'd like to be able to write a menhir .mly spec and an ocamllex .mll spec in an exercise directory, referring to definitions in prelude.ml, and the exercise build system will handle generation and scoping so that students can invoke them, without obscuring error messages with the generated output.

Considered alternatives:

No response

Additional context:

No response

@dm0n3y dm0n3y added the kind: feature New user-facing feature. label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: feature New user-facing feature.
Projects
None yet
Development

No branches or pull requests

1 participant