-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from dinosaure/protobuf
Protobuf [WIP]
- Loading branch information
Showing
12 changed files
with
472 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_build | ||
_opam* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM ocaml/opam2:alpine-3.7 | ||
|
||
ENV OPAMYES=1 | ||
|
||
RUN opam pin add crowbar --dev -n | ||
RUN opam install opam-depext | ||
RUN opam depext -i jbuilder fmt logs lwt menhir higher ppx_deriving \ | ||
crowbar ocaml-protoc | ||
|
||
COPY . /src | ||
RUN sudo chown -R opam /src | ||
WORKDIR /src | ||
|
||
RUN opam exec -- make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
opam-version: "1.2" | ||
maintainer: "Thomas Gazagnaire <thomas@gazagnaire.org>" | ||
authors: ["Thomas Gazagnaire" "Romain Calascibetta"] | ||
homepage: "https://github.com/samoht/mirage-lambda" | ||
license: "ISC" | ||
dev-repo: "https://github.com/samoht/mirage-lambda.git" | ||
bug-reports: "https://github.com/samoht/mirage-lambda/issues" | ||
|
||
build: [ "jbuilder" "build" "-p" name "-j" jobs ] | ||
depends: [ | ||
"jbuilder" {build} | ||
"ocaml-protoc" | ||
"lambda" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(jbuild_version 1) | ||
|
||
(rule | ||
((targets (lambda_types.ml lambda_types.mli lambda_pb.ml lambda_pb.mli)) | ||
(deps (lambda.proto)) | ||
(action (run ocaml-protoc -binary -ml_out . lambda.proto)))) | ||
|
||
(library | ||
((name lambda_protobuf) | ||
(flags (:standard -w -30)) | ||
(public_name lambda-protobuf) | ||
(libraries (lambda ocaml-protoc)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
syntax = "proto2"; | ||
|
||
message Type { | ||
message Unit { } | ||
message Int { } | ||
message Int32 { } | ||
message Int64 { } | ||
message Bool { } | ||
message String { } | ||
message Lwt { } | ||
message List { | ||
required Type value = 1; | ||
} | ||
message Array { | ||
required Type value = 1; | ||
} | ||
message Option { | ||
required Type value = 1; | ||
} | ||
message Apply { | ||
required Type a = 1; | ||
required Type b = 2; | ||
} | ||
message Arrow { | ||
required Type a = 1; | ||
required Type b = 2; | ||
} | ||
message Pair { | ||
required Type a = 1; | ||
required Type b = 2; | ||
} | ||
message Either { | ||
required Type a = 1; | ||
required Type b = 2; | ||
} | ||
message Result { | ||
required Type a = 1; | ||
required Type b = 2; | ||
} | ||
message Abstract { | ||
required string witness = 1; | ||
} | ||
|
||
oneof t { | ||
Unit unit = 1; | ||
Int int = 2; | ||
Int32 int32 = 3; | ||
Int64 int64 = 4; | ||
Bool bool = 5; | ||
String string = 6; | ||
Lwt lwt = 7; | ||
List list = 8; | ||
Array array = 9; | ||
Option option = 10; | ||
Apply apply = 11; | ||
Arrow arrow = 12; | ||
Pair pair = 13; | ||
Either either = 14; | ||
Result result = 15; | ||
Abstract abstract = 16; | ||
} | ||
} | ||
|
||
message Primitive { | ||
required string name = 1; | ||
repeated Type arguments = 2; | ||
required Type return = 3; | ||
} | ||
|
||
enum Binop { | ||
ADD = 1; | ||
SUB = 2; | ||
MUL = 3; | ||
DIV = 4; | ||
PAIR = 5; | ||
EQ = 6; | ||
} | ||
|
||
message Unop { | ||
message Fst { } | ||
message Snd { } | ||
message L { required Type value = 1; } | ||
message R { required Type value = 1; } | ||
message Ok { required Type value = 1; } | ||
message Error { required Type value = 1; } | ||
|
||
oneof t { | ||
Fst fst = 1; | ||
Snd snd = 2; | ||
L l = 3; | ||
R r = 4; | ||
Ok ok = 5; | ||
Error error = 6; | ||
} | ||
} | ||
|
||
message Value { | ||
message Unit { } | ||
message Int { required int32 value = 1; } | ||
message Int32 { required int32 value = 1; } | ||
message Int64 { required int64 value = 1; } | ||
message Bool { required bool value = 1; } | ||
message String { required string value = 1; } | ||
message List { | ||
required Type typ = 1; | ||
repeated Value value = 2; | ||
} | ||
message Array { | ||
required Type typ = 1; | ||
repeated Value value = 2; | ||
} | ||
message Option { | ||
required Type typ = 1; | ||
optional Value value = 2; | ||
} | ||
message Pair { | ||
required Value a = 1; | ||
required Value b = 2; | ||
} | ||
|
||
oneof t { | ||
Unit unit = 1; | ||
Int int = 2; | ||
Int32 int32 = 3; | ||
Int64 int64 = 4; | ||
Bool bool = 5; | ||
String string = 6; | ||
List list = 7; | ||
Array array = 8; | ||
Option option = 9; | ||
Pair pair = 10; | ||
} | ||
} | ||
|
||
message Expr { | ||
message Val { required Value value = 1; } | ||
message Prm { required Primitive value = 1; } | ||
message Lst { optional Type typ = 1; | ||
repeated Expr expr = 2; } | ||
message Arr { optional Type typ = 1; | ||
repeated Expr expr = 2; } | ||
message Opt { required Type typ = 1; | ||
optional Expr expr = 2; } | ||
message Var { required int32 var = 1; } | ||
message Lam { required Type typ = 1; | ||
required string var = 2; | ||
required Expr expr = 3; } | ||
message Rec { required Type ret = 1; | ||
required string name = 2; | ||
required Type argument = 3; | ||
required Expr expr = 4; } | ||
message App { required Expr a = 1; | ||
required Expr b = 2; } | ||
message Bin { | ||
required Binop op = 1; | ||
required Expr a = 2; | ||
required Expr b = 3; | ||
} | ||
message Uno { | ||
required Unop op = 1; | ||
required Expr x = 2; | ||
} | ||
message Let { | ||
required Type typ = 1; | ||
required string name = 2; | ||
required Expr expr = 3; | ||
required Expr body = 4; | ||
} | ||
message Swt { | ||
required Expr a = 1; | ||
required Expr b = 2; | ||
required Expr s = 3; | ||
} | ||
message If { | ||
required Expr a = 1; | ||
required Expr b = 2; | ||
required Expr s = 3; | ||
} | ||
|
||
oneof t { | ||
Val val = 1; | ||
Prm prm = 2; | ||
Lst lst = 3; | ||
Arr arr = 4; | ||
Opt opt = 5; | ||
Var var = 6; | ||
Lam lam = 7; | ||
Rec rec = 8; | ||
App app = 9; | ||
Bin bin = 10; | ||
Uno uno = 11; | ||
Let let = 12; | ||
Swt swt = 13; | ||
If if = 14; | ||
} | ||
} |
Oops, something went wrong.