Skip to content

Rename Syntax module to Ast #5

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

Merged
merged 1 commit into from
Aug 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ml-proto/src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ parser.mli
*.opt
*.zip
_build

wasm
4 changes: 2 additions & 2 deletions ml-proto/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
NAME = wasm
MODULES = \
flags lib source error \
types values memory syntax \
types values memory ast \
check arithmetic eval print script \
lexer parser \
main
NOMLI = flags types values syntax sexpr main
NOMLI = flags types values ast sexpr main
PARSERS = parser
LEXERS = lexer
LIBRARIES = bigarray
Expand Down
12 changes: 6 additions & 6 deletions ml-proto/src/arithmetic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sig
val float_of_bits : t -> float
end

module IntOp (IntOpSyntax : module type of Syntax.IntOp ()) (Int : INT) =
module IntOp (IntOpSyntax : module type of Ast.IntOp ()) (Int : INT) =
struct
open IntOpSyntax

Expand Down Expand Up @@ -122,8 +122,8 @@ struct
function Int64 i -> i | v -> raise (TypeError (n, v, Int64Type))
end

module Int32Op = IntOp (Syntax.Int32Op) (Int32X)
module Int64Op = IntOp (Syntax.Int64Op) (Int64X)
module Int32Op = IntOp (Ast.Int32Op) (Int32X)
module Int64Op = IntOp (Ast.Int64Op) (Int64X)


(* Float operators *)
Expand All @@ -135,7 +135,7 @@ sig
val to_value : float -> value
end

module FloatOp (FloatOpSyntax : module type of Syntax.FloatOp ())
module FloatOp (FloatOpSyntax : module type of Ast.FloatOp ())
(Float : FLOAT) =
struct
open FloatOpSyntax
Expand Down Expand Up @@ -202,8 +202,8 @@ struct
function Float64 z -> z | v -> raise (TypeError (n, v, Float64Type))
end

module Float32Op = FloatOp (Syntax.Float32Op) (Float32X)
module Float64Op = FloatOp (Syntax.Float64Op) (Float64X)
module Float32Op = FloatOp (Ast.Float32Op) (Float32X)
module Float64Op = FloatOp (Ast.Float64Op) (Float64X)


(* Dispatch *)
Expand Down
8 changes: 4 additions & 4 deletions ml-proto/src/arithmetic.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open Values

exception TypeError of int * value * Types.value_type

val eval_unop : Syntax.unop -> value -> value
val eval_binop : Syntax.binop -> value -> value -> value
val eval_relop : Syntax.relop -> value -> value -> bool
val eval_cvt : Syntax.cvt -> value -> value
val eval_unop : Ast.unop -> value -> value
val eval_binop : Ast.binop -> value -> value -> value
val eval_relop : Ast.relop -> value -> value -> bool
val eval_cvt : Ast.cvt -> value -> value
File renamed without changes.
2 changes: 1 addition & 1 deletion ml-proto/src/check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* (c) 2015 Andreas Rossberg
*)

open Syntax
open Ast
open Source
open Types

Expand Down
2 changes: 1 addition & 1 deletion ml-proto/src/check.mli
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
* (c) 2015 Andreas Rossberg
*)

val check_module : Syntax.modul -> unit (* raise Error *)
val check_module : Ast.modul -> unit (* raise Error *)
6 changes: 3 additions & 3 deletions ml-proto/src/eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*)

open Values
open Syntax
open Ast
open Source

let error = Error.error
Expand All @@ -12,7 +12,7 @@ let error = Error.error
(* Module Instances *)

type value = Values.value
type func = Syntax.func
type func = Ast.func

type module_instance =
{
Expand Down Expand Up @@ -238,7 +238,7 @@ and eval_func m f vs =
(* Modules *)

let init m =
let {Syntax.funcs; exports; tables; globals; memory = (n, _)} = m.it in
let {Ast.funcs; exports; tables; globals; memory = (n, _)} = m.it in
{
funcs = funcs;
exports = List.map (fun x -> List.nth funcs x.it) exports;
Expand Down
4 changes: 2 additions & 2 deletions ml-proto/src/eval.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
type module_instance
type value = Values.value

val init : Syntax.modul -> module_instance
val init : Ast.modul -> module_instance
val invoke : module_instance -> int -> value list -> value list
(* raise Error.Error *)
val eval : module_instance -> Syntax.expr -> value (* raise Error.Error *)
val eval : module_instance -> Ast.expr -> value (* raise Error.Error *)
2 changes: 1 addition & 1 deletion ml-proto/src/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
open Parser
open Syntax
open Ast

let convert_pos pos =
{ Source.file = pos.Lexing.pos_fname;
Expand Down
16 changes: 8 additions & 8 deletions ml-proto/src/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

%{
open Source
open Syntax
open Ast
open Script

let position_to_pos position =
Expand Down Expand Up @@ -50,12 +50,12 @@ let literal at s t =
%token<int> VAR
%token<Types.value_type> TYPE
%token<Types.value_type> CONST
%token<Syntax.unop> UNARY
%token<Syntax.binop> BINARY
%token<Syntax.relop> COMPARE
%token<Syntax.cvt> CONVERT
%token<Syntax.memop> GETMEMORY
%token<Syntax.memop> SETMEMORY
%token<Ast.unop> UNARY
%token<Ast.binop> BINARY
%token<Ast.relop> COMPARE
%token<Ast.cvt> CONVERT
%token<Ast.memop> GETMEMORY
%token<Ast.memop> SETMEMORY

%start script
%type<Script.script> script
Expand Down Expand Up @@ -210,4 +210,4 @@ script :
;

%%


6 changes: 3 additions & 3 deletions ml-proto/src/print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* (c) 2015 Andreas Rossberg
*)

open Syntax
open Ast
open Source
open Printf

Expand All @@ -12,7 +12,7 @@ open Printf
open Types

let func_type f =
let {Syntax.params; results; _} = f.it in
let {Ast.params; results; _} = f.it in
{ins = List.map Source.it params; outs = List.map Source.it results}

let string_of_table_type = function
Expand All @@ -30,7 +30,7 @@ let print_table_sig prefix i t_opt =
printf "%s %d : %s\n" prefix i (string_of_table_type t_opt)


(* Syntax *)
(* Ast *)

let print_func i f =
print_func_sig "func" i f
Expand Down
4 changes: 2 additions & 2 deletions ml-proto/src/print.mli
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* (c) 2015 Andreas Rossberg
*)

val print_module : Syntax.modul -> unit
val print_module_sig : Syntax.modul -> unit
val print_module : Ast.modul -> unit
val print_module_sig : Ast.modul -> unit
val print_values : Values.value list -> unit

4 changes: 2 additions & 2 deletions ml-proto/src/script.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ open Source

type command = command' phrase
and command' =
| Define of Syntax.modul
| Invoke of int * Syntax.expr list
| Define of Ast.modul
| Invoke of int * Ast.expr list

type script = command list

Expand Down
4 changes: 2 additions & 2 deletions ml-proto/src/script.mli
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

type command = command' Source.phrase
and command' =
| Define of Syntax.modul
| Invoke of int * Syntax.expr list
| Define of Ast.modul
| Invoke of int * Ast.expr list

type script = command list

Expand Down