From 9e6bff4741f04509213b78b7b85a17e40a2ba0fb Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Mon, 29 Jul 2019 12:33:02 +0200 Subject: [PATCH] Renamings. Additions. --- .../Doc/{pascaligo1.bnf => pascaligo_01.bnf} | 0 .../Doc/{pascaligo2.bnf => pascaligo_02.bnf} | 0 .../Doc/{pascaligo3.bnf => pascaligo_03.bnf} | 0 .../Doc/{pascaligo4.bnf => pascaligo_04.bnf} | 0 .../Doc/{pascaligo5.bnf => pascaligo_05.bnf} | 0 src/parser/pascaligo/Doc/pascaligo_06.bnf | 390 ++++++++++++++++++ src/parser/pascaligo/Doc/pascaligo_07.bnf | 380 +++++++++++++++++ src/parser/pascaligo/Doc/pascaligo_08.bnf | 382 +++++++++++++++++ src/parser/pascaligo/Doc/pascaligo_09.bnf | 385 +++++++++++++++++ src/parser/pascaligo/Doc/pascaligo_10.bnf | 377 +++++++++++++++++ 10 files changed, 1914 insertions(+) rename src/parser/pascaligo/Doc/{pascaligo1.bnf => pascaligo_01.bnf} (100%) rename src/parser/pascaligo/Doc/{pascaligo2.bnf => pascaligo_02.bnf} (100%) rename src/parser/pascaligo/Doc/{pascaligo3.bnf => pascaligo_03.bnf} (100%) rename src/parser/pascaligo/Doc/{pascaligo4.bnf => pascaligo_04.bnf} (100%) rename src/parser/pascaligo/Doc/{pascaligo5.bnf => pascaligo_05.bnf} (100%) create mode 100644 src/parser/pascaligo/Doc/pascaligo_06.bnf create mode 100644 src/parser/pascaligo/Doc/pascaligo_07.bnf create mode 100644 src/parser/pascaligo/Doc/pascaligo_08.bnf create mode 100644 src/parser/pascaligo/Doc/pascaligo_09.bnf create mode 100644 src/parser/pascaligo/Doc/pascaligo_10.bnf diff --git a/src/parser/pascaligo/Doc/pascaligo1.bnf b/src/parser/pascaligo/Doc/pascaligo_01.bnf similarity index 100% rename from src/parser/pascaligo/Doc/pascaligo1.bnf rename to src/parser/pascaligo/Doc/pascaligo_01.bnf diff --git a/src/parser/pascaligo/Doc/pascaligo2.bnf b/src/parser/pascaligo/Doc/pascaligo_02.bnf similarity index 100% rename from src/parser/pascaligo/Doc/pascaligo2.bnf rename to src/parser/pascaligo/Doc/pascaligo_02.bnf diff --git a/src/parser/pascaligo/Doc/pascaligo3.bnf b/src/parser/pascaligo/Doc/pascaligo_03.bnf similarity index 100% rename from src/parser/pascaligo/Doc/pascaligo3.bnf rename to src/parser/pascaligo/Doc/pascaligo_03.bnf diff --git a/src/parser/pascaligo/Doc/pascaligo4.bnf b/src/parser/pascaligo/Doc/pascaligo_04.bnf similarity index 100% rename from src/parser/pascaligo/Doc/pascaligo4.bnf rename to src/parser/pascaligo/Doc/pascaligo_04.bnf diff --git a/src/parser/pascaligo/Doc/pascaligo5.bnf b/src/parser/pascaligo/Doc/pascaligo_05.bnf similarity index 100% rename from src/parser/pascaligo/Doc/pascaligo5.bnf rename to src/parser/pascaligo/Doc/pascaligo_05.bnf diff --git a/src/parser/pascaligo/Doc/pascaligo_06.bnf b/src/parser/pascaligo/Doc/pascaligo_06.bnf new file mode 100644 index 000000000..0f8007966 --- /dev/null +++ b/src/parser/pascaligo/Doc/pascaligo_06.bnf @@ -0,0 +1,390 @@ +option(X) := + (**) +| X + +series(item,sep,term) ::= + item after_item(item,sep,term) + +after_item(item,sep,term) ::= + sep item_or_closing(item,sep,term) +| term + +item_or_closing(item,sep,term) ::= + term +| series(item,sep,term) + +(* Compound constructs *) + +par(X) ::= LPAR X RPAR + +brackets(X) ::= LBRACKET X RBRACKET + +(* Sequences *) + +(* Possibly empty sequence of items *) + +seq(X) ::= + (**) +| X seq(X) + +(* Non-empty sequence of items *) + +nseq(X) ::= X seq(X) + +(* Non-empty separated sequence of items *) + +nsepseq(X,Sep) ::= + X +| X Sep nsepseq(X,Sep) + +(* Possibly empy separated sequence of items *) + +sepseq(X,Sep) ::= + (**) +| nsepseq(X,Sep) + +(* Main *) + +contract ::= + nseq(declaration) EOF + +declaration ::= + type_decl +| const_decl +| lambda_decl + +(* Type declarations *) + +type_decl ::= + Type Ident (* type_name *) Is type_expr option(SEMI) + +type_expr ::= + cartesian +| sum_type +| record_type + +cartesian ::= + nsepseq(function_type,TIMES) + +function_type ::= + core_type +| core_type ARROW function_type + +core_type ::= + Ident (* type_name *) +| Ident (* type_name *) type_tuple +| Map type_tuple +| Set par(type_expr) +| List par(type_expr) +| par(type_expr) + +type_tuple ::= + par(nsepseq(type_expr,COMMA)) + +sum_type ::= + option(VBAR) nsepseq(variant,VBAR) + +variant ::= + Constr Of cartesian +| Constr + +record_type ::= + Record series(field_decl,SEMI,End) +| Record LBRACKET series(field_decl,SEMI,RBRACKET) + +field_decl ::= + Ident (* field_name *) COLON type_expr + +(* Function and procedure declarations *) + +lambda_decl ::= + fun_decl +| proc_decl +| entry_decl + +fun_decl ::= + Function Ident (* fun_name *) parameters COLON type_expr Is + seq(local_decl) + block + With expr option(SEMI) + +entry_decl ::= + Entrypoint Ident (* fun_name *) entry_params COLON type_expr Is + seq(local_decl) + block + With expr option(SEMI) + +entry_params ::= + par(nsepseq(entry_param_decl,SEMI)) + +proc_decl ::= + Procedure Ident (* fun_name *) parameters Is + seq(local_decl) + block option(SEMI) + +parameters ::= + par(nsepseq(param_decl,SEMI)) + +param_decl ::= + Var Ident (* var *) COLON param_type +| Const Ident (* var *) COLON param_type + +entry_param_decl ::= + param_decl +| Storage Ident (* var *) COLON param_type + +param_type ::= + cartesian + +block ::= + Begin series(statement,SEMI,End) +| Block LBRACE series(statement,SEMI,RBRACE) + +statement ::= + instruction +| open_data_decl + +open_data_decl ::= + open_const_decl +| open_var_decl + +open_const_decl ::= + Const unqualified_decl(EQUAL) + +open_var_decl ::= + Var unqualified_decl(ASS) + +local_decl ::= + fun_decl +| proc_decl +| data_decl + +data_decl ::= + const_decl +| var_decl + +unqualified_decl(op) ::= + Ident (* var *) COLON type_expr op expr + +const_decl ::= + open_const_decl option(SEMI) + +var_decl ::= + open_var_decl option(SEMI) + +instruction ::= + single_instr +| block + +single_instr ::= + If expr Then if_clause option(SEMI) Else if_clause +| case(instruction) +| Ident (* proc_name *) arguments +| Ident option(brackets(expr)) ASS expr +| Ident DOT nsepseq(selection,DOT) option(brackets(expr)) ASS expr +| loop +| Fail expr +| Skip +| Patch path With record_expr +| Patch path With injection(Map,binding) +| Patch path With injection(Set,expr) +| Remove expr From Map path +| Remove expr From Set path + +injection(Kind,element) ::= + Kind series(element,SEMI,End) +| Kind End +| Kind LBRACKET bracketed + +bracketed ::= + series(element,SEMI,RBRACKET) +| RBRACKET + +binding ::= + expr ARROW expr + +if_clause ::= + instruction +| LBRACE series(statement,COMMA,RBRACE) + +case(rhs) ::= + Case expr Of cases(rhs) End +| Case expr Of LBRACKET cases(rhs) RBRACKET + +cases(rhs) ::= + option(VBAR) nsepseq(case_clause(rhs),VBAR) + +case_clause(rhs) ::= + pattern ARROW rhs + +loop ::= + while_loop +| for_loop + +while_loop ::= + While expr block + +for_loop ::= + For Ident ASS expr option(Down) To expr option(step_clause) block +| For Ident option(arrow_clause) In expr block + +step_clause ::= + Step expr + +arrow_clause ::= + ARROW Ident (* var *) + +(* Expressions *) + +interactive_expr ::= + expr EOF + +expr ::= + case(expr) +| annot_expr + +annot_expr ::= + LPAR disj_expr COLON type_expr RPAR +| disj_expr + +disj_expr ::= + disj_expr Or conj_expr +| conj_expr + +conj_expr ::= + conj_expr And set_membership +| set_membership + +set_membership ::= + core_expr Contains set_membership +| comp_expr + +comp_expr ::= + comp_expr LT cat_expr +| comp_expr LEQ cat_expr +| comp_expr GT cat_expr +| comp_expr GEQ cat_expr +| comp_expr EQUAL cat_expr +| comp_expr NEQ cat_expr +| cat_expr + +cat_expr ::= + cons_expr CAT cat_expr +| cons_expr + +cons_expr ::= + add_expr CONS cons_expr +| add_expr + +add_expr ::= + add_expr PLUS mult_expr +| add_expr MINUS mult_expr +| mult_expr + +mult_expr ::= + mult_expr TIMES unary_expr +| mult_expr SLASH unary_expr +| mult_expr Mod unary_expr +| unary_expr + +unary_expr ::= + MINUS core_expr +| Not core_expr +| core_expr + +core_expr ::= + Int +| Nat +| Mtz +| Ident (* var *) +| String +| Bytes +| C_False +| C_True +| C_Unit +| tuple_expr +| list_expr +| C_None +| fun_call +| map_expr +| set_expr +| record_expr +| Ident (* struct_name *) DOT nsepseq(selection,DOT) +| Constr arguments +| Constr +| C_Some arguments + +set_expr ::= + injection(Set,expr) + +map_expr ::= + map_lookup +| injection(Map,binding) + +map_lookup ::= + path brackets(expr) + +path ::= + Ident (* var *) +| Ident (* struct_name *) DOT nsepseq(selection,DOT) + +selection ::= + Ident (* field_name *) +| Int + +record_expr ::= + Record series(field_assignment,SEMI,End) +| Record LBRACKET series(field_assignment,SEMI,RBRACKET) + +field_assignment ::= + Ident (* field_name *) EQUAL expr + +fun_call ::= + Ident (* fun_name *) arguments + +tuple_expr ::= + tuple_inj + +tuple_inj ::= + par(nsepseq(expr,COMMA)) + +arguments ::= + tuple_inj + +list_expr ::= + injection(List,expr) +| Nil + +(* Patterns *) + +pattern ::= + nsepseq(core_pattern,CONS) + +core_pattern ::= + Ident (* var *) +| WILD +| Int +| String +| C_Unit +| C_False +| C_True +| C_None +| list_pattern +| tuple_pattern +| constr_pattern +| C_Some par(core_pattern) + +list_pattern ::= + injection(List,core_pattern) +| Nil +| par(cons_pattern) + +cons_pattern ::= + core_pattern CONS pattern + +tuple_pattern ::= + par(nsepseq(core_pattern,COMMA)) + +constr_pattern ::= + Constr tuple_pattern +| Constr diff --git a/src/parser/pascaligo/Doc/pascaligo_07.bnf b/src/parser/pascaligo/Doc/pascaligo_07.bnf new file mode 100644 index 000000000..7d4b78f1b --- /dev/null +++ b/src/parser/pascaligo/Doc/pascaligo_07.bnf @@ -0,0 +1,380 @@ +option(X) := + (**) +| X + +series(item,sep,term) ::= + item after_item(item,sep,term) + +after_item(item,sep,term) ::= + sep item_or_closing(item,sep,term) +| term + +item_or_closing(item,sep,term) ::= + term +| series(item,sep,term) + +(* Compound constructs *) + +par(X) ::= LPAR X RPAR + +brackets(X) ::= LBRACKET X RBRACKET + +(* Sequences *) + +(* Possibly empty sequence of items *) + +seq(X) ::= + (**) +| X seq(X) + +(* Non-empty sequence of items *) + +nseq(X) ::= X seq(X) + +(* Non-empty separated sequence of items *) + +nsepseq(X,Sep) ::= + X +| X Sep nsepseq(X,Sep) + +(* Possibly empy separated sequence of items *) + +sepseq(X,Sep) ::= + (**) +| nsepseq(X,Sep) + +(* Main *) + +contract ::= + nseq(declaration) EOF + +declaration ::= + type_decl option(SEMI) +| const_decl option(SEMI) +| lambda_decl option(SEMI) + +(* Type declarations *) + +type_decl ::= + Type Ident (* type_name *) Is type_expr + +type_expr ::= + cartesian +| sum_type +| record_type + +cartesian ::= + nsepseq(function_type,TIMES) + +function_type ::= + core_type +| core_type ARROW function_type + +core_type ::= + Ident (* type_name *) +| Ident (* type_name *) type_tuple +| Map type_tuple +| Set par(type_expr) +| List par(type_expr) +| par(type_expr) + +type_tuple ::= + par(nsepseq(type_expr,COMMA)) + +sum_type ::= + option(VBAR) nsepseq(variant,VBAR) + +variant ::= + Constr Of cartesian +| Constr + +record_type ::= + Record series(field_decl,SEMI,End) +| Record LBRACKET series(field_decl,SEMI,RBRACKET) + +field_decl ::= + Ident (* field_name *) COLON type_expr + +(* Function and procedure declarations *) + +lambda_decl ::= + fun_decl +| proc_decl +| entry_decl + +fun_decl ::= + Function Ident (* fun_name *) parameters COLON type_expr Is + seq(local_decl) + block + With expr + +entry_decl ::= + Entrypoint Ident (* fun_name *) entry_params COLON type_expr Is + seq(local_decl) + block + With expr + +entry_params ::= + par(nsepseq(entry_param_decl,SEMI)) + +proc_decl ::= + Procedure Ident (* fun_name *) parameters Is + seq(local_decl) + block + +parameters ::= + par(nsepseq(param_decl,SEMI)) + +param_decl ::= + Var Ident (* var *) COLON param_type +| Const Ident (* var *) COLON param_type + +entry_param_decl ::= + param_decl +| Storage Ident (* var *) COLON param_type + +param_type ::= + cartesian + +block ::= + Begin series(statement,SEMI,End) +| Block LBRACE series(statement,SEMI,RBRACE) + +statement ::= + instruction +| data_decl + +data_decl ::= + const_decl +| var_decl + +const_decl ::= + Const unqualified_decl(EQUAL) + +var_decl ::= + Var unqualified_decl(ASS) + +local_decl ::= + fun_decl option(SEMI) +| proc_decl option(SEMI) +| data_decl option(SEMI) + +unqualified_decl(op) ::= + Ident (* var *) COLON type_expr op expr + +instruction ::= + single_instr +| block + +single_instr ::= + If expr Then if_clause option(SEMI) Else if_clause +| case(instruction) +| Ident (* proc_name *) arguments +| Ident option(brackets(expr)) ASS expr +| Ident DOT nsepseq(selection,DOT) option(brackets(expr)) ASS expr +| loop +| Fail expr +| Skip +| Patch path With record_expr +| Patch path With injection(Map,binding) +| Patch path With injection(Set,expr) +| Remove expr From Map path +| Remove expr From Set path + +injection(Kind,element) ::= + Kind series(element,SEMI,End) +| Kind End +| Kind LBRACKET bracketed + +bracketed ::= + series(element,SEMI,RBRACKET) +| RBRACKET + +binding ::= + expr ARROW expr + +if_clause ::= + instruction +| LBRACE series(statement,COMMA,RBRACE) + +case(rhs) ::= + Case expr Of cases(rhs) End +| Case expr Of LBRACKET cases(rhs) RBRACKET + +cases(rhs) ::= + option(VBAR) nsepseq(case_clause(rhs),VBAR) + +case_clause(rhs) ::= + pattern ARROW rhs + +loop ::= + while_loop +| for_loop + +while_loop ::= + While expr block + +for_loop ::= + For Ident ASS expr option(Down) To expr option(step_clause) block +| For Ident option(arrow_clause) In expr block + +step_clause ::= + Step expr + +arrow_clause ::= + ARROW Ident (* var *) + +(* Expressions *) + +interactive_expr ::= + expr EOF + +expr ::= + case(expr) +| annot_expr + +annot_expr ::= + LPAR disj_expr COLON type_expr RPAR +| disj_expr + +disj_expr ::= + disj_expr Or conj_expr +| conj_expr + +conj_expr ::= + conj_expr And set_membership +| set_membership + +set_membership ::= + core_expr Contains set_membership +| comp_expr + +comp_expr ::= + comp_expr LT cat_expr +| comp_expr LEQ cat_expr +| comp_expr GT cat_expr +| comp_expr GEQ cat_expr +| comp_expr EQUAL cat_expr +| comp_expr NEQ cat_expr +| cat_expr + +cat_expr ::= + cons_expr CAT cat_expr +| cons_expr + +cons_expr ::= + add_expr CONS cons_expr +| add_expr + +add_expr ::= + add_expr PLUS mult_expr +| add_expr MINUS mult_expr +| mult_expr + +mult_expr ::= + mult_expr TIMES unary_expr +| mult_expr SLASH unary_expr +| mult_expr Mod unary_expr +| unary_expr + +unary_expr ::= + MINUS core_expr +| Not core_expr +| core_expr + +core_expr ::= + Int +| Nat +| Mtz +| Ident (* var *) +| String +| Bytes +| C_False +| C_True +| C_Unit +| tuple_expr +| list_expr +| C_None +| fun_call +| map_expr +| set_expr +| record_expr +| Ident (* struct_name *) DOT nsepseq(selection,DOT) +| Constr arguments +| Constr +| C_Some arguments + +set_expr ::= + injection(Set,expr) + +map_expr ::= + map_lookup +| injection(Map,binding) + +map_lookup ::= + path brackets(expr) + +path ::= + Ident (* var *) +| Ident (* struct_name *) DOT nsepseq(selection,DOT) + +selection ::= + Ident (* field_name *) +| Int + +record_expr ::= + Record series(field_assignment,SEMI,End) +| Record LBRACKET series(field_assignment,SEMI,RBRACKET) + +field_assignment ::= + Ident (* field_name *) EQUAL expr + +fun_call ::= + Ident (* fun_name *) arguments + +tuple_expr ::= + tuple_inj + +tuple_inj ::= + par(nsepseq(expr,COMMA)) + +arguments ::= + tuple_inj + +list_expr ::= + injection(List,expr) +| Nil + +(* Patterns *) + +pattern ::= + nsepseq(core_pattern,CONS) + +core_pattern ::= + Ident (* var *) +| WILD +| Int +| String +| C_Unit +| C_False +| C_True +| C_None +| list_pattern +| tuple_pattern +| constr_pattern +| C_Some par(core_pattern) + +list_pattern ::= + injection(List,core_pattern) +| Nil +| par(cons_pattern) + +cons_pattern ::= + core_pattern CONS pattern + +tuple_pattern ::= + par(nsepseq(core_pattern,COMMA)) + +constr_pattern ::= + Constr tuple_pattern +| Constr diff --git a/src/parser/pascaligo/Doc/pascaligo_08.bnf b/src/parser/pascaligo/Doc/pascaligo_08.bnf new file mode 100644 index 000000000..b420288bb --- /dev/null +++ b/src/parser/pascaligo/Doc/pascaligo_08.bnf @@ -0,0 +1,382 @@ +option(X) := + (**) +| X + +series(item,sep,term) ::= + item after_item(item,sep,term) + +after_item(item,sep,term) ::= + sep item_or_closing(item,sep,term) +| term + +item_or_closing(item,sep,term) ::= + term +| series(item,sep,term) + +(* Compound constructs *) + +par(X) ::= LPAR X RPAR + +brackets(X) ::= LBRACKET X RBRACKET + +(* Sequences *) + +(* Possibly empty sequence of items *) + +seq(X) ::= + (**) +| X seq(X) + +(* Non-empty sequence of items *) + +nseq(X) ::= X seq(X) + +(* Non-empty separated sequence of items *) + +nsepseq(X,Sep) ::= + X +| X Sep nsepseq(X,Sep) + +(* Possibly empy separated sequence of items *) + +sepseq(X,Sep) ::= + (**) +| nsepseq(X,Sep) + +(* Main *) + +contract ::= + nseq(declaration) EOF + +declaration ::= + type_decl option(SEMI) +| const_decl option(SEMI) +| lambda_decl option(SEMI) + +(* Type declarations *) + +type_decl ::= + Type Ident (* type_name *) Is type_expr + +type_expr ::= + cartesian +| sum_type +| record_type + +cartesian ::= + nsepseq(function_type,TIMES) + +function_type ::= + core_type +| core_type ARROW function_type + +core_type ::= + Ident (* type_name *) +| Ident (* type_name *) type_tuple +| Map type_tuple +| Set par(type_expr) +| List par(type_expr) +| par(type_expr) + +type_tuple ::= + par(nsepseq(type_expr,COMMA)) + +sum_type ::= + nsepseq(variant,VBAR) +| VBAR nsepseq(variant,VBAR) + +variant ::= + Constr Of cartesian +| Constr + +record_type ::= + Record series(field_decl,SEMI,End) +| Record LBRACKET series(field_decl,SEMI,RBRACKET) + +field_decl ::= + Ident (* field_name *) COLON type_expr + +(* Function and procedure declarations *) + +lambda_decl ::= + fun_decl +| proc_decl +| entry_decl + +fun_decl ::= + Function Ident (* fun_name *) parameters COLON type_expr Is + seq(local_decl) + block + With expr + +entry_decl ::= + Entrypoint Ident (* fun_name *) entry_params COLON type_expr Is + seq(local_decl) + block + With expr + +entry_params ::= + par(nsepseq(entry_param_decl,SEMI)) + +proc_decl ::= + Procedure Ident (* fun_name *) parameters Is + seq(local_decl) + block + +parameters ::= + par(nsepseq(param_decl,SEMI)) + +param_decl ::= + Var Ident (* var *) COLON param_type +| Const Ident (* var *) COLON param_type + +entry_param_decl ::= + param_decl +| Storage Ident (* var *) COLON param_type + +param_type ::= + cartesian + +block ::= + Begin series(statement,SEMI,End) +| Block LBRACE series(statement,SEMI,RBRACE) + +statement ::= + instruction +| data_decl + +data_decl ::= + const_decl +| var_decl + +const_decl ::= + Const unqualified_decl(EQUAL) + +var_decl ::= + Var unqualified_decl(ASS) + +local_decl ::= + fun_decl option(SEMI) +| proc_decl option(SEMI) +| data_decl option(SEMI) + +unqualified_decl(op) ::= + Ident (* var *) COLON type_expr op expr + +instruction ::= + single_instr +| block + +single_instr ::= + If expr Then if_clause option(SEMI) Else if_clause +| case(instruction) +| Ident (* proc_name *) arguments +| Ident ASS expr +| Ident brackets(expr) ASS expr +| Ident DOT nsepseq(selection,DOT) option(brackets(expr)) ASS expr +| loop +| Fail expr +| Skip +| Patch path With record_expr +| Patch path With injection(Map,binding) +| Patch path With injection(Set,expr) +| Remove expr From Map path +| Remove expr From Set path + +injection(Kind,element) ::= + Kind series(element,SEMI,End) +| Kind End +| Kind LBRACKET bracketed + +bracketed ::= + series(element,SEMI,RBRACKET) +| RBRACKET + +binding ::= + expr ARROW expr + +if_clause ::= + instruction +| LBRACE series(statement,COMMA,RBRACE) + +case(rhs) ::= + Case expr Of cases(rhs) End +| Case expr Of LBRACKET cases(rhs) RBRACKET + +cases(rhs) ::= + option(VBAR) nsepseq(case_clause(rhs),VBAR) + +case_clause(rhs) ::= + pattern ARROW rhs + +loop ::= + while_loop +| for_loop + +while_loop ::= + While expr block + +for_loop ::= + For Ident ASS expr option(Down) To expr option(step_clause) block +| For Ident option(arrow_clause) In expr block + +step_clause ::= + Step expr + +arrow_clause ::= + ARROW Ident (* var *) + +(* Expressions *) + +interactive_expr ::= + expr EOF + +expr ::= + case(expr) +| annot_expr + +annot_expr ::= + LPAR disj_expr COLON type_expr RPAR +| disj_expr + +disj_expr ::= + disj_expr Or conj_expr +| conj_expr + +conj_expr ::= + conj_expr And set_membership +| set_membership + +set_membership ::= + core_expr Contains set_membership +| comp_expr + +comp_expr ::= + comp_expr LT cat_expr +| comp_expr LEQ cat_expr +| comp_expr GT cat_expr +| comp_expr GEQ cat_expr +| comp_expr EQUAL cat_expr +| comp_expr NEQ cat_expr +| cat_expr + +cat_expr ::= + cons_expr CAT cat_expr +| cons_expr + +cons_expr ::= + add_expr CONS cons_expr +| add_expr + +add_expr ::= + add_expr PLUS mult_expr +| add_expr MINUS mult_expr +| mult_expr + +mult_expr ::= + mult_expr TIMES unary_expr +| mult_expr SLASH unary_expr +| mult_expr Mod unary_expr +| unary_expr + +unary_expr ::= + MINUS core_expr +| Not core_expr +| core_expr + +core_expr ::= + Int +| Nat +| Mtz +| Ident (* var *) +| String +| Bytes +| C_False +| C_True +| C_Unit +| tuple_expr +| list_expr +| C_None +| fun_call +| map_expr +| set_expr +| record_expr +| Ident (* struct_name *) DOT nsepseq(selection,DOT) +| Constr arguments +| Constr +| C_Some arguments + +set_expr ::= + injection(Set,expr) + +map_expr ::= + map_lookup +| injection(Map,binding) + +map_lookup ::= + path brackets(expr) + +path ::= + Ident (* var *) +| Ident (* struct_name *) DOT nsepseq(selection,DOT) + +selection ::= + Ident (* field_name *) +| Int + +record_expr ::= + Record series(field_assignment,SEMI,End) +| Record LBRACKET series(field_assignment,SEMI,RBRACKET) + +field_assignment ::= + Ident (* field_name *) EQUAL expr + +fun_call ::= + Ident (* fun_name *) arguments + +tuple_expr ::= + tuple_inj + +tuple_inj ::= + par(nsepseq(expr,COMMA)) + +arguments ::= + tuple_inj + +list_expr ::= + injection(List,expr) +| Nil + +(* Patterns *) + +pattern ::= + nsepseq(core_pattern,CONS) + +core_pattern ::= + Ident (* var *) +| WILD +| Int +| String +| C_Unit +| C_False +| C_True +| C_None +| list_pattern +| tuple_pattern +| constr_pattern +| C_Some par(core_pattern) + +list_pattern ::= + injection(List,core_pattern) +| Nil +| par(cons_pattern) + +cons_pattern ::= + core_pattern CONS pattern + +tuple_pattern ::= + par(nsepseq(core_pattern,COMMA)) + +constr_pattern ::= + Constr tuple_pattern +| Constr diff --git a/src/parser/pascaligo/Doc/pascaligo_09.bnf b/src/parser/pascaligo/Doc/pascaligo_09.bnf new file mode 100644 index 000000000..b08424594 --- /dev/null +++ b/src/parser/pascaligo/Doc/pascaligo_09.bnf @@ -0,0 +1,385 @@ +left_assoc(item,op) + +right_assoc(item,op) ::= + item +| item op right_assoc(item,op) + +option(X) := + (**) +| X + +series(item,sep,term) ::= + item after_item(item,sep,term) + +after_item(item,sep,term) ::= + sep item_or_closing(item,sep,term) +| term + +item_or_closing(item,sep,term) ::= + term +| series(item,sep,term) + +(* Compound constructs *) + +par(X) ::= LPAR X RPAR + +brackets(X) ::= LBRACKET X RBRACKET + +(* Sequences *) + +(* Possibly empty sequence of items *) + +seq(X) ::= + (**) +| X seq(X) + +(* Non-empty sequence of items *) + +nseq(X) ::= X seq(X) + +(* Non-empty separated sequence of items *) + +nsepseq(X,Sep) ::= + X +| X Sep nsepseq(X,Sep) + +(* Possibly empy separated sequence of items *) + +sepseq(X,Sep) ::= + (**) +| nsepseq(X,Sep) + +(* Main *) + +contract ::= + nseq(declaration) EOF + +declaration ::= + type_decl option(SEMI) +| const_decl option(SEMI) +| lambda_decl option(SEMI) + +(* Type declarations *) + +type_decl ::= + Type Ident (* type_name *) Is type_expr + +type_expr ::= + cartesian +| sum_type +| record_type + +cartesian ::= + nsepseq(function_type,TIMES) + +function_type ::= + right_assoc(core_type,ARROW) + +core_type ::= + Ident (* type_name *) +| Ident (* type_name *) type_tuple +| Map type_tuple +| Set par(type_expr) +| List par(type_expr) +| par(type_expr) + +type_tuple ::= + par(nsepseq(type_expr,COMMA)) + +sum_type ::= + nsepseq(variant,VBAR) +| VBAR nsepseq(variant,VBAR) + +variant ::= + Constr Of cartesian +| Constr + +record_type ::= + Record series(field_decl,SEMI,End) +| Record LBRACKET series(field_decl,SEMI,RBRACKET) + +field_decl ::= + Ident (* field_name *) COLON type_expr + +(* Function and procedure declarations *) + +lambda_decl ::= + fun_decl +| proc_decl +| entry_decl + +fun_decl ::= + Function Ident (* fun_name *) parameters COLON type_expr Is + seq(local_decl) + block + With expr + +entry_decl ::= + Entrypoint Ident (* fun_name *) entry_params COLON type_expr Is + seq(local_decl) + block + With expr + +entry_params ::= + par(nsepseq(entry_param_decl,SEMI)) + +proc_decl ::= + Procedure Ident (* fun_name *) parameters Is + seq(local_decl) + block + +parameters ::= + par(nsepseq(param_decl,SEMI)) + +param_decl ::= + Var Ident (* var *) COLON param_type +| Const Ident (* var *) COLON param_type + +entry_param_decl ::= + param_decl +| Storage Ident (* var *) COLON param_type + +param_type ::= + cartesian + +block ::= + Begin series(statement,SEMI,End) +| Block LBRACE series(statement,SEMI,RBRACE) + +statement ::= + instruction +| data_decl + +data_decl ::= + const_decl +| var_decl + +const_decl ::= + Const unqualified_decl(EQUAL) + +var_decl ::= + Var unqualified_decl(ASS) + +local_decl ::= + fun_decl option(SEMI) +| proc_decl option(SEMI) +| data_decl option(SEMI) + +unqualified_decl(op) ::= + Ident (* var *) COLON type_expr op expr + +instruction ::= + single_instr +| block + +single_instr ::= + If expr Then if_clause option(SEMI) Else if_clause +| case(instruction) +| Ident (* proc_name *) arguments +| Ident ASS expr +| Ident brackets(expr) ASS expr +| Ident DOT nsepseq(selection,DOT) option(brackets(expr)) ASS expr +| loop +| Fail expr +| Skip +| Patch path With record_expr +| Patch path With injection(Map,binding) +| Patch path With injection(Set,expr) +| Remove expr From Map path +| Remove expr From Set path + +injection(Kind,element) ::= + Kind series(element,SEMI,End) +| Kind End +| Kind LBRACKET bracketed + +bracketed ::= + series(element,SEMI,RBRACKET) +| RBRACKET + +binding ::= + expr ARROW expr + +if_clause ::= + instruction +| LBRACE series(statement,COMMA,RBRACE) + +case(rhs) ::= + Case expr Of cases(rhs) End +| Case expr Of LBRACKET cases(rhs) RBRACKET + +cases(rhs) ::= + option(VBAR) nsepseq(case_clause(rhs),VBAR) + +case_clause(rhs) ::= + pattern ARROW rhs + +loop ::= + while_loop +| for_loop + +while_loop ::= + While expr block + +for_loop ::= + For Ident ASS expr option(Down) To expr option(step_clause) block +| For Ident In expr block +| For Ident ARROW Ident In expr block + +step_clause ::= + Step expr + +(* Expressions *) + +interactive_expr ::= + expr EOF + +expr ::= + case(expr) +| annot_expr + +annot_expr ::= + LPAR disj_expr COLON type_expr RPAR +| disj_expr + +disj_expr ::= + disj_expr Or conj_expr +| conj_expr + +conj_expr ::= + conj_expr And set_membership +| set_membership + +set_membership ::= + core_expr Contains set_membership +| comp_expr + +comp_expr ::= + comp_expr LT cat_expr +| comp_expr LEQ cat_expr +| comp_expr GT cat_expr +| comp_expr GEQ cat_expr +| comp_expr EQUAL cat_expr +| comp_expr NEQ cat_expr +| cat_expr + +cat_expr ::= + cons_expr CAT cat_expr +| cons_expr + +cons_expr ::= + add_expr CONS cons_expr +| add_expr + +add_expr ::= + add_expr PLUS mult_expr +| add_expr MINUS mult_expr +| mult_expr + +mult_expr ::= + mult_expr TIMES unary_expr +| mult_expr SLASH unary_expr +| mult_expr Mod unary_expr +| unary_expr + +unary_expr ::= + MINUS core_expr +| Not core_expr +| core_expr + +core_expr ::= + Int +| Nat +| Mtz +| Ident (* var *) +| String +| Bytes +| C_False +| C_True +| C_Unit +| tuple_expr +| list_expr +| C_None +| fun_call +| map_expr +| set_expr +| record_expr +| Ident (* struct_name *) DOT nsepseq(selection,DOT) +| Constr arguments +| Constr +| C_Some arguments + +set_expr ::= + injection(Set,expr) + +map_expr ::= + map_lookup +| injection(Map,binding) + +map_lookup ::= + path brackets(expr) + +path ::= + Ident (* var *) +| Ident (* struct_name *) DOT nsepseq(selection,DOT) + +selection ::= + Ident (* field_name *) +| Int + +record_expr ::= + Record series(field_assignment,SEMI,End) +| Record LBRACKET series(field_assignment,SEMI,RBRACKET) + +field_assignment ::= + Ident (* field_name *) EQUAL expr + +fun_call ::= + Ident (* fun_name *) arguments + +tuple_expr ::= + tuple_inj + +tuple_inj ::= + par(nsepseq(expr,COMMA)) + +arguments ::= + tuple_inj + +list_expr ::= + injection(List,expr) +| Nil + +(* Patterns *) + +pattern ::= + nsepseq(core_pattern,CONS) + +core_pattern ::= + Ident (* var *) +| WILD +| Int +| String +| C_Unit +| C_False +| C_True +| C_None +| list_pattern +| tuple_pattern +| constr_pattern +| C_Some par(core_pattern) + +list_pattern ::= + injection(List,core_pattern) +| Nil +| par(cons_pattern) + +cons_pattern ::= + core_pattern CONS pattern + +tuple_pattern ::= + par(nsepseq(core_pattern,COMMA)) + +constr_pattern ::= + Constr tuple_pattern +| Constr diff --git a/src/parser/pascaligo/Doc/pascaligo_10.bnf b/src/parser/pascaligo/Doc/pascaligo_10.bnf new file mode 100644 index 000000000..b33ff4778 --- /dev/null +++ b/src/parser/pascaligo/Doc/pascaligo_10.bnf @@ -0,0 +1,377 @@ +left_assoc(item,op) + +right_assoc(item,op) ::= + item +| item op right_assoc(item,op) + +option(X) := + (**) +| X + +series(item,sep,term) ::= + item after_item(item,sep,term) + +after_item(item,sep,term) ::= + sep item_or_closing(item,sep,term) +| term + +item_or_closing(item,sep,term) ::= + term +| series(item,sep,term) + +(* Compound constructs *) + +par(X) ::= LPAR X RPAR + +brackets(X) ::= LBRACKET X RBRACKET + +(* Sequences *) + +(* Possibly empty sequence of items *) + +seq(X) ::= + (**) +| X seq(X) + +(* Non-empty sequence of items *) + +nseq(X) ::= X seq(X) + +(* Non-empty separated sequence of items *) + +nsepseq(X,Sep) ::= + X +| X Sep nsepseq(X,Sep) + +(* Possibly empy separated sequence of items *) + +sepseq(X,Sep) ::= + (**) +| nsepseq(X,Sep) + +(* Main *) + +contract ::= + nseq(declaration) EOF + +declaration ::= + type_decl option(SEMI) +| const_decl option(SEMI) +| lambda_decl option(SEMI) + +(* Type declarations *) + +type_decl ::= + Type Ident (* type_name *) Is type_expr + +type_expr ::= + cartesian +| sum_type +| record_type + +cartesian ::= + nsepseq(function_type,TIMES) + +function_type ::= + right_assoc(core_type,ARROW) + +core_type ::= + Ident (* type_name *) +| Ident (* type_name *) type_tuple +| Map type_tuple +| Set par(type_expr) +| List par(type_expr) +| par(type_expr) + +type_tuple ::= + par(nsepseq(type_expr,COMMA)) + +sum_type ::= + nsepseq(variant,VBAR) +| VBAR nsepseq(variant,VBAR) + +variant ::= + Constr Of cartesian +| Constr + +record_type ::= + Record series(field_decl,SEMI,End) +| Record LBRACKET series(field_decl,SEMI,RBRACKET) + +field_decl ::= + Ident (* field_name *) COLON type_expr + +(* Function and procedure declarations *) + +lambda_decl ::= + fun_decl +| proc_decl +| entry_decl + +fun_decl ::= + Function Ident (* fun_name *) parameters COLON type_expr Is + seq(local_decl) + block + With expr + +entry_decl ::= + Entrypoint Ident (* fun_name *) entry_params COLON type_expr Is + seq(local_decl) + block + With expr + +entry_params ::= + par(nsepseq(entry_param_decl,SEMI)) + +proc_decl ::= + Procedure Ident (* fun_name *) parameters Is + seq(local_decl) + block + +parameters ::= + par(nsepseq(param_decl,SEMI)) + +param_decl ::= + Var Ident (* var *) COLON param_type +| Const Ident (* var *) COLON param_type + +entry_param_decl ::= + param_decl +| Storage Ident (* var *) COLON param_type + +param_type ::= + cartesian + +block ::= + Begin series(statement,SEMI,End) +| Block LBRACE series(statement,SEMI,RBRACE) + +statement ::= + instruction +| data_decl + +data_decl ::= + const_decl +| var_decl + +const_decl ::= + Const unqualified_decl(EQUAL) + +var_decl ::= + Var unqualified_decl(ASS) + +local_decl ::= + fun_decl option(SEMI) +| proc_decl option(SEMI) +| data_decl option(SEMI) + +unqualified_decl(op) ::= + Ident (* var *) COLON type_expr op expr + +instruction ::= + single_instr +| block + +single_instr ::= + If expr Then if_clause option(SEMI) Else if_clause +| case(instruction) +| Ident (* proc_name *) arguments +| Ident ASS expr +| Ident brackets(expr) ASS expr +| Ident DOT nsepseq(selection,DOT) option(brackets(expr)) ASS expr +| loop +| Fail expr +| Skip +| Patch path With record_expr +| Patch path With injection(Map,binding) +| Patch path With injection(Set,expr) +| Remove expr From Map path +| Remove expr From Set path + +injection(Kind,element) ::= + Kind series(element,SEMI,End) +| Kind End +| Kind LBRACKET bracketed + +bracketed ::= + series(element,SEMI,RBRACKET) +| RBRACKET + +binding ::= + expr ARROW expr + +if_clause ::= + instruction +| LBRACE series(statement,COMMA,RBRACE) + +case(rhs) ::= + Case expr Of cases(rhs) End +| Case expr Of LBRACKET cases(rhs) RBRACKET + +cases(rhs) ::= + nsepseq(case_clause(rhs),VBAR) +| VBAR nsepseq(case_clause(rhs),VBAR) + +case_clause(rhs) ::= + pattern ARROW rhs + +loop ::= + while_loop +| for_loop + +while_loop ::= + While expr block + +for_loop ::= + For Ident ASS expr option(Down) To expr option(step_clause) block +| For Ident In expr block +| For Ident ARROW Ident In expr block + +step_clause ::= + Step expr + +(* Expressions *) + +interactive_expr ::= + expr EOF + +expr ::= + case(expr) +| annot_expr + +annot_expr ::= + LPAR disj_expr COLON type_expr RPAR +| disj_expr + +disj_expr ::= + left_assoc(conj_expr,Or) + +conj_expr ::= + left_assoc(set_membership,And) + +set_membership ::= + core_expr Contains set_membership +| comp_expr + +comp_expr ::= + left_assoc(cat_expr,op_comp) + +op_comp ::= + LT | LEQ | GT | GEQ | EQUAL | NEQ + +cat_expr ::= + right_assoc(cons_expr,CAT) + +cons_expr ::= + left_assoc(add_expr,CONS) + +add_expr ::= + left_assoc(mult_expr,add_op) + +add_op ::= + PLUS | MINUS + +mult_expr ::= + left_assoc(unary_expr,mult_op) + +mult_op ::= + TIMES | SLASH | Mod + +unary_expr ::= + MINUS core_expr +| Not core_expr +| core_expr + +core_expr ::= + Int +| Nat +| Mtz +| Ident (* var *) +| String +| Bytes +| C_False +| C_True +| C_Unit +| tuple_expr +| list_expr +| C_None +| fun_call +| map_expr +| set_expr +| record_expr +| Ident (* struct_name *) DOT nsepseq(selection,DOT) +| Constr arguments +| Constr +| C_Some arguments + +set_expr ::= + injection(Set,expr) + +map_expr ::= + path brackets(expr) (* lookup *) +| injection(Map,binding) + +path ::= + Ident (* var *) +| Ident (* struct_name *) DOT nsepseq(selection,DOT) + +selection ::= + Ident (* field_name *) +| Int + +record_expr ::= + Record series(field_assignment,SEMI,End) +| Record LBRACKET series(field_assignment,SEMI,RBRACKET) + +field_assignment ::= + Ident (* field_name *) EQUAL expr + +fun_call ::= + Ident (* fun_name *) arguments + +tuple_expr ::= + tuple_inj + +tuple_inj ::= + par(nsepseq(expr,COMMA)) + +arguments ::= + tuple_inj + +list_expr ::= + injection(List,expr) +| Nil + +(* Patterns *) + +pattern ::= + nsepseq(core_pattern,CONS) + +core_pattern ::= + Ident (* var *) +| WILD +| Int +| String +| C_Unit +| C_False +| C_True +| C_None +| list_pattern +| tuple_pattern +| constr_pattern +| C_Some par(core_pattern) + +list_pattern ::= + injection(List,core_pattern) +| Nil +| par(cons_pattern) + +cons_pattern ::= + core_pattern CONS pattern + +tuple_pattern ::= + par(nsepseq(core_pattern,COMMA)) + +constr_pattern ::= + Constr tuple_pattern +| Constr