Comments (5)
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.
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.
See https://gitlab.inria.fr/fpottier/menhir/issues/6.
from nice-parser.
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.
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)
- Having some trouble building... HOT 7
- No package named nice_parser HOT 2
- Explanation of “ppx_sedlex and ppx_import are incompatible with jbuilder?” HOT 3
- Please provide ability to compile to js_of_ocaml if possible HOT 3
- Error: Uninterpreted extension 'sedlex.regexp' HOT 4
- Core still listed as a dependency in test/jbuild HOT 1
- How to use with dune HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nice-parser.