Comments (3)
Ideally, the jbuild
-file should look like this
(jbuild_version 1)
;; generate menhir tokens
(rule
((targets (Tokens.ml))
(deps (Menhir_parser.mly))
(action (run ${bin:menhir} --only-tokens ${<} --base Tokens))))
;; generate parser
(menhir
((modules (Menhir_parser))
(flags (--external-tokens Lexer))))
(library
((name ocaml_parsing)
(public_name ocaml_parsing)
(wrapped true)
(libraries
(core
sedlex
compiler-libs.common
menhirLib)
)
(virtual_deps (cppo menhir))
(preprocess (pps
(ppx_deriving.std
ppx_enumerate
ppx_sedlex ;; include sedlex here
ppx_import ;; use ppx_import instead of cppo
)
))
)
)
and Lexer.cppo.sedlex.ml
should become simply Lexer.ml
and start like this:
type token = [%import: Tokens.token] [@@deriving show, enumerate]
...
Unfortunately, both ppx_sedlex
and ppx_import
are currently not directly compatible with jbuilder
. As a workaround, I invoke ppx_sedlex
manually and I use cppo
, again by invoking it manually, instead of ppx_import
.
While ppx_sedlex
will become compatible with jbuilder
soon (ocaml-community/sedlex#57), ppx_import
will likely never become compatible. The right thing to do here is probably to ask Francois Pottier (the menhir author) to provide a Tokens.to_string
function, so we don't have to derive it through this hack
from nice-parser.
This is a really great write-up and response! I'm happy I understand the constraints, now.
As I'm sure you're more experienced than me — can you think of an alternative workaround, that allows Merlin to function? I was thinking of trying to use Jbuilder's “promotion” features, maybe? I suspect we could come up with a structure wherein the Tokens
module is actually inlined into the file while editing it, and then automatically updated/replaced …
from nice-parser.
Sorry, but I don't use Merlin myself, so I am not sure what to do. I suppose it's best to wait for a new release of Menhir that allows us to get rid of this hack ;)
from nice-parser.
Related Issues (8)
- Having some trouble building... HOT 7
- No package named nice_parser HOT 2
- Why the usage of `cppo`? HOT 5
- 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.