Series of instructions can now be interleaved with data declarations.
This commit is contained in:
parent
7f617263db
commit
baffeeb6eb
@ -302,7 +302,7 @@ and param_var = {
|
|||||||
|
|
||||||
and block = {
|
and block = {
|
||||||
opening : block_opening;
|
opening : block_opening;
|
||||||
instr : instructions;
|
statements : statements;
|
||||||
terminator : semi option;
|
terminator : semi option;
|
||||||
closing : block_closing
|
closing : block_closing
|
||||||
}
|
}
|
||||||
@ -315,9 +315,18 @@ and block_closing =
|
|||||||
Block of rbrace
|
Block of rbrace
|
||||||
| End of kwd_end
|
| End of kwd_end
|
||||||
|
|
||||||
|
and statements = (statement, semi) nsepseq
|
||||||
|
|
||||||
|
and statement =
|
||||||
|
Instr of instruction
|
||||||
|
| Data of data_decl
|
||||||
|
|
||||||
and local_decl =
|
and local_decl =
|
||||||
LocalLam of lambda_decl
|
LocalLam of lambda_decl
|
||||||
| LocalConst of const_decl reg
|
| LocalData of data_decl
|
||||||
|
|
||||||
|
and data_decl =
|
||||||
|
LocalConst of const_decl reg
|
||||||
| LocalVar of var_decl reg
|
| LocalVar of var_decl reg
|
||||||
|
|
||||||
and var_decl = {
|
and var_decl = {
|
||||||
@ -330,8 +339,6 @@ and var_decl = {
|
|||||||
terminator : semi option
|
terminator : semi option
|
||||||
}
|
}
|
||||||
|
|
||||||
and instructions = (instruction, semi) nsepseq
|
|
||||||
|
|
||||||
and instruction =
|
and instruction =
|
||||||
Single of single_instr
|
Single of single_instr
|
||||||
| Block of block reg
|
| Block of block reg
|
||||||
@ -410,7 +417,7 @@ and conditional = {
|
|||||||
|
|
||||||
and if_clause =
|
and if_clause =
|
||||||
ClauseInstr of instruction
|
ClauseInstr of instruction
|
||||||
| ClauseBlock of (instructions * semi option) braces reg
|
| ClauseBlock of (statements * semi option) braces reg
|
||||||
|
|
||||||
and set_membership = {
|
and set_membership = {
|
||||||
set : expr;
|
set : expr;
|
||||||
@ -789,11 +796,11 @@ let pattern_to_region = function
|
|||||||
| PTuple {region; _} -> region
|
| PTuple {region; _} -> region
|
||||||
|
|
||||||
let local_decl_to_region = function
|
let local_decl_to_region = function
|
||||||
LocalLam FunDecl {region; _}
|
LocalLam FunDecl {region; _}
|
||||||
| LocalLam ProcDecl {region; _}
|
| LocalLam ProcDecl {region; _}
|
||||||
| LocalLam EntryDecl {region; _}
|
| LocalLam EntryDecl {region; _}
|
||||||
| LocalConst {region; _}
|
| LocalData LocalConst {region; _}
|
||||||
| LocalVar {region; _} -> region
|
| LocalData LocalVar {region; _} -> region
|
||||||
|
|
||||||
let lhs_to_region : lhs -> Region.t = function
|
let lhs_to_region : lhs -> Region.t = function
|
||||||
Path path -> path_to_region path
|
Path path -> path_to_region path
|
||||||
@ -1028,9 +1035,9 @@ and print_param_var {value; _} =
|
|||||||
print_type_expr param_type
|
print_type_expr param_type
|
||||||
|
|
||||||
and print_block {value; _} =
|
and print_block {value; _} =
|
||||||
let {opening; instr; terminator; closing} = value in
|
let {opening; statements; terminator; closing} = value in
|
||||||
print_block_opening opening;
|
print_block_opening opening;
|
||||||
print_instructions instr;
|
print_statements statements;
|
||||||
print_terminator terminator;
|
print_terminator terminator;
|
||||||
print_block_closing closing
|
print_block_closing closing
|
||||||
|
|
||||||
@ -1047,9 +1054,12 @@ and print_local_decls sequence =
|
|||||||
List.iter print_local_decl sequence
|
List.iter print_local_decl sequence
|
||||||
|
|
||||||
and print_local_decl = function
|
and print_local_decl = function
|
||||||
LocalLam decl -> print_lambda_decl decl
|
LocalLam decl -> print_lambda_decl decl
|
||||||
| LocalConst decl -> print_const_decl decl
|
| LocalData decl -> print_data_decl decl
|
||||||
| LocalVar decl -> print_var_decl decl
|
|
||||||
|
and print_data_decl = function
|
||||||
|
LocalConst decl -> print_const_decl decl
|
||||||
|
| LocalVar decl -> print_var_decl decl
|
||||||
|
|
||||||
and print_var_decl {value; _} =
|
and print_var_decl {value; _} =
|
||||||
let {kwd_var; name; colon; var_type;
|
let {kwd_var; name; colon; var_type;
|
||||||
@ -1062,12 +1072,16 @@ and print_var_decl {value; _} =
|
|||||||
print_expr init;
|
print_expr init;
|
||||||
print_terminator terminator
|
print_terminator terminator
|
||||||
|
|
||||||
and print_instructions sequence =
|
and print_statements sequence =
|
||||||
print_nsepseq ";" print_instruction sequence
|
print_nsepseq ";" print_statement sequence
|
||||||
|
|
||||||
|
and print_statement = function
|
||||||
|
Instr instr -> print_instruction instr
|
||||||
|
| Data data -> print_data_decl data
|
||||||
|
|
||||||
and print_instruction = function
|
and print_instruction = function
|
||||||
Single instr -> print_single_instr instr
|
Single instr -> print_single_instr instr
|
||||||
| Block block -> print_block block
|
| Block block -> print_block block
|
||||||
|
|
||||||
and print_single_instr = function
|
and print_single_instr = function
|
||||||
Cond {value; _} -> print_conditional value
|
Cond {value; _} -> print_conditional value
|
||||||
@ -1102,10 +1116,10 @@ and print_if_clause = function
|
|||||||
ClauseInstr instr -> print_instruction instr
|
ClauseInstr instr -> print_instruction instr
|
||||||
| ClauseBlock {value; _} ->
|
| ClauseBlock {value; _} ->
|
||||||
let {lbrace; inside; rbrace} = value in
|
let {lbrace; inside; rbrace} = value in
|
||||||
let instr, terminator = inside in
|
let statements, terminator = inside in
|
||||||
print_token lbrace "{";
|
print_token lbrace "{";
|
||||||
print_instructions instr;
|
print_statements statements;
|
||||||
print_terminator terminator;
|
print_terminator terminator;
|
||||||
print_token rbrace "}"
|
print_token rbrace "}"
|
||||||
|
|
||||||
and print_case_instr (node : case_instr) =
|
and print_case_instr (node : case_instr) =
|
||||||
|
@ -286,7 +286,7 @@ and param_var = {
|
|||||||
|
|
||||||
and block = {
|
and block = {
|
||||||
opening : block_opening;
|
opening : block_opening;
|
||||||
instr : instructions;
|
statements : statements;
|
||||||
terminator : semi option;
|
terminator : semi option;
|
||||||
closing : block_closing
|
closing : block_closing
|
||||||
}
|
}
|
||||||
@ -299,9 +299,18 @@ and block_closing =
|
|||||||
Block of rbrace
|
Block of rbrace
|
||||||
| End of kwd_end
|
| End of kwd_end
|
||||||
|
|
||||||
|
and statements = (statement, semi) nsepseq
|
||||||
|
|
||||||
|
and statement =
|
||||||
|
Instr of instruction
|
||||||
|
| Data of data_decl
|
||||||
|
|
||||||
and local_decl =
|
and local_decl =
|
||||||
LocalLam of lambda_decl
|
LocalLam of lambda_decl
|
||||||
| LocalConst of const_decl reg
|
| LocalData of data_decl
|
||||||
|
|
||||||
|
and data_decl =
|
||||||
|
LocalConst of const_decl reg
|
||||||
| LocalVar of var_decl reg
|
| LocalVar of var_decl reg
|
||||||
|
|
||||||
and var_decl = {
|
and var_decl = {
|
||||||
@ -314,8 +323,6 @@ and var_decl = {
|
|||||||
terminator : semi option
|
terminator : semi option
|
||||||
}
|
}
|
||||||
|
|
||||||
and instructions = (instruction, semi) nsepseq
|
|
||||||
|
|
||||||
and instruction =
|
and instruction =
|
||||||
Single of single_instr
|
Single of single_instr
|
||||||
| Block of block reg
|
| Block of block reg
|
||||||
@ -394,7 +401,7 @@ and conditional = {
|
|||||||
|
|
||||||
and if_clause =
|
and if_clause =
|
||||||
ClauseInstr of instruction
|
ClauseInstr of instruction
|
||||||
| ClauseBlock of (instructions * semi option) braces reg
|
| ClauseBlock of (statements * semi option) braces reg
|
||||||
|
|
||||||
and set_membership = {
|
and set_membership = {
|
||||||
set : expr;
|
set : expr;
|
||||||
|
@ -350,34 +350,72 @@ core_param_type:
|
|||||||
in TApp {region; value = $1,$2}}
|
in TApp {region; value = $1,$2}}
|
||||||
|
|
||||||
block:
|
block:
|
||||||
Begin series(instruction,End) {
|
Begin series(statement,End) {
|
||||||
let first, (others, terminator, closing) = $2 in
|
let first, (others, terminator, closing) = $2 in
|
||||||
let region = cover $1 closing
|
let region = cover $1 closing
|
||||||
and value = {
|
and value = {
|
||||||
opening = Begin $1;
|
opening = Begin $1;
|
||||||
instr = first, others;
|
statements = first, others;
|
||||||
terminator;
|
terminator;
|
||||||
closing = End closing}
|
closing = End closing}
|
||||||
in {region; value}
|
in {region; value}
|
||||||
}
|
}
|
||||||
| Block LBRACE series(instruction,RBRACE) {
|
| Block LBRACE series(statement,RBRACE) {
|
||||||
let first, (others, terminator, closing) = $3 in
|
let first, (others, terminator, closing) = $3 in
|
||||||
let region = cover $1 closing
|
let region = cover $1 closing
|
||||||
and value = {
|
and value = {
|
||||||
opening = Block ($1,$2);
|
opening = Block ($1,$2);
|
||||||
instr = first, others;
|
statements = first, others;
|
||||||
terminator;
|
terminator;
|
||||||
closing = Block closing}
|
closing = Block closing}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
statement:
|
||||||
|
instruction { Instr $1 }
|
||||||
|
| open_data_decl { Data $1 }
|
||||||
|
|
||||||
|
open_data_decl:
|
||||||
|
open_const_decl { LocalConst $1 }
|
||||||
|
| open_var_decl { LocalVar $1 }
|
||||||
|
|
||||||
|
open_const_decl:
|
||||||
|
Const unqualified_decl(EQUAL) {
|
||||||
|
let name, colon, const_type, equal, init, stop = $2 in
|
||||||
|
let region = cover $1 stop
|
||||||
|
and value = {
|
||||||
|
kwd_const = $1;
|
||||||
|
name;
|
||||||
|
colon;
|
||||||
|
const_type;
|
||||||
|
equal;
|
||||||
|
init;
|
||||||
|
terminator = None}
|
||||||
|
in {region; value}}
|
||||||
|
|
||||||
|
open_var_decl:
|
||||||
|
Var unqualified_decl(ASS) {
|
||||||
|
let name, colon, var_type, assign, init, stop = $2 in
|
||||||
|
let region = cover $1 stop
|
||||||
|
and value = {
|
||||||
|
kwd_var = $1;
|
||||||
|
name;
|
||||||
|
colon;
|
||||||
|
var_type;
|
||||||
|
assign;
|
||||||
|
init;
|
||||||
|
terminator = None}
|
||||||
|
in {region; value}}
|
||||||
|
|
||||||
local_decl:
|
local_decl:
|
||||||
lambda_decl { LocalLam $1 }
|
lambda_decl { LocalLam $1 }
|
||||||
| const_decl { LocalConst $1 }
|
| data_decl { LocalData $1 }
|
||||||
| var_decl { LocalVar $1 }
|
|
||||||
|
data_decl:
|
||||||
|
const_decl { LocalConst $1 }
|
||||||
|
| var_decl { LocalVar $1 }
|
||||||
|
|
||||||
unqualified_decl(OP):
|
unqualified_decl(OP):
|
||||||
var COLON type_expr OP extended_expr option(SEMI) {
|
var COLON type_expr OP extended_expr {
|
||||||
let init, region =
|
let init, region =
|
||||||
match $5 with
|
match $5 with
|
||||||
`Expr e -> e, expr_to_region e
|
`Expr e -> e, expr_to_region e
|
||||||
@ -399,17 +437,13 @@ unqualified_decl(OP):
|
|||||||
colon = Region.ghost;
|
colon = Region.ghost;
|
||||||
opt_type = $3};
|
opt_type = $3};
|
||||||
rpar = Region.ghost}
|
rpar = Region.ghost}
|
||||||
in EConstr (NoneExpr {region; value}), region in
|
in EConstr (NoneExpr {region; value}), region
|
||||||
let stop = match $6 with
|
in $1, $2, $3, $4, init, region}
|
||||||
Some region -> region
|
|
||||||
| None -> region
|
|
||||||
in $1, $2, $3, $4, init, $6, stop}
|
|
||||||
|
|
||||||
const_decl:
|
const_decl:
|
||||||
Const unqualified_decl(EQUAL) {
|
Const unqualified_decl(EQUAL) SEMI {
|
||||||
let name, colon, const_type, equal,
|
let name, colon, const_type, equal, init, _ = $2 in
|
||||||
init, terminator, stop = $2 in
|
let region = cover $1 $3
|
||||||
let region = cover $1 stop
|
|
||||||
and value = {
|
and value = {
|
||||||
kwd_const = $1;
|
kwd_const = $1;
|
||||||
name;
|
name;
|
||||||
@ -417,14 +451,15 @@ const_decl:
|
|||||||
const_type;
|
const_type;
|
||||||
equal;
|
equal;
|
||||||
init;
|
init;
|
||||||
terminator}
|
terminator = Some $3}
|
||||||
in {region; value}}
|
in {region; value}
|
||||||
|
}
|
||||||
|
| open_const_decl { $1 }
|
||||||
|
|
||||||
var_decl:
|
var_decl:
|
||||||
Var unqualified_decl(ASS) {
|
Var unqualified_decl(ASS) SEMI {
|
||||||
let name, colon, var_type, assign,
|
let name, colon, var_type, assign, init, _ = $2 in
|
||||||
init, terminator, stop = $2 in
|
let region = cover $1 $3
|
||||||
let region = cover $1 stop
|
|
||||||
and value = {
|
and value = {
|
||||||
kwd_var = $1;
|
kwd_var = $1;
|
||||||
name;
|
name;
|
||||||
@ -432,8 +467,10 @@ var_decl:
|
|||||||
var_type;
|
var_type;
|
||||||
assign;
|
assign;
|
||||||
init;
|
init;
|
||||||
terminator}
|
terminator = Some $3}
|
||||||
in {region; value}}
|
in {region; value}
|
||||||
|
}
|
||||||
|
| open_var_decl { $1 }
|
||||||
|
|
||||||
extended_expr:
|
extended_expr:
|
||||||
expr { `Expr $1 }
|
expr { `Expr $1 }
|
||||||
@ -625,7 +662,7 @@ if_clause:
|
|||||||
instruction {
|
instruction {
|
||||||
ClauseInstr $1
|
ClauseInstr $1
|
||||||
}
|
}
|
||||||
| LBRACE series(instruction,RBRACE) {
|
| LBRACE series(statement,RBRACE) {
|
||||||
let first, (others, terminator, closing) = $2 in
|
let first, (others, terminator, closing) = $2 in
|
||||||
let region = cover $1 closing in
|
let region = cover $1 closing in
|
||||||
let value = {
|
let value = {
|
||||||
|
Loading…
Reference in New Issue
Block a user