Skip to content

Commit f43085f

Browse files
authored
[interpreter] Renamings in README to match spec (#701)
1 parent 695f1bb commit f43085f

2 files changed

Lines changed: 67 additions & 68 deletions

File tree

‎interpreter/README.md‎

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ string: "(<char> | \n | \t | \\ | \' | \" | \<hex><hex> | \u{<hex>+})*"
175175
value: <int> | <float>
176176
var: <nat> | <name>
177177
178-
type: i32 | i64 | f32 | f64
179-
elem_type: anyfunc
180-
181178
unop: ctz | clz | popcnt | ...
182179
binop: add | sub | mul | ...
183180
relop: eq | ne | lt | ...
@@ -186,27 +183,29 @@ offset: offset=<nat>
186183
align: align=(1|2|4|8|...)
187184
cvtop: trunc_s | trunc_u | extend_s | extend_u | ...
188185
189-
block_sig : ( result <type>* )*
190-
func_sig: ( type <var> )? <param>* <result>*
191-
global_sig: <type> | ( mut <type> )
192-
table_sig: <nat> <nat>? <elem_type>
193-
memory_sig: <nat> <nat>?
186+
val_type: i32 | i64 | f32 | f64
187+
elem_type: anyfunc
188+
block_type : ( result <val_type>* )*
189+
func_type: ( type <var> )? <param>* <result>*
190+
global_type: <val_type> | ( mut <val_type> )
191+
table_type: <nat> <nat>? <elem_type>
192+
memory_type: <nat> <nat>?
194193
195194
expr:
196195
( <op> )
197-
( <op> <expr>+ ) ;; = <expr>+ (<op>)
198-
( block <name>? <block_sig> <instr>* )
199-
( loop <name>? <block_sig> <instr>* )
200-
( if <name>? <block_sig> ( then <instr>* ) ( else <instr>* )? )
201-
( if <name>? <block_sig> <expr>+ ( then <instr>* ) ( else <instr>* )? ) ;; = <expr>+ (if <name>? <block_sig> (then <instr>*) (else <instr>*)?)
196+
( <op> <expr>+ ) ;; = <expr>+ (<op>)
197+
( block <name>? <block_type> <instr>* )
198+
( loop <name>? <block_type> <instr>* )
199+
( if <name>? <block_type> ( then <instr>* ) ( else <instr>* )? )
200+
( if <name>? <block_tyoe> <expr>+ ( then <instr>* ) ( else <instr>* )? ) ;; = <expr>+ (if <name>? <block_type> (then <instr>*) (else <instr>*)?)
202201
203202
instr:
204203
<expr>
205-
<op> ;; = (<op>)
206-
block <name>? <block_sig> <instr>* end <name>? ;; = (block <name>? <block_sig> <instr>*)
207-
loop <name>? <block_sig> <instr>* end <name>? ;; = (loop <name>? <block_sig> <instr>*)
208-
if <name>? <block_sig> <instr>* end <name>? ;; = (if <name>? <block_sig> (then <instr>*))
209-
if <name>? <block_sig> <instr>* else <name>? <instr>* end <name>? ;; = (if <name>? <block_sig> (then <instr>*) (else <instr>*))
204+
<op> ;; = (<op>)
205+
block <name>? <block_type> <instr>* end <name>? ;; = (block <name>? <block_type> <instr>*)
206+
loop <name>? <block_type> <instr>* end <name>? ;; = (loop <name>? <block_type> <instr>*)
207+
if <name>? <block_type> <instr>* end <name>? ;; = (if <name>? <block_type> (then <instr>*))
208+
if <name>? <block_type> <instr>* else <name>? <instr>* end <name>? ;; = (if <name>? <block_type> (then <instr>*) (else <instr>*))
210209
211210
op:
212211
unreachable
@@ -216,57 +215,57 @@ op:
216215
br_table <var>+
217216
return
218217
call <var>
219-
call_indirect <func_sig>
218+
call_indirect <func_type>
220219
drop
221220
select
222221
get_local <var>
223222
set_local <var>
224223
tee_local <var>
225224
get_global <var>
226225
set_global <var>
227-
<type>.load((8|16|32)_<sign>)? <offset>? <align>?
228-
<type>.store(8|16|32)? <offset>? <align>?
226+
<val_type>.load((8|16|32)_<sign>)? <offset>? <align>?
227+
<val_type>.store(8|16|32)? <offset>? <align>?
229228
current_memory
230229
grow_memory
231-
<type>.const <value>
232-
<type>.<unop>
233-
<type>.<binop>
234-
<type>.<testop>
235-
<type>.<relop>
236-
<type>.<cvtop>/<type>
237-
238-
func: ( func <name>? <func_sig> <local>* <instr>* )
230+
<val_type>.const <value>
231+
<val_type>.<unop>
232+
<val_type>.<binop>
233+
<val_type>.<testop>
234+
<val_type>.<relop>
235+
<val_type>.<cvtop>/<val_type>
236+
237+
func: ( func <name>? <func_type> <local>* <instr>* )
239238
( func <name>? ( export <string> ) <...> ) ;; = (export <string> (func <N>)) (func <name>? <...>)
240-
( func <name>? ( import <string> <string> ) <func_sig>) ;; = (import <name>? <string> <string> (func <func_sig>))
241-
param: ( param <type>* ) | ( param <name> <type> )
242-
result: ( result <type>* )
243-
local: ( local <type>* ) | ( local <name> <type> )
239+
( func <name>? ( import <string> <string> ) <func_type>) ;; = (import <name>? <string> <string> (func <func_type>))
240+
param: ( param <val_type>* ) | ( param <name> <val_type> )
241+
result: ( result <val_type>* )
242+
local: ( local <val_type>* ) | ( local <name> <val_type> )
244243
245-
global: ( global <name>? <global_sig> <instr>* )
244+
global: ( global <name>? <global_type> <instr>* )
246245
( global <name>? ( export <string> ) <...> ) ;; = (export <string> (global <N>)) (global <name>? <...>)
247-
( global <name>? ( import <string> <string> ) <global_sig> ) ;; = (import <name>? <string> <string> (global <global_sig>))
248-
table: ( table <name>? <table_sig> )
246+
( global <name>? ( import <string> <string> ) <global_type> ) ;; = (import <name>? <string> <string> (global <global_type>))
247+
table: ( table <name>? <table_type> )
249248
( table <name>? ( export <string> ) <...> ) ;; = (export <string> (table <N>)) (table <name>? <...>)
250-
( table <name>? ( import <string> <string> ) <table_sig> ) ;; = (import <name>? <string> <string> (table <table_sig>))
249+
( table <name>? ( import <string> <string> ) <table_type> ) ;; = (import <name>? <string> <string> (table <table_type>))
251250
( table <name>? ( export <string> )* <elem_type> ( elem <var>* ) ) ;; = (table <name>? ( export <string> )* <size> <size> <elem_type>) (elem (i32.const 0) <var>*)
252251
elem: ( elem <var>? (offset <instr>* ) <var>* )
253252
( elem <var>? <expr> <var>* ) ;; = (elem <var>? (offset <expr>) <var>*)
254-
memory: ( memory <name>? <memory_sig> )
253+
memory: ( memory <name>? <memory_type> )
255254
( memory <name>? ( export <string> ) <...> ) ;; = (export <string> (memory <N>))+ (memory <name>? <...>)
256-
( memory <name>? ( import <string> <string> ) <memory_sig> ) ;; = (import <name>? <string> <string> (memory <memory_sig>))
255+
( memory <name>? ( import <string> <string> ) <memory_type> ) ;; = (import <name>? <string> <string> (memory <memory_type>))
257256
( memory <name>? ( export <string> )* ( data <string>* ) ;; = (memory <name>? ( export <string> )* <size> <size>) (data (i32.const 0) <string>*)
258257
data: ( data <var>? ( offset <instr>* ) <string>* )
259258
( data <var>? <expr> <string>* ) ;; = (data <var>? (offset <expr>) <string>*)
260259
261260
start: ( start <var> )
262261
263-
typedef: ( type <name>? ( func <func_sig> ) )
262+
typedef: ( type <name>? ( func <param>* <result>* ) )
264263
265264
import: ( import <string> <string> <imkind> )
266-
imkind: ( func <name>? <func_sig> )
267-
( global <name>? <global_sig> )
268-
( table <name>? <table_sig> )
269-
( memory <name>? <memory_sig> )
265+
imkind: ( func <name>? <func_type> )
266+
( global <name>? <global_type> )
267+
( table <name>? <table_type> )
268+
( memory <name>? <memory_type> )
270269
export: ( export <string> <exkind> )
271270
exkind: ( func <var> )
272271
( global <var> )

‎interpreter/text/parser.mly‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -211,25 +211,25 @@ global_type :
211211
| VALUE_TYPE { GlobalType ($1, Immutable) }
212212
| LPAR MUT VALUE_TYPE RPAR { GlobalType ($3, Mutable) }
213213

214-
func_type :
215-
| LPAR FUNC func_sig RPAR { $3 }
214+
def_type :
215+
| LPAR FUNC func_type RPAR { $3 }
216216

217-
func_sig :
217+
func_type :
218218
| /* empty */
219219
{ FuncType ([], []) }
220-
| LPAR RESULT value_type_list RPAR func_sig
220+
| LPAR RESULT value_type_list RPAR func_type
221221
{ let FuncType (ins, out) = $5 in
222222
if ins <> [] then error (at ()) "result before parameter";
223223
FuncType (ins, $3 @ out) }
224-
| LPAR PARAM value_type_list RPAR func_sig
224+
| LPAR PARAM value_type_list RPAR func_type
225225
{ let FuncType (ins, out) = $5 in FuncType ($3 @ ins, out) }
226-
| LPAR PARAM bind_var VALUE_TYPE RPAR func_sig /* Sugar */
226+
| LPAR PARAM bind_var VALUE_TYPE RPAR func_type /* Sugar */
227227
{ let FuncType (ins, out) = $6 in FuncType ($4 :: ins, out) }
228228

229-
table_sig :
229+
table_type :
230230
| limits elem_type { TableType ($1, $2) }
231231

232-
memory_sig :
232+
memory_type :
233233
| limits { MemoryType $1 }
234234

235235
limits :
@@ -327,11 +327,11 @@ plain_instr :
327327
| CONVERT { fun c -> $1 }
328328
329329
call_instr :
330-
| CALL_INDIRECT call_instr_sig
330+
| CALL_INDIRECT call_instr_type
331331
{ let at1 = ati 1 in
332332
fun c -> let x, es = $2 c in call_indirect x @@ at1, es }
333333
334-
call_instr_sig :
334+
call_instr_type :
335335
| type_use call_instr_params
336336
{ let at1 = ati 1 in
337337
fun c ->
@@ -366,11 +366,11 @@ block_instr :
366366
{ fun c -> let c' = $2 c ($5 @ $8) in
367367
let ts, es1 = $3 c' in if_ ts es1 ($6 c') }
368368
369-
block_sig :
369+
block_type :
370370
| LPAR RESULT VALUE_TYPE RPAR { [$3] }
371371
372372
block :
373-
| block_sig instr_list
373+
| block_type instr_list
374374
{ fun c -> $1, $2 c }
375375
| instr_list { fun c -> [], $1 c }
376376
@@ -380,7 +380,7 @@ expr : /* Sugar */
380380
381381
expr1 : /* Sugar */
382382
| plain_instr expr_list { fun c -> $2 c, $1 c }
383-
| CALL_INDIRECT call_expr_sig
383+
| CALL_INDIRECT call_expr_type
384384
{ fun c -> let x, es = $2 c in es, call_indirect x }
385385
| BLOCK labeling_opt block
386386
{ fun c -> let c' = $2 c [] in let ts, es = $3 c' in [], block ts es }
@@ -390,7 +390,7 @@ expr1 : /* Sugar */
390390
{ fun c -> let c' = $2 c [] in
391391
let ts, (es, es1, es2) = $3 c c' in es, if_ ts es1 es2 }
392392
393-
call_expr_sig :
393+
call_expr_type :
394394
| type_use call_expr_params
395395
{ let at1 = ati 1 in
396396
fun c ->
@@ -416,7 +416,7 @@ call_expr_results :
416416
417417
418418
if_block :
419-
| block_sig if_block { fun c c' -> let ts, ess = $2 c c' in $1 @ ts, ess }
419+
| block_type if_block { fun c c' -> let ts, ess = $2 c c' in $1 @ ts, ess }
420420
| if_ { fun c c' -> [], $1 c c' }
421421
422422
if_ :
@@ -534,9 +534,9 @@ table :
534534
fun () -> $4 c x at }
535535
536536
table_fields :
537-
| table_sig
537+
| table_type
538538
{ fun c x at -> [{ttype = $1} @@ at], [], [], [] }
539-
| inline_import table_sig
539+
| inline_import table_type /* Sugar */
540540
{ fun c x at ->
541541
[], [],
542542
[{ module_name = fst $1; item_name = snd $1;
@@ -566,9 +566,9 @@ memory :
566566
fun () -> $4 c x at }
567567
568568
memory_fields :
569-
| memory_sig
569+
| memory_type
570570
{ fun c x at -> [{mtype = $1} @@ at], [], [], [] }
571-
| inline_import memory_sig
571+
| inline_import memory_type /* Sugar */
572572
{ fun c x at ->
573573
[], [],
574574
[{ module_name = fst $1; item_name = snd $1;
@@ -593,7 +593,7 @@ global :
593593
global_fields :
594594
| global_type const_expr
595595
{ fun c x at -> [{gtype = $1; value = $2 c} @@ at], [], [] }
596-
| inline_import global_type
596+
| inline_import global_type /* Sugar */
597597
{ fun c x at ->
598598
[],
599599
[{ module_name = fst $1; item_name = snd $1;
@@ -609,14 +609,14 @@ import_desc :
609609
| LPAR FUNC bind_var_opt type_use RPAR
610610
{ fun c -> ignore ($3 c anon_func bind_func);
611611
fun () -> FuncImport ($4 c type_) }
612-
| LPAR FUNC bind_var_opt func_sig RPAR /* Sugar */
612+
| LPAR FUNC bind_var_opt func_type RPAR /* Sugar */
613613
{ let at4 = ati 4 in
614614
fun c -> ignore ($3 c anon_func bind_func);
615615
fun () -> FuncImport (inline_type c $4 at4) }
616-
| LPAR TABLE bind_var_opt table_sig RPAR
616+
| LPAR TABLE bind_var_opt table_type RPAR
617617
{ fun c -> ignore ($3 c anon_table bind_table);
618618
fun () -> TableImport $4 }
619-
| LPAR MEMORY bind_var_opt memory_sig RPAR
619+
| LPAR MEMORY bind_var_opt memory_type RPAR
620620
{ fun c -> ignore ($3 c anon_memory bind_memory);
621621
fun () -> MemoryImport $4 }
622622
| LPAR GLOBAL bind_var_opt global_type RPAR
@@ -651,7 +651,7 @@ inline_export :
651651
/* Modules */
652652
653653
type_ :
654-
| func_type { $1 @@ at () }
654+
| def_type { $1 @@ at () }
655655
656656
type_def :
657657
| LPAR TYPE type_ RPAR

0 commit comments

Comments
 (0)