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