GithubHelp home page GithubHelp logo

Comments (5)

smolkaj avatar smolkaj commented on June 30, 2024

I need to include the type definition syntactically, not just semantically, so that [@@deriving show, enumerate] will work. The reason is that the deriving mechanism is implemented as a syntax-to-syntax transformation.

from nice-parser.

smolkaj avatar smolkaj commented on June 30, 2024

Just to be clear, this is definitely a hack, as pointed out in #2. Maybe we can convince the menhir author to provide a to_string function, so we don't have to derive it.

from nice-parser.

smolkaj avatar smolkaj commented on June 30, 2024

See https://gitlab.inria.fr/fpottier/menhir/issues/6.

from nice-parser.

ELLIOTTCABLE avatar ELLIOTTCABLE commented on June 30, 2024

Well, pending menhir#6, I have an equally-janky-but-in-a-different-way solution.

This completely discards any external dependencies, instead using jbuilder's promotion functionality and cross-platform pseudo-scripting to merge Tokens.ml into the Lexer module files:

(rule
 ((targets (Lexer.sedlex.ml))
  (deps    (Lexer.sedlex.body.ml Tokens.ml))
  (action  (with-stdout-to Lexer.sedlex.ml
    (progn (cat Tokens.ml)
           (echo "  [@@deriving show, enumerate]")
           (cat Lexer.sedlex.body.ml))))))

It's … not pretty, but it works.

With that in place, I removed the inclusion-headers from the Lexer files (in the source-tree); and if I want to iterate on the Lexer files, and keep the various OCaml tooling (like Merlin) working, then I just add open Tokens at the top of the Lexer file I'm working on: boom, no errors.

Ideally, I'd like to commit open Tokens into the file, and then have that preprocessed out, in favour of the actual source-text inclusion that cppo and/or my jbuilder configuration do, before building — but I couldn't figure out a way to do that, without 1. depending on external tooling (which takes me right back to cppo), or 2. writing a ppx-rewriter to replace an open statement with the verbatim content of the mentioned module (which is a bit beyond my skills).

(I didn't bother to pull-request, because it depends on unpublished jbuilder functionality. cppo is probably a net win, compared to this, if you don't need Merlin.)

Hope this helps somebody! <3

from nice-parser.

smolkaj avatar smolkaj commented on June 30, 2024

Looks like we can use ppx_import to solve this in a cleaner way soon: ocaml-ppx/ppx_import#26

from nice-parser.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.