frenetic-lang / frenetic

The Frenetic Programming Language and Runtime System
http://www.frenetic-lang.org/
Other
223 stars 51 forks source link

Unbound Fenetic_NetKAT and Frenetic_OpenFlow0x01_Plugin modules #600

Closed ZhijiaCHEN closed 6 years ago

ZhijiaCHEN commented 6 years ago

After updating Frenetic, I am unable to build NetKAT programs written in OCaml. For example, I tried to use this this script to build a simple repeater (example 1 of this page). Then got an error "Error: Unbound module Frenetic_NetKAT". It seems to me that it's due to outdated OCaml import syntax, so I changed "Frenetic_NetKAT" as "Frenetic.Netkat", and it passed. But then it threw out "Error: Unbound module Frenetic_OpenFlow0x01_Plugin". I also tried to build the learning switch in the examples folder, but got similar errors. I guess these errors are due to some syntax inconsistencies, but I just could not find a right way to get through. Could someone give me a hint? Thanks!

ZhijiaCHEN commented 6 years ago

By the way, I also got an error when try to use '$' to reference OCaml variables. Not sure if it has something to do with the the NetKAT module import issue.

frenetic@frenetic-tutorial-vm:~/netkat-tutorial-solutions$ ./netkat-build Repeater2.d.byte
+ ocamlfind ocamldep -package frenetic.ppx -package frenetic.async -package frenetic -package async -package core -modules Repeater2.ml > Repeater2.ml.depends
File "Repeater2.ml", line 13, characters 27-27:
Error: unexpected character in NetKAT expression: '$'
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
jnfoster commented 6 years ago

Hi Zhijia,

There have been two upstream changes to OCaml. It seems some of our code and documentation has not been updated to reflect these changes. Sorry about that.

  1. The new jbuilder system now generates libraries with hierarchical names rather than putting them into one big flat namespace. Generally what used to be Frenetic_NetKAT_Foo is now Frenetic.Netkat.Foo and similarly for other names.

  2. The new PPX framework for metaprogramming uses a different syntax for anti-quotation. So $ shouldn't appear in your code. I believe it's [%expr ...] to inject an OCaml expression. But I'm not a PPX expert...

@smolkaj can you confirm this?

Thanks for the bug reports. We'll get around to fixing these when we can. If you do it and want to send PRs we'd also be glad to review and merge them.

-N

smolkaj commented 6 years ago

Hi @ZhijiaCHEN, The new syntax is described here: https://github.com/frenetic-lang/frenetic/tree/master/src/syntax. You can use OCaml code (including variables) inside of NetKAT using curly braces:

let outport = 1 in
let%nk pol = {|
  (* this is NetKAT code *)
  port := {outport}
|} in
pol
ZhijiaCHEN commented 6 years ago

@jnfoster Thanks for the hint! Finally get the program compiled after putting OpenFlow0x01_Plugin in the Frenetic.Async namespace.

@smolkaj I see that. I should have checked this file earlier. Sorry for the noise.