-
Notifications
You must be signed in to change notification settings - Fork 51
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
Compiling Program Using NetKAT Syntax Extension Throws DynLoader.Error #507
Comments
Maybe it's time to throw out camlp4 and replace it with ppx... |
Personally, I would love to have a way to make small extensions to the NetKAT syntax without writing a new parser every time. For example, I would like to have a "path" operator ( |
@basus: That's not really related. You could do that with the current architecture by modifying the lexer and parser appropriately. |
Ok, I figured out how to get rid of camlp4, replace it with ppx, and make the whole lexing/parsing pipeline simpler and easier to extend. It's probably best to do this after #512 has been merged in. |
@smolkaj does the fix you mentioned here still work? What's involved? I'd like to fix issue #526. The main culprit is that Ideally we'd port the tutorial examples to PPX and then fix the build script. -N |
ps. I'm happy to do the legwork if you explain what you meant in the comment above. |
Yes, we should do this! Here is what I had in mind: Syntax
We may also want to support expressions:
ppx-extensionShould be easy following this blog post (just a "context-free extension expander"). However, we will need a parser of type ParserWe need to replace the Camlp4 parser. I suggest Menhir. Note that we actually need two parsers:
Since the parsers are identical up to semantic actions, it would be a shame to have two separate implementations, as we did in the past. I propose to have two semantic actions for each parse rule, and use CPPO to to produce two parsers from this one specification. I have a prototype of this at home, and it is quite clean. Let me post it here tonight. How to build OCaml ASTs conveniently: LexerI think we need to replace the lexer as well? Not sure what's the best option here. Here is an example of how to make menhir work with ulex. Looks pretty straight-forward: https://github.com/Drup/llvm/blob/3c43000f4e86af5b9b368f50721604957d403750/test/Bindings/OCaml/kaleidoscope/src/syntax.ml Plan of AttackI would implement things top-down in the order of my description: first the ppx-extension (with a dummy parser), than the parser, than the lexer. |
@jnfoster: I will create a new branch tonight and push what I have. |
Wonderful! I like the PPX design. -N On Thu, Nov 3, 2016 at 11:57 AM, Steffen Smolka notifications@github.com
|
Cool, let's push on this. Shouldn't be too much work. I just pushed a draft of the parser: https://github.com/frenetic-lang/frenetic/tree/ppx I'll try to hack up a skeleton of the ppx extension. We also need a lexer. |
Ok, the ppx extension works! This was surprisingly difficult, because things are very poorly documented. For future reference, this is where the OCaml AST definitions can be found: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Parsetree.html#TYPEexpression I only implemented |
(We still need to finish the parser and implement the lexer.) |
This problem has been solved with #527. @basus: We also have a new parser and a new lexer. Extending them for experimentation should be really easy. The relevant files to look at are https://github.com/frenetic-lang/frenetic/blob/master/lib/Parser.cppo.mly and https://github.com/frenetic-lang/frenetic/blob/master/lib/Frenetic_NetKAT_Lexer.ml. |
Compiling the sample program on the NetKAT Wiki page:
yields:
Previously we fixed this by writing a script that runs camlp4 with the
threads.cma
library explicitly listed before Core. This no longer works, probably since Core tossed out camlp4 compatibility in 113.24, and was hacky anyway.The text was updated successfully, but these errors were encountered: