Skip to content

Commit

Permalink
fix forwarding tail-binding anonymous monadic expressions parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
ISANobody committed Aug 19, 2015
1 parent 6a6e9f7 commit 3c398f9
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 247 deletions.
2 changes: 1 addition & 1 deletion _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Maintainers: Dennis Griffith <isanobody@gmail.com>
License: GPL-3 with OCaml linking exception
OCamlVersion: >= 4.0
Plugins: StdFiles (0.3), DevFiles (0.3), META (0.3)
BuildDepends: unix, threads, core, sexplib, bin_prot, sexplib.syntax, bin_prot.syntax,
BuildDepends: unix, threads, core, sexplib, bin_prot, sexplib, sexplib.syntax, bin_prot.syntax,
monad-custom, mparser, mparser.re
BuildTools: ocamlbuild, camlp4, camlp4o

Expand Down
23 changes: 12 additions & 11 deletions _tags
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# OASIS_START
# DO NOT EDIT (digest: d695d5b4b387816b01ebcc0210658b58)
# DO NOT EDIT (digest: ab24c69488f3dc259841d80ffceaecb7)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
true: annot, bin_annot
<**/.svn>: -traverse
<**/.svn>: not_hygienic
".bzr": -traverse
Expand Down Expand Up @@ -35,15 +36,15 @@
"sshstub.byte": package(sexplib.syntax)
"sshstub.byte": package(threads)
"sshstub.byte": package(unix)
<*.ml{,i}>: package(bin_prot)
<*.ml{,i}>: package(bin_prot.syntax)
<*.ml{,i}>: package(core)
<*.ml{,i}>: package(monad-custom)
<*.ml{,i}>: package(mparser)
<*.ml{,i}>: package(mparser.re)
<*.ml{,i}>: package(sexplib)
<*.ml{,i}>: package(sexplib.syntax)
<*.ml{,i}>: package(threads)
<*.ml{,i}>: package(unix)
<*.ml{,i,y}>: package(bin_prot)
<*.ml{,i,y}>: package(bin_prot.syntax)
<*.ml{,i,y}>: package(core)
<*.ml{,i,y}>: package(monad-custom)
<*.ml{,i,y}>: package(mparser)
<*.ml{,i,y}>: package(mparser.re)
<*.ml{,i,y}>: package(sexplib)
<*.ml{,i,y}>: package(sexplib.syntax)
<*.ml{,i,y}>: package(threads)
<*.ml{,i,y}>: package(unix)
# OASIS_STOP
<*.ml>: syntax_camlp4o
118 changes: 66 additions & 52 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: 3d65ca90fc4edebe06b7b35a55ef91fc) *)
(* DO NOT EDIT (digest: 2b686a81cec9fb16d1640bda36a68fbd) *)
module OASISGettext = struct
(* # 22 "/Users/dgriffi3/.opam/system/build/oasis.0.4.4/src/oasis/OASISGettext.ml" *)
(* # 22 "src/oasis/OASISGettext.ml" *)


let ns_ str =
Expand Down Expand Up @@ -30,7 +30,7 @@ module OASISGettext = struct
end

module OASISExpr = struct
(* # 22 "/Users/dgriffi3/.opam/system/build/oasis.0.4.4/src/oasis/OASISExpr.ml" *)
(* # 22 "src/oasis/OASISExpr.ml" *)



Expand All @@ -39,10 +39,10 @@ module OASISExpr = struct
open OASISGettext


type test = string
type test = string


type flag = string
type flag = string


type t =
Expand All @@ -52,10 +52,10 @@ module OASISExpr = struct
| EOr of t * t
| EFlag of flag
| ETest of test * string



type 'a choices = (t * 'a) list

type 'a choices = (t * 'a) list


let eval var_get t =
Expand Down Expand Up @@ -131,7 +131,7 @@ end

# 132 "myocamlbuild.ml"
module BaseEnvLight = struct
(* # 22 "/Users/dgriffi3/.opam/system/build/oasis.0.4.4/src/base/BaseEnvLight.ml" *)
(* # 22 "src/base/BaseEnvLight.ml" *)


module MapString = Map.Make(String)
Expand Down Expand Up @@ -236,7 +236,7 @@ end

# 237 "myocamlbuild.ml"
module MyOCamlbuildFindlib = struct
(* # 22 "/Users/dgriffi3/.opam/system/build/oasis.0.4.4/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
(* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)


(** OCamlbuild extension, copied from
Expand All @@ -249,6 +249,9 @@ module MyOCamlbuildFindlib = struct
*)
open Ocamlbuild_plugin

type conf =
{ no_automatic_syntax: bool;
}

(* these functions are not really officially exported *)
let run_and_read =
Expand Down Expand Up @@ -315,7 +318,7 @@ module MyOCamlbuildFindlib = struct

(* This lists all supported packages. *)
let find_packages () =
List.map before_space (split_nl & run_and_read "ocamlfind list")
List.map before_space (split_nl & run_and_read (exec_from_conf "ocamlfind" ^ " list"))


(* Mock to list available syntaxes. *)
Expand All @@ -338,7 +341,7 @@ module MyOCamlbuildFindlib = struct
]


let dispatch =
let dispatch conf =
function
| After_options ->
(* By using Before_options one let command line options have an higher
Expand All @@ -357,31 +360,39 @@ module MyOCamlbuildFindlib = struct
* -linkpkg *)
flag ["ocaml"; "link"; "program"] & A"-linkpkg";

(* For each ocamlfind package one inject the -package option when
* compiling, computing dependencies, generating documentation and
* linking. *)
List.iter
begin fun pkg ->
let base_args = [A"-package"; A pkg] in
(* TODO: consider how to really choose camlp4o or camlp4r. *)
let syn_args = [A"-syntax"; A "camlp4o"] in
let args =
(* Heuristic to identify syntax extensions: whether they end in
".syntax"; some might not.
*)
if Filename.check_suffix pkg "syntax" ||
List.mem pkg well_known_syntax then
syn_args @ base_args
else
base_args
in
flag ["ocaml"; "compile"; "pkg_"^pkg] & S args;
flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
flag ["ocaml"; "doc"; "pkg_"^pkg] & S args;
flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args;
flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;
end
(find_packages ());
if not (conf.no_automatic_syntax) then begin
(* For each ocamlfind package one inject the -package option when
* compiling, computing dependencies, generating documentation and
* linking. *)
List.iter
begin fun pkg ->
let base_args = [A"-package"; A pkg] in
(* TODO: consider how to really choose camlp4o or camlp4r. *)
let syn_args = [A"-syntax"; A "camlp4o"] in
let (args, pargs) =
(* Heuristic to identify syntax extensions: whether they end in
".syntax"; some might not.
*)
if Filename.check_suffix pkg "syntax" ||
List.mem pkg well_known_syntax then
(syn_args @ base_args, syn_args)
else
(base_args, [])
in
flag ["ocaml"; "compile"; "pkg_"^pkg] & S args;
flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
flag ["ocaml"; "doc"; "pkg_"^pkg] & S args;
flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args;
flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;

(* TODO: Check if this is allowed for OCaml < 3.12.1 *)
flag ["ocaml"; "compile"; "package("^pkg^")"] & S pargs;
flag ["ocaml"; "ocamldep"; "package("^pkg^")"] & S pargs;
flag ["ocaml"; "doc"; "package("^pkg^")"] & S pargs;
flag ["ocaml"; "infer_interface"; "package("^pkg^")"] & S pargs;
end
(find_packages ());
end;

(* Like -package but for extensions syntax. Morover -syntax is useless
* when linking. *)
Expand Down Expand Up @@ -415,7 +426,7 @@ module MyOCamlbuildFindlib = struct
end

module MyOCamlbuildBase = struct
(* # 22 "/Users/dgriffi3/.opam/system/build/oasis.0.4.4/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
(* # 22 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)


(** Base functions for writing myocamlbuild.ml
Expand All @@ -430,13 +441,13 @@ module MyOCamlbuildBase = struct
module OC = Ocamlbuild_pack.Ocaml_compiler


type dir = string
type file = string
type name = string
type tag = string
type dir = string
type file = string
type name = string
type tag = string


(* # 62 "/Users/dgriffi3/.opam/system/build/oasis.0.4.4/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
(* # 62 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)


type t =
Expand All @@ -448,7 +459,7 @@ module MyOCamlbuildBase = struct
* directory.
*)
includes: (dir * dir list) list;
}
}


let env_filename =
Expand Down Expand Up @@ -546,12 +557,13 @@ module MyOCamlbuildBase = struct

(* When ocaml link something that use the C library, then one
need that file to be up to date.
This holds both for programs and for libraries.
*)
dep ["link"; "ocaml"; "program"; tag_libstubs lib]
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
dep ["link"; "ocaml"; tag_libstubs lib]
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];

dep ["compile"; "ocaml"; "program"; tag_libstubs lib]
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
dep ["compile"; "ocaml"; tag_libstubs lib]
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];

(* TODO: be more specific about what depends on headers *)
(* Depends on .h files *)
Expand Down Expand Up @@ -580,25 +592,27 @@ module MyOCamlbuildBase = struct
()


let dispatch_default t =
let dispatch_default conf t =
dispatch_combine
[
dispatch t;
MyOCamlbuildFindlib.dispatch;
MyOCamlbuildFindlib.dispatch conf;
]


end


# 594 "myocamlbuild.ml"
# 606 "myocamlbuild.ml"
open Ocamlbuild_plugin;;
let package_default =
{MyOCamlbuildBase.lib_ocaml = []; lib_c = []; flags = []; includes = []}
;;

let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}

let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;

# 603 "myocamlbuild.ml"
# 617 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;
14 changes: 7 additions & 7 deletions newparser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1023,13 +1023,7 @@ and proc_inst_ : ((proc option -> proc),'s) MParser.t Lazy.t = lazy(
| None -> errr sloc "Cannot end a process with an internal choice")))
<|>
(perform
c2 <-- subchan;
return (function
| None -> Fwd (sloc,c1,c2)
| Some cont -> errr (locP cont) "Forwarding must end its process"))
<|>
(perform
e <-- Lazy.force exp_;
e <-- attempt (Lazy.force exp_);
(perform
skip_symbol "-<";
cs <-- many anychan;
Expand All @@ -1041,6 +1035,12 @@ and proc_inst_ : ((proc option -> proc),'s) MParser.t Lazy.t = lazy(
| Some cont -> Bind (sloc,c1,e,[],cont)
| None -> TailBind (sloc,c1,e,[]))))
<|>
(perform
c2 <-- subchan;
return (function
| None -> Fwd (sloc,c1,c2)
| Some cont -> errr (locP cont) "Forwarding must end its process"))
<|>
(perform
skip_symbol "send";
c2 <-- anychan;
Expand Down
Loading

0 comments on commit 3c398f9

Please sign in to comment.