diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index c32cedbcb..cc08d58c2 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs @@ -2,7 +2,7 @@ // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 // Machine: DESKTOP-IF20NRO -// DateTime: 3/17/2019 11:23:05 AM +// DateTime: 3/30/2019 7:18:34 AM // UserName: FatCow // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.lst b/Parsers/PascalABCParserNewSaushkin/ABCPascal.lst index f397106d1..90846f8f2 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.lst +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.lst @@ -3,9 +3,9 @@ // GPPG error listing for yacc source file // ========================================================================== // Version: 1.3.6 -// Machine: DESKTOP-A6LT9RI -// DateTime: 10.11.2018 23:09:24 -// UserName: Станислав +// Machine: DESKTOP-IF20NRO +// DateTime: 3/30/2019 6:53:52 AM +// UserName: FatCow // ========================================================================== @@ -35,6 +35,7 @@ %using PascalABCCompiler.ParserTools; %using PascalABCCompiler.Errors; %using System.Linq; +%using SyntaxVisitors; %namespace GPPGParserScanner @@ -42,9 +43,9 @@ %start parse_goal -%token tkDirectiveName tkAmpersend tkColon tkDotDot tkPoint tkRoundOpen tkRoundClose tkSemiColon tkSquareOpen tkSquareClose tkQuestion tkQuestionPoint tkDoubleQuestion tkQuestionSquareOpen +%token tkDirectiveName tkAmpersend tkColon tkDotDot tkPoint tkRoundOpen tkRoundClose tkSemiColon tkSquareOpen tkSquareClose tkQuestion tkUnderscore tkQuestionPoint tkDoubleQuestion tkQuestionSquareOpen %token tkSizeOf tkTypeOf tkWhere tkArray tkCase tkClass tkAuto tkStatic tkConst tkConstructor tkDestructor tkElse tkExcept tkFile tkFor tkForeach tkFunction tkMatch tkWhen -%token tkIf tkImplementation tkInherited tkInterface /* tkTypeclass tkInstance */ tkProcedure tkOperator tkProperty tkRaise tkRecord tkSet tkType tkThen tkUses tkVar tkWhile tkWith tkNil +%token tkIf tkImplementation tkInherited tkInterface tkProcedure tkOperator tkProperty tkRaise tkRecord tkSet tkType tkThen tkUses tkVar tkWhile tkWith tkNil %token tkGoto tkOf tkLabel tkLock tkProgram tkEvent tkDefault tkTemplate tkPacked tkExports tkResourceString tkThreadvar tkSealed tkPartial tkTo tkDownto %token tkLoop %token tkSequence tkYield @@ -88,7 +89,7 @@ %type exception_handler %type exception_handler_list %type exception_identifier -%type typed_const_list1 typed_const_list optional_expr_list elem_list optional_expr_list_with_bracket expr_list const_elem_list1 const_func_expr_list case_label_list const_elem_list optional_const_func_expr_list elem_list1 +%type typed_const_list1 typed_const_list optional_expr_list elem_list optional_expr_list_with_bracket expr_list const_elem_list1 /*const_func_expr_list*/ case_label_list const_elem_list optional_const_func_expr_list elem_list1 %type enumeration_id expr_l1_list %type enumeration_id_list %type const_simple_expr term simple_term typed_const typed_const_plus typed_var_init_expression expr expr_with_func_decl_lambda const_expr elem range_expr const_elem array_const factor relop_expr expr_dq expr_l1 expr_l1_func_decl_lambda simple_expr range_term range_factor @@ -104,7 +105,6 @@ %type func_name_ident param_name const_field_name func_name_with_template_args identifier_or_keyword unit_name exception_variable const_name func_meth_name_ident label_name type_decl_identifier template_identifier_with_equal %type program_param identifier identifier_keyword_operatorname func_class_name_ident /*optional_identifier*/ visibility_specifier %type property_specifier_directives non_reserved -//%type typeclass_restriction %type if_stmt %type initialization_part %type template_arguments label_list ident_or_keyword_pointseparator_list ident_list param_name_list @@ -156,7 +156,7 @@ %type simple_property_definition %type stmt_or_expression unlabelled_stmt stmt case_item %type set_type -%type as_is_expr as_is_constexpr is_expr as_expr power_expr power_constexpr +%type as_is_expr as_is_constexpr is_type_expr as_expr power_expr power_constexpr %type unsized_array_type simple_type_or_ simple_type simple_type_question/*array_name_for_new_expr*/ foreach_stmt_ident_dype_opt fptype type_ref fptype_noproctype array_type %type template_param template_empty_param structured_type unpacked_structured_type empty_template_type_reference simple_or_template_type_reference type_ref_or_secific for_stmt_decl_or_assign type_decl_type %type type_ref_and_secific_list @@ -166,7 +166,6 @@ %type typeof_expr %type simple_fp_sect %type template_param_list template_empty_param_list template_type_params template_type_empty_params -//%type template_type_or_typeclass_params typeclass_params %type template_type %type try_stmt %type uses_clause used_units_list @@ -174,7 +173,7 @@ %type used_unit_name %type unit_header %type var_decl_sect -%type var_decl var_decl_part /*var_decl_internal*/ field_definition +%type var_decl var_decl_part /*var_decl_internal*/ field_definition var_decl_with_assign_var_tuple %type var_stmt %type where_part %type where_part_list optional_where_section @@ -183,14 +182,20 @@ %type variable_as_type dotted_identifier %type func_decl_lambda expl_func_decl_lambda %type lambda_type_ref lambda_type_ref_noproctype -%type full_lambda_fp_list lambda_simple_fp_sect lambda_function_body lambda_procedure_body optional_full_lambda_fp_list +%type full_lambda_fp_list lambda_simple_fp_sect lambda_function_body lambda_procedure_body common_lambda_body optional_full_lambda_fp_list %type field_in_unnamed_object list_fields_in_unnamed_object func_class_name_ident_list rem_lambda variable_list var_ident_list %type tkAssignOrEqual -%type pattern pattern_optional_var match_with pattern_case pattern_cases pattern_out_param pattern_out_param_optional_var -%type pattern_out_param_list pattern_out_param_list_optional_var +%type pattern pattern_optional_var const_pattern collection_pattern collection_pattern_list_item collection_pattern_var_item match_with pattern_case pattern_cases pattern_out_param pattern_out_param_optional_var tuple_pattern_expr_list const_pattern_expr_list +%type pattern_out_param_list pattern_out_param_list_optional_var collection_pattern_expr_list +%type const_pattern_expression tuple_pattern tuple_pattern_expr + %% -// Warning: NonTerminal symbol "const_func_expr_list" is unreachable -// ----------------------------------------------------------------- +// Warning: Terminating collection_pattern_var_item fixes the following size-1 NonTerminal set + // {collection_pattern_var_item} +// Error: NonTerminal symbol "collection_pattern_var_item" has no productions +// Error: There are 1 non-terminating NonTerminal Symbols + // {collection_pattern_var_item} +// ------------------------------------------------------------------------------------------- parse_goal : program_file @@ -666,26 +671,39 @@ type_decl_sect } ; +var_decl_with_assign_var_tuple + : var_decl + { + $$ = $1; + } + | tkRoundOpen identifier tkComma ident_list tkRoundClose tkAssign expr_l1 tkSemiColon + { + ($4 as ident_list).Insert(0,$2); + $4.source_context = LexLocation.MergeAll(@1,@2,@3,@4,@5); + $$ = new var_tuple_def_statement($4 as ident_list, $7, @$); + } + ; + var_decl_sect - : tkVar var_decl + : tkVar var_decl_with_assign_var_tuple { $$ = new variable_definitions($2 as var_def_statement, @$); } - | tkEvent var_decl + | tkEvent var_decl_with_assign_var_tuple { $$ = new variable_definitions($2 as var_def_statement, @$); ($2 as var_def_statement).is_event = true; } - | var_decl_sect var_decl + | var_decl_sect var_decl_with_assign_var_tuple { $$ = ($1 as variable_definitions).Add($2 as var_def_statement, @$); } - | tkVar tkRoundOpen identifier tkComma ident_list tkRoundClose tkAssign expr_l1 tkSemiColon + /*| tkVar tkRoundOpen identifier tkComma ident_list tkRoundClose tkAssign expr_l1 tkSemiColon { ($5 as ident_list).Insert(0,$3); $5.source_context = LexLocation.MergeAll(@1,@2,@3,@4,@5,@6); $$ = new assign_var_tuple($5 as ident_list, $8, @$); - } + }*/ ; const_decl @@ -966,7 +984,7 @@ optional_const_func_expr_list { $$ = null; } ; -const_func_expr_list +/*const_func_expr_list : const_expr { $$ = new expression_list($1, @$); @@ -975,7 +993,7 @@ const_func_expr_list { $$ = ($1 as expression_list).Add($3, @$); } - ; + ;*/ const_elem_list : const_elem_list1 @@ -1146,41 +1164,8 @@ simple_type_decl | template_identifier_with_equal type_decl_type tkSemiColon { $$ = new type_declaration($1, $2, @$); - }/* - | typeclass_restriction tkEqual tkTypeclass optional_base_classes optional_component_list_seq_end tkSemiColon - { - $$ = new type_declaration($1 as typeclass_restriction, new typeclass_definition($4 as named_type_reference_list, $5 as class_body_list, @$), @$); } - | typeclass_restriction tkEqual tkInstance optional_component_list_seq_end tkSemiColon - { - $$ = new type_declaration($1 as typeclass_restriction, new instance_definition($4 as class_body_list, @$), @$); - }*/ ; -/* -typeclass_restriction - : simple_type_identifier typeclass_params - { - $$ = new typeclass_restriction(($1 as named_type_reference).ToString(), $2 as template_param_list, @$); - } - ; - -typeclass_params - : tkSquareOpen template_param_list tkSquareClose - { - $$ = new typeclass_param_list($2 as template_param_list); - } - ; - -template_type_or_typeclass_params - : template_type_params - { - $$ = $1; - } - | typeclass_params - { - $$ = $1; - } - ;*/ type_decl_identifier : identifier @@ -1563,108 +1548,31 @@ proc_type_decl object_type : class_attributes class_or_interface_keyword optional_base_classes optional_where_section optional_component_list_seq_end { - $$ = NewObjectType((class_attribute)$1, $2, $3 as named_type_reference_list, $4 as where_definition_list, $5 as class_body_list, @$); - class_definition cd = $$ as class_definition; - if (cd == null || cd.body == null) - break; - var ccnt = cd.body.DescendantNodes().OfType().ToArray(); - var cm = new class_members(access_modifer.private_modifer); - foreach (var prop in ccnt) + var cd = NewObjectType((class_attribute)$1, $2, $3 as named_type_reference_list, $4 as where_definition_list, $5 as class_body_list, @$); + $$ = cd; + var tt = cd.DescendantNodes().OfType().Where(cld => cld.keyword == class_keyword.Record); + if (tt.Count()>0) { - var td = prop.property_type; - var ra = prop.accessors?.read_accessor; - if ($2.text.ToLower() == "interface" && ra != null && (ra.pr != null || ra.accessor_name != null)) - parsertools.AddErrorFromResource("INVALID_INTERFACE_MEMBER",ra.source_context); - - if (ra != null && ra.pr != null) + foreach (var ttt in tt) { - if (prop.parameter_list != null) - parsertools.AddErrorFromResource("EXTENDED_INDEXED_PROPERTIES",ra.source_context); - var rapr = ra.pr as procedure_definition; - (rapr.proc_header as function_header).return_type = td; - cm.Add(rapr); - if (prop.attr == definition_attribute.Static) - { - rapr.proc_header.class_keyword = true; - procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static); - pa.source_context = rapr.proc_header.source_context; - rapr.proc_header.proc_attributes = new procedure_attributes_list(pa); - } - } - var wa = prop.accessors?.write_accessor; - if ($2.text.ToLower() == "interface" && wa != null && (wa.pr != null || wa.accessor_name != null)) - parsertools.AddErrorFromResource("INVALID_INTERFACE_MEMBER",wa.source_context); - - if (wa != null && wa.pr != null) - { - if (prop.parameter_list != null) - parsertools.AddErrorFromResource("EXTENDED_INDEXED_PROPERTIES",ra.source_context); - var wapr = wa.pr as procedure_definition; - wapr.proc_header.parameters.params_list[0].vars_type = td; - cm.Add(wapr); - if (prop.attr == definition_attribute.Static) - { - wapr.proc_header.class_keyword = true; - procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static); - pa.source_context = wapr.proc_header.source_context; - wapr.proc_header.proc_attributes = new procedure_attributes_list(pa); - } + var sc = ttt.source_context; + parsertools.AddErrorFromResource("NESTED_RECORD_DEFINITIONS_ARE_FORBIDDEN", new LexLocation(sc.begin_position.line_num, sc.begin_position.column_num-1, sc.end_position.line_num, sc.end_position.column_num, sc.FileName)); } } - if (cm.Count>0) - cd.body.Insert(0, cm); } ; record_type : tkRecord optional_base_classes optional_where_section member_list_section tkEnd { - $$ = NewRecordType($2 as named_type_reference_list, $3 as where_definition_list, $4 as class_body_list, @$); - class_definition cd = $$ as class_definition; - if (cd == null || cd.body == null) - break; - var ccnt = cd.body.DescendantNodes().OfType().ToArray(); - var cm = new class_members(access_modifer.private_modifer); - foreach (var prop in ccnt) - { - var td = prop.property_type; - var ra = prop.accessors?.read_accessor; - - if (ra != null && ra.pr != null) - { - if (prop.parameter_list != null) - parsertools.AddErrorFromResource("EXTENDED_INDEXED_PROPERTIES",ra.source_context); - var rapr = ra.pr as procedure_definition; - (rapr.proc_header as function_header).return_type = td; - cm.Add(rapr); - if (prop.attr == definition_attribute.Static) - { - rapr.proc_header.class_keyword = true; - procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static); - pa.source_context = rapr.proc_header.source_context; - rapr.proc_header.proc_attributes = new procedure_attributes_list(pa); - } - } - var wa = prop.accessors?.write_accessor; - - if (wa != null && wa.pr != null && prop.parameter_list == null) - { - if (prop.parameter_list != null) - parsertools.AddErrorFromResource("EXTENDED_INDEXED_PROPERTIES",ra.source_context); - var wapr = wa.pr as procedure_definition; - wapr.proc_header.parameters.params_list[0].vars_type = td; - cm.Add(wapr); - if (prop.attr == definition_attribute.Static) - { - wapr.proc_header.class_keyword = true; - procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static); - pa.source_context = wapr.proc_header.source_context; - wapr.proc_header.proc_attributes = new procedure_attributes_list(pa); - } - } - } - if (cm.Count>0) - cd.body.Insert(0, cm); + var nnrt = new class_definition($2 as named_type_reference_list, $4 as class_body_list, class_keyword.Record, null, $3 as where_definition_list, class_attribute.None, false, @$); + if (/*nnrt.body!=null && nnrt.body.class_def_blocks!=null && + nnrt.body.class_def_blocks.Count>0 &&*/ + nnrt.body.class_def_blocks[0].access_mod==null) + { + nnrt.body.class_def_blocks[0].access_mod = new access_modifer_node(access_modifer.public_modifer); + } + $$ = nnrt; } ; @@ -1760,12 +1668,7 @@ base_class_name : simple_type_identifier { $$ = $1; } | template_type - { $$ = $1; }/* - | typeclass_restriction - { - var names = new List(); - names.Add(($1 as typeclass_restriction).name); - $$ = new typeclass_reference(null, names, ($1 as typeclass_restriction).restriction_args); }*/ + { $$ = $1; } ; template_arguments @@ -1798,11 +1701,7 @@ where_part : tkWhere ident_list tkColon type_ref_and_secific_list tkSemiColon { $$ = new where_definition($2 as ident_list, $4 as where_type_specificator_list, @$); - }/* - | tkWhere typeclass_restriction tkSemiColon - { - $$ = new where_typeclass_constraint($2 as typeclass_restriction); - }*/ + } ; type_ref_and_secific_list @@ -2080,12 +1979,23 @@ simple_property_definition { parsertools.AddErrorFromResource("STATIC_PROPERTIES_CANNOT_HAVE_ATTRBUTE_{0}",@7,$7.name); } + | tkAuto tkProperty qualified_identifier property_interface tkSemiColon + { + $$ = NewSimplePropertyDefinition($3 as method_name, $4 as property_interface, null, proc_attribute.attr_none, null, @$); + ($$ as simple_property).is_auto = true; + } + | class_or_static tkAuto tkProperty qualified_identifier property_interface tkSemiColon + { + $$ = NewSimplePropertyDefinition($4 as method_name, $5 as property_interface, null, proc_attribute.attr_none, null, @$); + ($$ as simple_property).is_auto = true; + ($$ as simple_property).attr = definition_attribute.Static; + } ; array_defaultproperty : { $$ = null; } - | tkDefault tkSemiColon + | tkDefault tkSemiColon { $$ = new property_array_default(); $$.source_context = @$; @@ -2182,7 +2092,9 @@ property_specifiers procedure_definition pr = null; if (!parsertools.build_tree_for_formatter) pr = CreateAndAddToClassWriteProc($2 as statement,id,@2); - $$ = NewPropertySpecifiersWrite($1, id, pr, $2 as statement, $3 as property_accessors, @$); // $2 ïåðåäà¸òñÿ äëÿ ôîðìàòèðîâàíèÿ + if (parsertools.build_tree_for_formatter) + $$ = NewPropertySpecifiersWrite($1, id, pr, $2 as statement, $3 as property_accessors, @$); // $2 ïåðåäà¸òñÿ äëÿ ôîðìàòèðîâàíèÿ + else $$ = NewPropertySpecifiersWrite($1, id, pr, null, $3 as property_accessors, @$); } } ; @@ -2205,7 +2117,9 @@ write_property_specifiers procedure_definition pr = null; if (!parsertools.build_tree_for_formatter) pr = CreateAndAddToClassWriteProc($2 as statement,id,@2); - $$ = NewPropertySpecifiersWrite($1, id, pr, $2 as statement, null, @$); + if (parsertools.build_tree_for_formatter) + $$ = NewPropertySpecifiersWrite($1, id, pr, $2 as statement, null, @$); + else $$ = NewPropertySpecifiersWrite($1, id, pr, null, null, @$); } } ; @@ -2267,12 +2181,6 @@ var_decl_part { $$ = new var_def_statement($1 as ident_list, $3, $5, definition_attribute.None, false, @$); } - /*| tkRoundOpen identifier tkComma ident_list tkRoundClose tkAssign expr_l1 - { - ($4 as ident_list).Insert(0,$2); - $4.source_context = LexLocation.MergeAll(@1,@2,@3,@4,@5,@6); - $$ = new assign_var_tuple($4 as ident_list, $7, @$); - }*/ ; typed_var_init_expression @@ -2899,6 +2807,18 @@ pattern_case { $$ = new pattern_case($1 as pattern_node, $3 as statement, null, @$); } + | const_pattern tkWhen expr_l1 tkColon unlabelled_stmt + { + $$ = new pattern_case($1 as pattern_node, $5 as statement, $3, @$); + } + | const_pattern tkColon unlabelled_stmt + { + $$ = new pattern_case($1 as pattern_node, $3 as statement, null, @$); + } + | collection_pattern tkColon unlabelled_stmt + { + $$ = new pattern_case($1 as pattern_node, $3 as statement, null, @$); + } ; case_stmt @@ -3373,44 +3293,172 @@ relop_expr { $$ = new bin_expr($1, $3, $2.type, @$); } - | is_expr tkRoundOpen pattern_out_param_list tkRoundClose + | is_type_expr tkRoundOpen pattern_out_param_list tkRoundClose { var isTypeCheck = $1 as typecast_node; - var deconstructorPattern = new deconstructor_pattern($3 as List, isTypeCheck.type_def, @$); + var deconstructorPattern = new deconstructor_pattern($3 as List, isTypeCheck.type_def, @$); $$ = new is_pattern_expr(isTypeCheck.expr, deconstructorPattern, @$); } + + | term tkIs collection_pattern + { + $$ = new is_pattern_expr($1, $3 as pattern_node, @$); + } ; pattern : simple_or_template_type_reference tkRoundOpen pattern_out_param_list tkRoundClose { - $$ = new deconstructor_pattern($3 as List, $1, @$); + $$ = new deconstructor_pattern($3 as List, $1, @$); } ; pattern_optional_var : simple_or_template_type_reference tkRoundOpen pattern_out_param_list_optional_var tkRoundClose { - $$ = new deconstructor_pattern($3 as List, $1, @$); + $$ = new deconstructor_pattern($3 as List, $1, @$); } - ; + ; + +collection_pattern + : tkSquareOpen collection_pattern_expr_list tkSquareClose + { + $$ = new collection_pattern($2 as List, @$); + } + ; + +collection_pattern_expr_list + : collection_pattern_list_item + { + $$ = new List(); + ($$ as List).Add($1 as pattern_parameter); + } + | collection_pattern_expr_list tkComma collection_pattern_list_item + { + var list = $1 as List; + list.Add($3 as pattern_parameter); + $$ = list; + } + ; + +collection_pattern_list_item + : literal_or_number + { + $$ = new const_pattern_parameter($1, @$); + } + | collection_pattern_var_item + { + $$ = $1; + } + | tkUnderscore + { + $$ = new collection_pattern_wild_card(); + } + | pattern + { + $$ = new recursive_deconstructor_parameter($1 as pattern_node, @$); + } + | pattern_optional_var + { + $$ = new recursive_deconstructor_parameter($1 as pattern_node, @$); + } + | tkDotDot + { + $$ = new collection_pattern_gap_parameter(); + } + ; + +collection_pattern_var_item + | tkVar identifier tkColon type_ref +// Error: Syntax error, unexpected '|', expecting ':' +// -------------------------------------------------- + { + $$ = new collection_pattern_var_parameter($2, $4, @$); + } + | tkVar identifier + { + $$ = new collection_pattern_var_parameter($2, null, @$); + } + | identifier tkColon type_ref + { + $$ = new collection_pattern_var_parameter($1, $3, @$); + } + | identifier + { + $$ = new collection_pattern_var_parameter($1, null, @$); + } + ; + +const_pattern + : const_pattern_expr_list + { + $$ = new const_pattern($1 as expression_list, @$); + } + ; + +const_pattern_expr_list + : const_pattern_expression + { + $$ = new expression_list($1, @$); + } + | const_pattern_expr_list tkComma const_pattern_expression + { + $$ = ($1 as expression_list).Add($3, @$); + } + ; + +const_pattern_expression + : literal_or_number { $$ = $1; } + | tuple_pattern { $$ = $1; } + ; +tuple_pattern + : tkRoundOpen tuple_pattern_expr tkComma tuple_pattern_expr_list lambda_type_ref optional_full_lambda_fp_list tkRoundClose + { + /*if ($5 != null) + parsertools.AddErrorFromResource("BAD_TUPLE",@5); + if ($6 != null) + parsertools.AddErrorFromResource("BAD_TUPLE",@6);*/ + + if (($4 as expression_list).Count>6) + parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",@$); + ($4 as expression_list).Insert(0,$2); + $$ = new tuple_node($4 as expression_list,@$); + } + ; + +tuple_pattern_expr + : tkUnderscore { $$ = new tuple_wild_card(); } + | literal_or_number { $$ = $1; } + ; + +tuple_pattern_expr_list + : tuple_pattern_expr + { + $$ = new expression_list($1, @$); + } + | tuple_pattern_expr_list tkComma tuple_pattern_expr + { + $$ = ($1 as expression_list).Add($3, @$); + } + ; + pattern_out_param_list_optional_var : pattern_out_param_optional_var { - $$ = new List(); - ($$ as List).Add($1 as pattern_deconstructor_parameter); + $$ = new List(); + ($$ as List).Add($1 as pattern_parameter); } | pattern_out_param_list_optional_var tkSemiColon pattern_out_param_optional_var { - var list = $1 as List; - list.Add($3 as pattern_deconstructor_parameter); + var list = $1 as List; + list.Add($3 as pattern_parameter); $$ = list; } | pattern_out_param_list_optional_var tkComma pattern_out_param_optional_var { - var list = $1 as List; - list.Add($3 as pattern_deconstructor_parameter); + var list = $1 as List; + list.Add($3 as pattern_parameter); $$ = list; } ; @@ -3418,25 +3466,33 @@ pattern_out_param_list_optional_var pattern_out_param_list : pattern_out_param { - $$ = new List(); - ($$ as List).Add($1 as pattern_deconstructor_parameter); + $$ = new List(); + ($$ as List).Add($1 as pattern_parameter); } | pattern_out_param_list tkSemiColon pattern_out_param { - var list = $1 as List; - list.Add($3 as pattern_deconstructor_parameter); + var list = $1 as List; + list.Add($3 as pattern_parameter); $$ = list; } | pattern_out_param_list tkComma pattern_out_param { - var list = $1 as List; - list.Add($3 as pattern_deconstructor_parameter); + var list = $1 as List; + list.Add($3 as pattern_parameter); $$ = list; } ; pattern_out_param - : tkVar identifier tkColon type_ref + : tkUnderscore + { + $$ = new wild_card_deconstructor_parameter(); + } + | literal_or_number + { + $$ = new const_pattern_parameter($1, @$); + } + | tkVar identifier tkColon type_ref { $$ = new var_deconstructor_parameter($2, $4, @$); } @@ -3451,7 +3507,15 @@ pattern_out_param ; pattern_out_param_optional_var - : identifier tkColon type_ref + : tkUnderscore + { + $$ = new wild_card_deconstructor_parameter(); + } + | literal_or_number + { + $$ = new const_pattern_parameter($1, @$); + } + | identifier tkColon type_ref { $$ = new var_deconstructor_parameter($1, $3, @$); } @@ -3585,7 +3649,7 @@ typecast_op ; as_is_expr - : is_expr + : is_type_expr { $$ = $1; } | as_expr { $$ = $1; } @@ -3598,7 +3662,7 @@ as_expr } ; -is_expr +is_type_expr : term tkIs simple_or_template_type_reference { $$ = NewAsIsExpr($1, op_typecast.is_op, $3, @$); @@ -4211,9 +4275,7 @@ keyword | tkMatch { $$ = $1; } | tkWhen - { $$ = $1; }/* - | tkInstance - { $$ = $1; }*/ + { $$ = $1; } ; reserved_keyword @@ -4482,15 +4544,8 @@ lambda_type_ref_noproctype } ; -lambda_function_body - : expr_l1 - { - //$$ = NewLambdaBody($1, @$); - var sl = new statement_list(new assign("result",$1,@$),@$); // íàäî ïîìå÷àòü åù¸ è assign êàê àâòîñãåíåðèðîâàííûé äëÿ ëÿìáäû - sl.expr_lambda_body = true; - $$ = sl; - } - | compound_stmt +common_lambda_body + : compound_stmt { $$ = $1; } @@ -4514,6 +4569,10 @@ lambda_function_body { $$ = new statement_list($1 as statement, @$); } + | loop_stmt + { + $$ = new statement_list($1 as statement, @$); + } | case_stmt { $$ = new statement_list($1 as statement, @$); @@ -4534,6 +4593,25 @@ lambda_function_body { $$ = new statement_list($1 as statement, @$); } + ; + + +lambda_function_body + : expr_l1 + { + var id = SyntaxVisitors.ExprHasNameVisitor.HasName($1, "Result"); + if (id != null) + { + parsertools.AddErrorFromResource("RESULT_IDENT_NOT_EXPECTED_IN_THIS_CONTEXT", id.source_context); + } + var sl = new statement_list(new assign("result",$1,@$),@$); // íàäî ïîìå÷àòü åù¸ è assign êàê àâòîñãåíåðèðîâàííûé äëÿ ëÿìáäû - ÷òîáû çàïðåòèòü ÿâíûé Result + sl.expr_lambda_body = true; + $$ = sl; + } + | common_lambda_body + { + $$ = $1; + } ; lambda_procedure_body @@ -4541,54 +4619,14 @@ lambda_procedure_body { $$ = new statement_list($1 as statement, @$); } - | compound_stmt - { - $$ = $1; - } - | if_stmt - { - $$ = new statement_list($1 as statement, @$); - } - | while_stmt - { - $$ = new statement_list($1 as statement, @$); - } - | repeat_stmt - { - $$ = new statement_list($1 as statement, @$); - } - | for_stmt - { - $$ = new statement_list($1 as statement, @$); - } - | foreach_stmt - { - $$ = new statement_list($1 as statement, @$); - } - | case_stmt - { - $$ = new statement_list($1 as statement, @$); - } - | try_stmt - { - $$ = new statement_list($1 as statement, @$); - } - | lock_stmt - { - $$ = new statement_list($1 as statement, @$); - } - | yield_stmt - { - $$ = new statement_list($1 as statement, @$); - } - | raise_stmt - { - $$ = new statement_list($1 as statement, @$); - } | assignment { $$ = new statement_list($1 as statement, @$); } + | common_lambda_body + { + $$ = $1; + } ; %%// ========================================================================== diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index 34dfd4770..11e654bad 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -174,7 +174,7 @@ %type full_lambda_fp_list lambda_simple_fp_sect lambda_function_body lambda_procedure_body common_lambda_body optional_full_lambda_fp_list %type field_in_unnamed_object list_fields_in_unnamed_object func_class_name_ident_list rem_lambda variable_list var_ident_list %type tkAssignOrEqual -%type pattern pattern_optional_var const_pattern collection_pattern collection_pattern_list_item match_with pattern_case pattern_cases pattern_out_param pattern_out_param_optional_var tuple_pattern_expr_list const_pattern_expr_list +%type pattern pattern_optional_var const_pattern collection_pattern collection_pattern_list_item collection_pattern_var_item match_with pattern_case pattern_cases pattern_out_param pattern_out_param_optional_var tuple_pattern_expr_list const_pattern_expr_list %type pattern_out_param_list pattern_out_param_list_optional_var collection_pattern_expr_list %type const_pattern_expression tuple_pattern tuple_pattern_expr @@ -3279,7 +3279,7 @@ relop_expr | is_type_expr tkRoundOpen pattern_out_param_list tkRoundClose { var isTypeCheck = $1 as typecast_node; - var deconstructorPattern = new deconstructor_pattern($3 as List, isTypeCheck.type_def, @$); + var deconstructorPattern = new deconstructor_pattern($3 as List, isTypeCheck.type_def, null, @$); $$ = new is_pattern_expr(isTypeCheck.expr, deconstructorPattern, @$); } @@ -3292,14 +3292,14 @@ relop_expr pattern : simple_or_template_type_reference tkRoundOpen pattern_out_param_list tkRoundClose { - $$ = new deconstructor_pattern($3 as List, $1, @$); + $$ = new deconstructor_pattern($3 as List, $1, null, @$); } ; pattern_optional_var : simple_or_template_type_reference tkRoundOpen pattern_out_param_list_optional_var tkRoundClose { - $$ = new deconstructor_pattern($3 as List, $1, @$); + $$ = new deconstructor_pattern($3 as List, $1, null, @$); } ; @@ -3329,10 +3329,18 @@ collection_pattern_list_item { $$ = new const_pattern_parameter($1, @$); } - | pattern + | collection_pattern_var_item + { + $$ = $1; + } + | tkUnderscore + { + $$ = new collection_pattern_wild_card(); + } + /*| pattern { $$ = new recursive_deconstructor_parameter($1 as pattern_node, @$); - } + }*/ | pattern_optional_var { $$ = new recursive_deconstructor_parameter($1 as pattern_node, @$); @@ -3343,6 +3351,25 @@ collection_pattern_list_item } ; +collection_pattern_var_item + : tkVar identifier tkColon type_ref + { + $$ = new collection_pattern_var_parameter($2, $4, @$); + } + | tkVar identifier + { + $$ = new collection_pattern_var_parameter($2, null, @$); + } + | identifier tkColon type_ref + { + $$ = new collection_pattern_var_parameter($1, $3, @$); + } + | identifier + { + $$ = new collection_pattern_var_parameter($1, null, @$); + } + ; + const_pattern : const_pattern_expr_list { diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index 9c17bf14e..1927de0b6 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: DESKTOP-IF20NRO -// DateTime: 3/17/2019 11:23:05 AM +// DateTime: 3/30/2019 7:18:34 AM // UserName: FatCow // Input file @@ -75,7 +75,7 @@ public partial class GPPGParser: ShiftReduceParser aliasses; #pragma warning restore 649 - private static Rule[] rules = new Rule[925]; + private static Rule[] rules = new Rule[930]; private static State[] states = new State[1546]; private static string[] nonTerms = new string[] { "parse_goal", "unit_key_word", "class_or_static", "assignment", "optional_array_initializer", @@ -158,14 +158,14 @@ public partial class GPPGParser: ShiftReduceParser is_type_expr, tkRoundOpen, pattern_out_param_list, tkRoundClose { var isTypeCheck = ValueStack[ValueStack.Depth-4].ex as typecast_node; - var deconstructorPattern = new deconstructor_pattern(ValueStack[ValueStack.Depth-2].ob as List, isTypeCheck.type_def, CurrentLocationSpan); + var deconstructorPattern = new deconstructor_pattern(ValueStack[ValueStack.Depth-2].ob as List, isTypeCheck.type_def, null, CurrentLocationSpan); CurrentSemanticValue.ex = new is_pattern_expr(isTypeCheck.expr, deconstructorPattern, CurrentLocationSpan); } break; @@ -5574,13 +5579,13 @@ public partial class GPPGParser: ShiftReduceParser simple_or_template_type_reference, tkRoundOpen, // pattern_out_param_list, tkRoundClose { - CurrentSemanticValue.stn = new deconstructor_pattern(ValueStack[ValueStack.Depth-2].ob as List, ValueStack[ValueStack.Depth-4].td, CurrentLocationSpan); + CurrentSemanticValue.stn = new deconstructor_pattern(ValueStack[ValueStack.Depth-2].ob as List, ValueStack[ValueStack.Depth-4].td, null, CurrentLocationSpan); } break; case 612: // pattern_optional_var -> simple_or_template_type_reference, tkRoundOpen, // pattern_out_param_list_optional_var, tkRoundClose { - CurrentSemanticValue.stn = new deconstructor_pattern(ValueStack[ValueStack.Depth-2].ob as List, ValueStack[ValueStack.Depth-4].td, CurrentLocationSpan); + CurrentSemanticValue.stn = new deconstructor_pattern(ValueStack[ValueStack.Depth-2].ob as List, ValueStack[ValueStack.Depth-4].td, null, CurrentLocationSpan); } break; case 613: // collection_pattern -> tkSquareOpen, collection_pattern_expr_list, tkSquareClose @@ -5607,44 +5612,69 @@ public partial class GPPGParser: ShiftReduceParser pattern + case 617: // collection_pattern_list_item -> collection_pattern_var_item +{ + CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; + } + break; + case 618: // collection_pattern_list_item -> tkUnderscore +{ + CurrentSemanticValue.stn = new collection_pattern_wild_card(); + } + break; + case 619: // collection_pattern_list_item -> pattern_optional_var { CurrentSemanticValue.stn = new recursive_deconstructor_parameter(ValueStack[ValueStack.Depth-1].stn as pattern_node, CurrentLocationSpan); } break; - case 618: // collection_pattern_list_item -> pattern_optional_var -{ - CurrentSemanticValue.stn = new recursive_deconstructor_parameter(ValueStack[ValueStack.Depth-1].stn as pattern_node, CurrentLocationSpan); - } - break; - case 619: // collection_pattern_list_item -> tkDotDot + case 620: // collection_pattern_list_item -> tkDotDot { CurrentSemanticValue.stn = new collection_pattern_gap_parameter(); } break; - case 620: // const_pattern -> const_pattern_expr_list + case 621: // collection_pattern_var_item -> tkVar, identifier, tkColon, type_ref +{ + CurrentSemanticValue.stn = new collection_pattern_var_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); + } + break; + case 622: // collection_pattern_var_item -> tkVar, identifier +{ + CurrentSemanticValue.stn = new collection_pattern_var_parameter(ValueStack[ValueStack.Depth-1].id, null, CurrentLocationSpan); + } + break; + case 623: // collection_pattern_var_item -> identifier, tkColon, type_ref +{ + CurrentSemanticValue.stn = new collection_pattern_var_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); + } + break; + case 624: // collection_pattern_var_item -> identifier +{ + CurrentSemanticValue.stn = new collection_pattern_var_parameter(ValueStack[ValueStack.Depth-1].id, null, CurrentLocationSpan); + } + break; + case 625: // const_pattern -> const_pattern_expr_list { CurrentSemanticValue.stn = new const_pattern(ValueStack[ValueStack.Depth-1].stn as expression_list, CurrentLocationSpan); } break; - case 621: // const_pattern_expr_list -> const_pattern_expression + case 626: // const_pattern_expr_list -> const_pattern_expression { CurrentSemanticValue.stn = new expression_list(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 622: // const_pattern_expr_list -> const_pattern_expr_list, tkComma, + case 627: // const_pattern_expr_list -> const_pattern_expr_list, tkComma, // const_pattern_expression { CurrentSemanticValue.stn = (ValueStack[ValueStack.Depth-3].stn as expression_list).Add(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 623: // const_pattern_expression -> literal_or_number + case 628: // const_pattern_expression -> literal_or_number { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 624: // const_pattern_expression -> tuple_pattern + case 629: // const_pattern_expression -> tuple_pattern { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 625: // tuple_pattern -> tkRoundOpen, tuple_pattern_expr, tkComma, + case 630: // tuple_pattern -> tkRoundOpen, tuple_pattern_expr, tkComma, // tuple_pattern_expr_list, lambda_type_ref, // optional_full_lambda_fp_list, tkRoundClose { @@ -5659,29 +5689,29 @@ public partial class GPPGParser: ShiftReduceParser tkUnderscore + case 631: // tuple_pattern_expr -> tkUnderscore { CurrentSemanticValue.ex = new tuple_wild_card(); } break; - case 627: // tuple_pattern_expr -> literal_or_number + case 632: // tuple_pattern_expr -> literal_or_number { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 628: // tuple_pattern_expr_list -> tuple_pattern_expr + case 633: // tuple_pattern_expr_list -> tuple_pattern_expr { CurrentSemanticValue.stn = new expression_list(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 629: // tuple_pattern_expr_list -> tuple_pattern_expr_list, tkComma, tuple_pattern_expr + case 634: // tuple_pattern_expr_list -> tuple_pattern_expr_list, tkComma, tuple_pattern_expr { CurrentSemanticValue.stn = (ValueStack[ValueStack.Depth-3].stn as expression_list).Add(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 630: // pattern_out_param_list_optional_var -> pattern_out_param_optional_var + case 635: // pattern_out_param_list_optional_var -> pattern_out_param_optional_var { CurrentSemanticValue.ob = new List(); (CurrentSemanticValue.ob as List).Add(ValueStack[ValueStack.Depth-1].stn as pattern_parameter); } break; - case 631: // pattern_out_param_list_optional_var -> pattern_out_param_list_optional_var, + case 636: // pattern_out_param_list_optional_var -> pattern_out_param_list_optional_var, // tkSemiColon, // pattern_out_param_optional_var { @@ -5690,7 +5720,7 @@ public partial class GPPGParser: ShiftReduceParser pattern_out_param_list_optional_var, + case 637: // pattern_out_param_list_optional_var -> pattern_out_param_list_optional_var, // tkComma, // pattern_out_param_optional_var { @@ -5699,13 +5729,13 @@ public partial class GPPGParser: ShiftReduceParser pattern_out_param + case 638: // pattern_out_param_list -> pattern_out_param { CurrentSemanticValue.ob = new List(); (CurrentSemanticValue.ob as List).Add(ValueStack[ValueStack.Depth-1].stn as pattern_parameter); } break; - case 634: // pattern_out_param_list -> pattern_out_param_list, tkSemiColon, + case 639: // pattern_out_param_list -> pattern_out_param_list, tkSemiColon, // pattern_out_param { var list = ValueStack[ValueStack.Depth-3].ob as List; @@ -5713,257 +5743,257 @@ public partial class GPPGParser: ShiftReduceParser pattern_out_param_list, tkComma, pattern_out_param + case 640: // pattern_out_param_list -> pattern_out_param_list, tkComma, pattern_out_param { var list = ValueStack[ValueStack.Depth-3].ob as List; list.Add(ValueStack[ValueStack.Depth-1].stn as pattern_parameter); CurrentSemanticValue.ob = list; } break; - case 636: // pattern_out_param -> tkUnderscore + case 641: // pattern_out_param -> tkUnderscore { CurrentSemanticValue.stn = new wild_card_deconstructor_parameter(); } break; - case 637: // pattern_out_param -> literal_or_number + case 642: // pattern_out_param -> literal_or_number { CurrentSemanticValue.stn = new const_pattern_parameter(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 638: // pattern_out_param -> tkVar, identifier, tkColon, type_ref + case 643: // pattern_out_param -> tkVar, identifier, tkColon, type_ref { CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); } break; - case 639: // pattern_out_param -> tkVar, identifier + case 644: // pattern_out_param -> tkVar, identifier { CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-1].id, null, CurrentLocationSpan); } break; - case 640: // pattern_out_param -> pattern + case 645: // pattern_out_param -> pattern { CurrentSemanticValue.stn = new recursive_deconstructor_parameter(ValueStack[ValueStack.Depth-1].stn as pattern_node, CurrentLocationSpan); } break; - case 641: // pattern_out_param_optional_var -> tkUnderscore + case 646: // pattern_out_param_optional_var -> tkUnderscore { CurrentSemanticValue.stn = new wild_card_deconstructor_parameter(); } break; - case 642: // pattern_out_param_optional_var -> literal_or_number + case 647: // pattern_out_param_optional_var -> literal_or_number { CurrentSemanticValue.stn = new const_pattern_parameter(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 643: // pattern_out_param_optional_var -> identifier, tkColon, type_ref + case 648: // pattern_out_param_optional_var -> identifier, tkColon, type_ref { CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); } break; - case 644: // pattern_out_param_optional_var -> identifier + case 649: // pattern_out_param_optional_var -> identifier { CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-1].id, null, CurrentLocationSpan); } break; - case 645: // pattern_out_param_optional_var -> tkVar, identifier, tkColon, type_ref + case 650: // pattern_out_param_optional_var -> tkVar, identifier, tkColon, type_ref { CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); } break; - case 646: // pattern_out_param_optional_var -> tkVar, identifier + case 651: // pattern_out_param_optional_var -> tkVar, identifier { CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-1].id, null, CurrentLocationSpan); } break; - case 647: // pattern_out_param_optional_var -> pattern_optional_var + case 652: // pattern_out_param_optional_var -> pattern_optional_var { CurrentSemanticValue.stn = new recursive_deconstructor_parameter(ValueStack[ValueStack.Depth-1].stn as pattern_node, CurrentLocationSpan); } break; - case 648: // simple_expr_or_nothing -> simple_expr + case 653: // simple_expr_or_nothing -> simple_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 649: // simple_expr_or_nothing -> /* empty */ + case 654: // simple_expr_or_nothing -> /* empty */ { CurrentSemanticValue.ex = null; } break; - case 650: // const_expr_or_nothing -> const_expr + case 655: // const_expr_or_nothing -> const_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 651: // const_expr_or_nothing -> /* empty */ + case 656: // const_expr_or_nothing -> /* empty */ { CurrentSemanticValue.ex = null; } break; - case 652: // format_expr -> simple_expr, tkColon, simple_expr_or_nothing + case 657: // format_expr -> simple_expr, tkColon, simple_expr_or_nothing { CurrentSemanticValue.ex = new format_expr(ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, null, CurrentLocationSpan); } break; - case 653: // format_expr -> tkColon, simple_expr_or_nothing + case 658: // format_expr -> tkColon, simple_expr_or_nothing { CurrentSemanticValue.ex = new format_expr(null, ValueStack[ValueStack.Depth-1].ex, null, CurrentLocationSpan); } break; - case 654: // format_expr -> simple_expr, tkColon, simple_expr_or_nothing, tkColon, + case 659: // format_expr -> simple_expr, tkColon, simple_expr_or_nothing, tkColon, // simple_expr { CurrentSemanticValue.ex = new format_expr(ValueStack[ValueStack.Depth-5].ex, ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 655: // format_expr -> tkColon, simple_expr_or_nothing, tkColon, simple_expr + case 660: // format_expr -> tkColon, simple_expr_or_nothing, tkColon, simple_expr { CurrentSemanticValue.ex = new format_expr(null, ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 656: // format_const_expr -> const_expr, tkColon, const_expr_or_nothing + case 661: // format_const_expr -> const_expr, tkColon, const_expr_or_nothing { CurrentSemanticValue.ex = new format_expr(ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, null, CurrentLocationSpan); } break; - case 657: // format_const_expr -> tkColon, const_expr_or_nothing + case 662: // format_const_expr -> tkColon, const_expr_or_nothing { CurrentSemanticValue.ex = new format_expr(null, ValueStack[ValueStack.Depth-1].ex, null, CurrentLocationSpan); } break; - case 658: // format_const_expr -> const_expr, tkColon, const_expr_or_nothing, tkColon, + case 663: // format_const_expr -> const_expr, tkColon, const_expr_or_nothing, tkColon, // const_expr { CurrentSemanticValue.ex = new format_expr(ValueStack[ValueStack.Depth-5].ex, ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 659: // format_const_expr -> tkColon, const_expr_or_nothing, tkColon, const_expr + case 664: // format_const_expr -> tkColon, const_expr_or_nothing, tkColon, const_expr { CurrentSemanticValue.ex = new format_expr(null, ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 660: // relop -> tkEqual + case 665: // relop -> tkEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 661: // relop -> tkNotEqual + case 666: // relop -> tkNotEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 662: // relop -> tkLower + case 667: // relop -> tkLower { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 663: // relop -> tkGreater + case 668: // relop -> tkGreater { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 664: // relop -> tkLowerEqual + case 669: // relop -> tkLowerEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 665: // relop -> tkGreaterEqual + case 670: // relop -> tkGreaterEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 666: // relop -> tkIn + case 671: // relop -> tkIn { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 667: // simple_expr -> term + case 672: // simple_expr -> term { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 668: // simple_expr -> simple_expr, addop, term + case 673: // simple_expr -> simple_expr, addop, term { CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, ValueStack[ValueStack.Depth-2].op.type, CurrentLocationSpan); } break; - case 669: // addop -> tkPlus + case 674: // addop -> tkPlus { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 670: // addop -> tkMinus + case 675: // addop -> tkMinus { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 671: // addop -> tkOr + case 676: // addop -> tkOr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 672: // addop -> tkXor + case 677: // addop -> tkXor { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 673: // addop -> tkCSharpStyleOr + case 678: // addop -> tkCSharpStyleOr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 674: // typecast_op -> tkAs + case 679: // typecast_op -> tkAs { CurrentSemanticValue.ob = op_typecast.as_op; } break; - case 675: // typecast_op -> tkIs + case 680: // typecast_op -> tkIs { CurrentSemanticValue.ob = op_typecast.is_op; } break; - case 676: // as_is_expr -> is_type_expr + case 681: // as_is_expr -> is_type_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 677: // as_is_expr -> as_expr + case 682: // as_is_expr -> as_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 678: // as_expr -> term, tkAs, simple_or_template_type_reference + case 683: // as_expr -> term, tkAs, simple_or_template_type_reference { CurrentSemanticValue.ex = NewAsIsExpr(ValueStack[ValueStack.Depth-3].ex, op_typecast.as_op, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); } break; - case 679: // is_type_expr -> term, tkIs, simple_or_template_type_reference + case 684: // is_type_expr -> term, tkIs, simple_or_template_type_reference { CurrentSemanticValue.ex = NewAsIsExpr(ValueStack[ValueStack.Depth-3].ex, op_typecast.is_op, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); } break; - case 680: // simple_term -> factor + case 685: // simple_term -> factor { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 681: // power_expr -> simple_term, tkStarStar, factor + case 686: // power_expr -> simple_term, tkStarStar, factor { CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,(ValueStack[ValueStack.Depth-2].op).type, CurrentLocationSpan); } break; - case 682: // term -> factor + case 687: // term -> factor { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 683: // term -> new_expr + case 688: // term -> new_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 684: // term -> power_expr + case 689: // term -> power_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 685: // term -> term, mulop, factor + case 690: // term -> term, mulop, factor { CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,(ValueStack[ValueStack.Depth-2].op).type, CurrentLocationSpan); } break; - case 686: // term -> term, mulop, power_expr + case 691: // term -> term, mulop, power_expr { CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,(ValueStack[ValueStack.Depth-2].op).type, CurrentLocationSpan); } break; - case 687: // term -> as_is_expr + case 692: // term -> as_is_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 688: // mulop -> tkStar + case 693: // mulop -> tkStar { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 689: // mulop -> tkSlash + case 694: // mulop -> tkSlash { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 690: // mulop -> tkDiv + case 695: // mulop -> tkDiv { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 691: // mulop -> tkMod + case 696: // mulop -> tkMod { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 692: // mulop -> tkShl + case 697: // mulop -> tkShl { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 693: // mulop -> tkShr + case 698: // mulop -> tkShr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 694: // mulop -> tkAnd + case 699: // mulop -> tkAnd { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 695: // default_expr -> tkDefault, tkRoundOpen, simple_or_template_type_reference, + case 700: // default_expr -> tkDefault, tkRoundOpen, simple_or_template_type_reference, // tkRoundClose { CurrentSemanticValue.ex = new default_operator(ValueStack[ValueStack.Depth-2].td as named_type_reference, CurrentLocationSpan); } break; - case 696: // tuple -> tkRoundOpen, expr_l1, tkComma, expr_l1_list, lambda_type_ref, + case 701: // tuple -> tkRoundOpen, expr_l1, tkComma, expr_l1_list, lambda_type_ref, // optional_full_lambda_fp_list, tkRoundClose { /*if ($5 != null) @@ -5977,29 +6007,29 @@ public partial class GPPGParser: ShiftReduceParser tkNil + case 702: // factor -> tkNil { CurrentSemanticValue.ex = new nil_const(); CurrentSemanticValue.ex.source_context = CurrentLocationSpan; } break; - case 698: // factor -> literal_or_number + case 703: // factor -> literal_or_number { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 699: // factor -> default_expr + case 704: // factor -> default_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 700: // factor -> tkSquareOpen, elem_list, tkSquareClose + case 705: // factor -> tkSquareOpen, elem_list, tkSquareClose { CurrentSemanticValue.ex = new pascal_set_constant(ValueStack[ValueStack.Depth-2].stn as expression_list, CurrentLocationSpan); } break; - case 701: // factor -> tkNot, factor + case 706: // factor -> tkNot, factor { CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth-1].ex, ValueStack[ValueStack.Depth-2].op.type, CurrentLocationSpan); } break; - case 702: // factor -> sign, factor + case 707: // factor -> sign, factor { if (ValueStack[ValueStack.Depth-2].op.type == Operators.Minus) { @@ -6026,91 +6056,91 @@ public partial class GPPGParser: ShiftReduceParser var_reference + case 708: // factor -> var_reference { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 704: // factor -> tuple + case 709: // factor -> tuple { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 705: // literal_or_number -> literal + case 710: // literal_or_number -> literal { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 706: // literal_or_number -> unsigned_number + case 711: // literal_or_number -> unsigned_number { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 707: // var_question_point -> variable, tkQuestionPoint, variable + case 712: // var_question_point -> variable, tkQuestionPoint, variable { CurrentSemanticValue.ex = new dot_question_node(ValueStack[ValueStack.Depth-3].ex as addressed_value,ValueStack[ValueStack.Depth-1].ex as addressed_value,CurrentLocationSpan); } break; - case 708: // var_question_point -> variable, tkQuestionPoint, var_question_point + case 713: // var_question_point -> variable, tkQuestionPoint, var_question_point { CurrentSemanticValue.ex = new dot_question_node(ValueStack[ValueStack.Depth-3].ex as addressed_value,ValueStack[ValueStack.Depth-1].ex as addressed_value,CurrentLocationSpan); } break; - case 709: // var_reference -> var_address, variable + case 714: // var_reference -> var_address, variable { CurrentSemanticValue.ex = NewVarReference(ValueStack[ValueStack.Depth-2].stn as get_address, ValueStack[ValueStack.Depth-1].ex as addressed_value, CurrentLocationSpan); } break; - case 710: // var_reference -> variable + case 715: // var_reference -> variable { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 711: // var_reference -> var_question_point + case 716: // var_reference -> var_question_point { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 712: // var_address -> tkAddressOf + case 717: // var_address -> tkAddressOf { CurrentSemanticValue.stn = NewVarAddress(CurrentLocationSpan); } break; - case 713: // var_address -> var_address, tkAddressOf + case 718: // var_address -> var_address, tkAddressOf { CurrentSemanticValue.stn = NewVarAddress(ValueStack[ValueStack.Depth-2].stn as get_address, CurrentLocationSpan); } break; - case 714: // attribute_variable -> simple_type_identifier, optional_expr_list_with_bracket + case 719: // attribute_variable -> simple_type_identifier, optional_expr_list_with_bracket { CurrentSemanticValue.stn = new attribute(null, ValueStack[ValueStack.Depth-2].td as named_type_reference, ValueStack[ValueStack.Depth-1].stn as expression_list, CurrentLocationSpan); } break; - case 715: // attribute_variable -> template_type, optional_expr_list_with_bracket + case 720: // attribute_variable -> template_type, optional_expr_list_with_bracket { CurrentSemanticValue.stn = new attribute(null, ValueStack[ValueStack.Depth-2].td as named_type_reference, ValueStack[ValueStack.Depth-1].stn as expression_list, CurrentLocationSpan); } break; - case 716: // dotted_identifier -> identifier + case 721: // dotted_identifier -> identifier { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].id; } break; - case 717: // dotted_identifier -> dotted_identifier, tkPoint, identifier_or_keyword + case 722: // dotted_identifier -> dotted_identifier, tkPoint, identifier_or_keyword { CurrentSemanticValue.ex = new dot_node(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].id as addressed_value, CurrentLocationSpan); } break; - case 718: // variable_as_type -> dotted_identifier + case 723: // variable_as_type -> dotted_identifier { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex;} break; - case 719: // variable_as_type -> dotted_identifier, template_type_params + case 724: // variable_as_type -> dotted_identifier, template_type_params { CurrentSemanticValue.ex = new ident_with_templateparams(ValueStack[ValueStack.Depth-2].ex as addressed_value, ValueStack[ValueStack.Depth-1].stn as template_param_list, CurrentLocationSpan); } break; - case 720: // variable_or_literal_or_number -> variable + case 725: // variable_or_literal_or_number -> variable { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 721: // variable_or_literal_or_number -> literal_or_number + case 726: // variable_or_literal_or_number -> literal_or_number { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 722: // variable -> identifier + case 727: // variable -> identifier { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].id; } break; - case 723: // variable -> operator_name_ident + case 728: // variable -> operator_name_ident { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 724: // variable -> tkInherited, identifier + case 729: // variable -> tkInherited, identifier { CurrentSemanticValue.ex = new inherited_ident(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 725: // variable -> tkRoundOpen, expr, tkRoundClose + case 730: // variable -> tkRoundOpen, expr, tkRoundClose { if (!parsertools.build_tree_for_formatter) { @@ -6120,18 +6150,18 @@ public partial class GPPGParser: ShiftReduceParser sizeof_expr + case 731: // variable -> sizeof_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 727: // variable -> typeof_expr + case 732: // variable -> typeof_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 728: // variable -> literal_or_number, tkPoint, identifier_or_keyword + case 733: // variable -> literal_or_number, tkPoint, identifier_or_keyword { CurrentSemanticValue.ex = new dot_node(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].id as addressed_value, CurrentLocationSpan); } break; - case 729: // variable -> variable_or_literal_or_number, tkSquareOpen, expr_list, + case 734: // variable -> variable_or_literal_or_number, tkSquareOpen, expr_list, // tkSquareClose { var el = ValueStack[ValueStack.Depth-2].stn as expression_list; // SSM 10/03/16 @@ -6150,7 +6180,7 @@ public partial class GPPGParser: ShiftReduceParser variable, tkQuestionSquareOpen, format_expr, tkSquareClose + case 735: // variable -> variable, tkQuestionSquareOpen, format_expr, tkSquareClose { var fe = ValueStack[ValueStack.Depth-2].ex as format_expr; // SSM 9/01/17 if (!parsertools.build_tree_for_formatter) @@ -6163,71 +6193,71 @@ public partial class GPPGParser: ShiftReduceParser variable, tkRoundOpen, optional_expr_list, tkRoundClose + case 736: // variable -> variable, tkRoundOpen, optional_expr_list, tkRoundClose { CurrentSemanticValue.ex = new method_call(ValueStack[ValueStack.Depth-4].ex as addressed_value,ValueStack[ValueStack.Depth-2].stn as expression_list, CurrentLocationSpan); } break; - case 732: // variable -> variable, tkPoint, identifier_keyword_operatorname + case 737: // variable -> variable, tkPoint, identifier_keyword_operatorname { CurrentSemanticValue.ex = new dot_node(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].id as addressed_value, CurrentLocationSpan); } break; - case 733: // variable -> tuple, tkPoint, identifier_keyword_operatorname + case 738: // variable -> tuple, tkPoint, identifier_keyword_operatorname { CurrentSemanticValue.ex = new dot_node(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].id as addressed_value, CurrentLocationSpan); } break; - case 734: // variable -> variable, tkDeref + case 739: // variable -> variable, tkDeref { CurrentSemanticValue.ex = new roof_dereference(ValueStack[ValueStack.Depth-2].ex as addressed_value,CurrentLocationSpan); } break; - case 735: // variable -> variable, tkAmpersend, template_type_params + case 740: // variable -> variable, tkAmpersend, template_type_params { CurrentSemanticValue.ex = new ident_with_templateparams(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].stn as template_param_list, CurrentLocationSpan); } break; - case 736: // optional_expr_list -> expr_list + case 741: // optional_expr_list -> expr_list { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 737: // optional_expr_list -> /* empty */ + case 742: // optional_expr_list -> /* empty */ { CurrentSemanticValue.stn = null; } break; - case 738: // elem_list -> elem_list1 + case 743: // elem_list -> elem_list1 { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 739: // elem_list -> /* empty */ + case 744: // elem_list -> /* empty */ { CurrentSemanticValue.stn = null; } break; - case 740: // elem_list1 -> elem + case 745: // elem_list1 -> elem { CurrentSemanticValue.stn = new expression_list(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 741: // elem_list1 -> elem_list1, tkComma, elem + case 746: // elem_list1 -> elem_list1, tkComma, elem { CurrentSemanticValue.stn = (ValueStack[ValueStack.Depth-3].stn as expression_list).Add(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 742: // elem -> expr + case 747: // elem -> expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 743: // elem -> expr, tkDotDot, expr + case 748: // elem -> expr, tkDotDot, expr { CurrentSemanticValue.ex = new diapason_expr(ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 744: // one_literal -> tkStringLiteral + case 749: // one_literal -> tkStringLiteral { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].stn as literal; } break; - case 745: // one_literal -> tkAsciiChar + case 750: // one_literal -> tkAsciiChar { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].stn as literal; } break; - case 746: // literal -> literal_list + case 751: // literal -> literal_list { CurrentSemanticValue.ex = NewLiteral(ValueStack[ValueStack.Depth-1].stn as literal_const_line); } break; - case 747: // literal -> tkFormatStringLiteral + case 752: // literal -> tkFormatStringLiteral { if (parsertools.build_tree_for_formatter) { @@ -6239,12 +6269,12 @@ public partial class GPPGParser: ShiftReduceParser one_literal + case 753: // literal_list -> one_literal { CurrentSemanticValue.stn = new literal_const_line(ValueStack[ValueStack.Depth-1].ex as literal, CurrentLocationSpan); } break; - case 749: // literal_list -> literal_list, one_literal + case 754: // literal_list -> literal_list, one_literal { var line = ValueStack[ValueStack.Depth-2].stn as literal_const_line; if (line.literals.Last() is string_const && ValueStack[ValueStack.Depth-1].ex is string_const) @@ -6252,446 +6282,446 @@ public partial class GPPGParser: ShiftReduceParser tkOperator, overload_operator + case 755: // operator_name_ident -> tkOperator, overload_operator { CurrentSemanticValue.ex = new operator_name_ident((ValueStack[ValueStack.Depth-1].op as op_type_node).text, (ValueStack[ValueStack.Depth-1].op as op_type_node).type, CurrentLocationSpan); } break; - case 751: // optional_method_modificators -> tkSemiColon + case 756: // optional_method_modificators -> tkSemiColon { CurrentSemanticValue.stn = new procedure_attributes_list(new List(),CurrentLocationSpan); } break; - case 752: // optional_method_modificators -> tkSemiColon, meth_modificators, tkSemiColon + case 757: // optional_method_modificators -> tkSemiColon, meth_modificators, tkSemiColon { //parsertools.AddModifier((procedure_attributes_list)$2, proc_attribute.attr_overload); CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-2].stn; } break; - case 753: // optional_method_modificators1 -> /* empty */ + case 758: // optional_method_modificators1 -> /* empty */ { CurrentSemanticValue.stn = new procedure_attributes_list(new List(),CurrentLocationSpan); } break; - case 754: // optional_method_modificators1 -> tkSemiColon, meth_modificators + case 759: // optional_method_modificators1 -> tkSemiColon, meth_modificators { //parsertools.AddModifier((procedure_attributes_list)$2, proc_attribute.attr_overload); CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 755: // meth_modificators -> meth_modificator + case 760: // meth_modificators -> meth_modificator { CurrentSemanticValue.stn = new procedure_attributes_list(ValueStack[ValueStack.Depth-1].id as procedure_attribute, CurrentLocationSpan); } break; - case 756: // meth_modificators -> meth_modificators, tkSemiColon, meth_modificator + case 761: // meth_modificators -> meth_modificators, tkSemiColon, meth_modificator { CurrentSemanticValue.stn = (ValueStack[ValueStack.Depth-3].stn as procedure_attributes_list).Add(ValueStack[ValueStack.Depth-1].id as procedure_attribute, CurrentLocationSpan); } break; - case 757: // identifier -> tkIdentifier + case 762: // identifier -> tkIdentifier { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 758: // identifier -> property_specifier_directives + case 763: // identifier -> property_specifier_directives { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 759: // identifier -> non_reserved + case 764: // identifier -> non_reserved { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 760: // identifier_or_keyword -> identifier + case 765: // identifier_or_keyword -> identifier { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 761: // identifier_or_keyword -> keyword + case 766: // identifier_or_keyword -> keyword { CurrentSemanticValue.id = new ident(ValueStack[ValueStack.Depth-1].ti.text, CurrentLocationSpan); } break; - case 762: // identifier_or_keyword -> reserved_keyword + case 767: // identifier_or_keyword -> reserved_keyword { CurrentSemanticValue.id = new ident(ValueStack[ValueStack.Depth-1].ti.text, CurrentLocationSpan); } break; - case 763: // identifier_keyword_operatorname -> identifier + case 768: // identifier_keyword_operatorname -> identifier { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 764: // identifier_keyword_operatorname -> keyword + case 769: // identifier_keyword_operatorname -> keyword { CurrentSemanticValue.id = new ident(ValueStack[ValueStack.Depth-1].ti.text, CurrentLocationSpan); } break; - case 765: // identifier_keyword_operatorname -> operator_name_ident + case 770: // identifier_keyword_operatorname -> operator_name_ident { CurrentSemanticValue.id = (ident)ValueStack[ValueStack.Depth-1].ex; } break; - case 766: // meth_modificator -> tkAbstract + case 771: // meth_modificator -> tkAbstract { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 767: // meth_modificator -> tkOverload + case 772: // meth_modificator -> tkOverload { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; parsertools.AddWarningFromResource("OVERLOAD_IS_NOT_USED", ValueStack[ValueStack.Depth-1].id.source_context); } break; - case 768: // meth_modificator -> tkReintroduce + case 773: // meth_modificator -> tkReintroduce { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 769: // meth_modificator -> tkOverride + case 774: // meth_modificator -> tkOverride { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 770: // meth_modificator -> tkExtensionMethod + case 775: // meth_modificator -> tkExtensionMethod { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 771: // meth_modificator -> tkVirtual + case 776: // meth_modificator -> tkVirtual { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 772: // property_modificator -> tkVirtual + case 777: // property_modificator -> tkVirtual { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 773: // property_modificator -> tkOverride + case 778: // property_modificator -> tkOverride { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 774: // property_modificator -> tkAbstract + case 779: // property_modificator -> tkAbstract { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 775: // property_specifier_directives -> tkRead + case 780: // property_specifier_directives -> tkRead { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 776: // property_specifier_directives -> tkWrite + case 781: // property_specifier_directives -> tkWrite { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 777: // non_reserved -> tkName + case 782: // non_reserved -> tkName { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 778: // non_reserved -> tkNew + case 783: // non_reserved -> tkNew { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 779: // visibility_specifier -> tkInternal + case 784: // visibility_specifier -> tkInternal { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 780: // visibility_specifier -> tkPublic + case 785: // visibility_specifier -> tkPublic { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 781: // visibility_specifier -> tkProtected + case 786: // visibility_specifier -> tkProtected { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 782: // visibility_specifier -> tkPrivate + case 787: // visibility_specifier -> tkPrivate { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 783: // keyword -> visibility_specifier + case 788: // keyword -> visibility_specifier { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 784: // keyword -> tkSealed + case 789: // keyword -> tkSealed { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 785: // keyword -> tkTemplate + case 790: // keyword -> tkTemplate { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 786: // keyword -> tkOr + case 791: // keyword -> tkOr { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 787: // keyword -> tkTypeOf + case 792: // keyword -> tkTypeOf { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 788: // keyword -> tkSizeOf + case 793: // keyword -> tkSizeOf { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 789: // keyword -> tkDefault + case 794: // keyword -> tkDefault { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 790: // keyword -> tkWhere + case 795: // keyword -> tkWhere { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 791: // keyword -> tkXor + case 796: // keyword -> tkXor { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 792: // keyword -> tkAnd + case 797: // keyword -> tkAnd { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 793: // keyword -> tkDiv + case 798: // keyword -> tkDiv { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 794: // keyword -> tkMod + case 799: // keyword -> tkMod { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 795: // keyword -> tkShl + case 800: // keyword -> tkShl { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 796: // keyword -> tkShr + case 801: // keyword -> tkShr { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 797: // keyword -> tkNot + case 802: // keyword -> tkNot { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 798: // keyword -> tkAs + case 803: // keyword -> tkAs { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 799: // keyword -> tkIn + case 804: // keyword -> tkIn { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 800: // keyword -> tkIs + case 805: // keyword -> tkIs { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 801: // keyword -> tkArray + case 806: // keyword -> tkArray { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 802: // keyword -> tkSequence + case 807: // keyword -> tkSequence { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 803: // keyword -> tkBegin + case 808: // keyword -> tkBegin { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 804: // keyword -> tkCase + case 809: // keyword -> tkCase { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 805: // keyword -> tkClass + case 810: // keyword -> tkClass { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 806: // keyword -> tkConst + case 811: // keyword -> tkConst { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 807: // keyword -> tkConstructor + case 812: // keyword -> tkConstructor { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 808: // keyword -> tkDestructor + case 813: // keyword -> tkDestructor { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 809: // keyword -> tkDownto + case 814: // keyword -> tkDownto { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 810: // keyword -> tkDo + case 815: // keyword -> tkDo { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 811: // keyword -> tkElse + case 816: // keyword -> tkElse { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 812: // keyword -> tkExcept + case 817: // keyword -> tkExcept { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 813: // keyword -> tkFile + case 818: // keyword -> tkFile { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 814: // keyword -> tkAuto + case 819: // keyword -> tkAuto { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 815: // keyword -> tkFinalization + case 820: // keyword -> tkFinalization { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 816: // keyword -> tkFinally + case 821: // keyword -> tkFinally { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 817: // keyword -> tkFor + case 822: // keyword -> tkFor { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 818: // keyword -> tkForeach + case 823: // keyword -> tkForeach { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 819: // keyword -> tkFunction + case 824: // keyword -> tkFunction { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 820: // keyword -> tkIf + case 825: // keyword -> tkIf { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 821: // keyword -> tkImplementation + case 826: // keyword -> tkImplementation { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 822: // keyword -> tkInherited + case 827: // keyword -> tkInherited { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 823: // keyword -> tkInitialization + case 828: // keyword -> tkInitialization { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 824: // keyword -> tkInterface + case 829: // keyword -> tkInterface { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 825: // keyword -> tkProcedure + case 830: // keyword -> tkProcedure { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 826: // keyword -> tkProperty + case 831: // keyword -> tkProperty { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 827: // keyword -> tkRaise + case 832: // keyword -> tkRaise { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 828: // keyword -> tkRecord + case 833: // keyword -> tkRecord { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 829: // keyword -> tkRepeat + case 834: // keyword -> tkRepeat { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 830: // keyword -> tkSet + case 835: // keyword -> tkSet { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 831: // keyword -> tkTry + case 836: // keyword -> tkTry { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 832: // keyword -> tkType + case 837: // keyword -> tkType { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 833: // keyword -> tkStatic + case 838: // keyword -> tkStatic { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 834: // keyword -> tkThen + case 839: // keyword -> tkThen { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 835: // keyword -> tkTo + case 840: // keyword -> tkTo { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 836: // keyword -> tkUntil + case 841: // keyword -> tkUntil { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 837: // keyword -> tkUses + case 842: // keyword -> tkUses { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 838: // keyword -> tkVar + case 843: // keyword -> tkVar { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 839: // keyword -> tkWhile + case 844: // keyword -> tkWhile { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 840: // keyword -> tkWith + case 845: // keyword -> tkWith { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 841: // keyword -> tkNil + case 846: // keyword -> tkNil { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 842: // keyword -> tkGoto + case 847: // keyword -> tkGoto { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 843: // keyword -> tkOf + case 848: // keyword -> tkOf { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 844: // keyword -> tkLabel + case 849: // keyword -> tkLabel { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 845: // keyword -> tkProgram + case 850: // keyword -> tkProgram { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 846: // keyword -> tkUnit + case 851: // keyword -> tkUnit { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 847: // keyword -> tkLibrary + case 852: // keyword -> tkLibrary { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 848: // keyword -> tkNamespace + case 853: // keyword -> tkNamespace { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 849: // keyword -> tkExternal + case 854: // keyword -> tkExternal { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 850: // keyword -> tkParams + case 855: // keyword -> tkParams { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 851: // keyword -> tkEvent + case 856: // keyword -> tkEvent { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 852: // keyword -> tkYield + case 857: // keyword -> tkYield { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 853: // keyword -> tkMatch + case 858: // keyword -> tkMatch { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 854: // keyword -> tkWhen + case 859: // keyword -> tkWhen { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 855: // reserved_keyword -> tkOperator + case 860: // reserved_keyword -> tkOperator { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 856: // reserved_keyword -> tkEnd + case 861: // reserved_keyword -> tkEnd { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 857: // overload_operator -> tkMinus + case 862: // overload_operator -> tkMinus { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 858: // overload_operator -> tkPlus + case 863: // overload_operator -> tkPlus { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 859: // overload_operator -> tkSlash + case 864: // overload_operator -> tkSlash { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 860: // overload_operator -> tkStar + case 865: // overload_operator -> tkStar { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 861: // overload_operator -> tkEqual + case 866: // overload_operator -> tkEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 862: // overload_operator -> tkGreater + case 867: // overload_operator -> tkGreater { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 863: // overload_operator -> tkGreaterEqual + case 868: // overload_operator -> tkGreaterEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 864: // overload_operator -> tkLower + case 869: // overload_operator -> tkLower { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 865: // overload_operator -> tkLowerEqual + case 870: // overload_operator -> tkLowerEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 866: // overload_operator -> tkNotEqual + case 871: // overload_operator -> tkNotEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 867: // overload_operator -> tkOr + case 872: // overload_operator -> tkOr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 868: // overload_operator -> tkXor + case 873: // overload_operator -> tkXor { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 869: // overload_operator -> tkAnd + case 874: // overload_operator -> tkAnd { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 870: // overload_operator -> tkDiv + case 875: // overload_operator -> tkDiv { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 871: // overload_operator -> tkMod + case 876: // overload_operator -> tkMod { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 872: // overload_operator -> tkShl + case 877: // overload_operator -> tkShl { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 873: // overload_operator -> tkShr + case 878: // overload_operator -> tkShr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 874: // overload_operator -> tkNot + case 879: // overload_operator -> tkNot { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 875: // overload_operator -> tkIn + case 880: // overload_operator -> tkIn { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 876: // overload_operator -> tkImplicit + case 881: // overload_operator -> tkImplicit { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 877: // overload_operator -> tkExplicit + case 882: // overload_operator -> tkExplicit { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 878: // overload_operator -> assign_operator + case 883: // overload_operator -> assign_operator { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 879: // overload_operator -> tkStarStar + case 884: // overload_operator -> tkStarStar { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 880: // assign_operator -> tkAssign + case 885: // assign_operator -> tkAssign { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 881: // assign_operator -> tkPlusEqual + case 886: // assign_operator -> tkPlusEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 882: // assign_operator -> tkMinusEqual + case 887: // assign_operator -> tkMinusEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 883: // assign_operator -> tkMultEqual + case 888: // assign_operator -> tkMultEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 884: // assign_operator -> tkDivEqual + case 889: // assign_operator -> tkDivEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 885: // func_decl_lambda -> identifier, tkArrow, lambda_function_body + case 890: // func_decl_lambda -> identifier, tkArrow, lambda_function_body { var idList = new ident_list(ValueStack[ValueStack.Depth-3].id, LocationStack[LocationStack.Depth-3]); var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]); CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan); } break; - case 886: // func_decl_lambda -> tkRoundOpen, tkRoundClose, lambda_type_ref_noproctype, + case 891: // func_decl_lambda -> tkRoundOpen, tkRoundClose, lambda_type_ref_noproctype, // tkArrow, lambda_function_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null, ValueStack[ValueStack.Depth-3].td, ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan); } break; - case 887: // func_decl_lambda -> tkRoundOpen, identifier, tkColon, fptype, tkRoundClose, + case 892: // func_decl_lambda -> tkRoundOpen, identifier, tkColon, fptype, tkRoundClose, // lambda_type_ref_noproctype, tkArrow, lambda_function_body { var idList = new ident_list(ValueStack[ValueStack.Depth-7].id, LocationStack[LocationStack.Depth-7]); @@ -6700,7 +6730,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, identifier, tkSemiColon, full_lambda_fp_list, + case 893: // func_decl_lambda -> tkRoundOpen, identifier, tkSemiColon, full_lambda_fp_list, // tkRoundClose, lambda_type_ref_noproctype, tkArrow, // lambda_function_body { @@ -6711,7 +6741,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, identifier, tkColon, fptype, tkSemiColon, + case 894: // func_decl_lambda -> tkRoundOpen, identifier, tkColon, fptype, tkSemiColon, // full_lambda_fp_list, tkRoundClose, // lambda_type_ref_noproctype, tkArrow, lambda_function_body { @@ -6723,7 +6753,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, expr_l1, tkComma, expr_l1_list, + case 895: // func_decl_lambda -> tkRoundOpen, expr_l1, tkComma, expr_l1_list, // lambda_type_ref, optional_full_lambda_fp_list, // tkRoundClose, rem_lambda { @@ -6785,61 +6815,61 @@ public partial class GPPGParser: ShiftReduceParser expl_func_decl_lambda + case 896: // func_decl_lambda -> expl_func_decl_lambda { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 892: // optional_full_lambda_fp_list -> /* empty */ + case 897: // optional_full_lambda_fp_list -> /* empty */ { CurrentSemanticValue.stn = null; } break; - case 893: // optional_full_lambda_fp_list -> tkSemiColon, full_lambda_fp_list + case 898: // optional_full_lambda_fp_list -> tkSemiColon, full_lambda_fp_list { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 894: // rem_lambda -> lambda_type_ref_noproctype, tkArrow, lambda_function_body + case 899: // rem_lambda -> lambda_type_ref_noproctype, tkArrow, lambda_function_body { CurrentSemanticValue.ob = new pair_type_stlist(ValueStack[ValueStack.Depth-3].td,ValueStack[ValueStack.Depth-1].stn as statement_list); } break; - case 895: // expl_func_decl_lambda -> tkFunction, lambda_type_ref, tkArrow, + case 900: // expl_func_decl_lambda -> tkFunction, lambda_type_ref, tkArrow, // lambda_function_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null, ValueStack[ValueStack.Depth-3].td, ValueStack[ValueStack.Depth-1].stn as statement_list, 1, CurrentLocationSpan); } break; - case 896: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, tkRoundClose, lambda_type_ref, + case 901: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, tkRoundClose, lambda_type_ref, // tkArrow, lambda_function_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null, ValueStack[ValueStack.Depth-3].td, ValueStack[ValueStack.Depth-1].stn as statement_list, 1, CurrentLocationSpan); } break; - case 897: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, full_lambda_fp_list, + case 902: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, full_lambda_fp_list, // tkRoundClose, lambda_type_ref, tkArrow, // lambda_function_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), ValueStack[ValueStack.Depth-5].stn as formal_parameters, ValueStack[ValueStack.Depth-3].td, ValueStack[ValueStack.Depth-1].stn as statement_list, 1, CurrentLocationSpan); } break; - case 898: // expl_func_decl_lambda -> tkProcedure, tkArrow, lambda_procedure_body + case 903: // expl_func_decl_lambda -> tkProcedure, tkArrow, lambda_procedure_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null, null, ValueStack[ValueStack.Depth-1].stn as statement_list, 2, CurrentLocationSpan); } break; - case 899: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, tkRoundClose, tkArrow, + case 904: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, tkRoundClose, tkArrow, // lambda_procedure_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null, null, ValueStack[ValueStack.Depth-1].stn as statement_list, 2, CurrentLocationSpan); } break; - case 900: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, full_lambda_fp_list, + case 905: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, full_lambda_fp_list, // tkRoundClose, tkArrow, lambda_procedure_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), ValueStack[ValueStack.Depth-4].stn as formal_parameters, null, ValueStack[ValueStack.Depth-1].stn as statement_list, 2, CurrentLocationSpan); } break; - case 901: // full_lambda_fp_list -> lambda_simple_fp_sect + case 906: // full_lambda_fp_list -> lambda_simple_fp_sect { var typed_pars = ValueStack[ValueStack.Depth-1].stn as typed_parameters; if (typed_pars.vars_type is lambda_inferred_type) @@ -6859,97 +6889,97 @@ public partial class GPPGParser: ShiftReduceParser full_lambda_fp_list, tkSemiColon, lambda_simple_fp_sect + case 907: // full_lambda_fp_list -> full_lambda_fp_list, tkSemiColon, lambda_simple_fp_sect { CurrentSemanticValue.stn =(ValueStack[ValueStack.Depth-3].stn as formal_parameters).Add(ValueStack[ValueStack.Depth-1].stn as typed_parameters, CurrentLocationSpan); } break; - case 903: // lambda_simple_fp_sect -> ident_list, lambda_type_ref + case 908: // lambda_simple_fp_sect -> ident_list, lambda_type_ref { CurrentSemanticValue.stn = new typed_parameters(ValueStack[ValueStack.Depth-2].stn as ident_list, ValueStack[ValueStack.Depth-1].td, parametr_kind.none, null, CurrentLocationSpan); } break; - case 904: // lambda_type_ref -> /* empty */ + case 909: // lambda_type_ref -> /* empty */ { CurrentSemanticValue.td = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null); } break; - case 905: // lambda_type_ref -> tkColon, fptype + case 910: // lambda_type_ref -> tkColon, fptype { CurrentSemanticValue.td = ValueStack[ValueStack.Depth-1].td; } break; - case 906: // lambda_type_ref_noproctype -> /* empty */ + case 911: // lambda_type_ref_noproctype -> /* empty */ { CurrentSemanticValue.td = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null); } break; - case 907: // lambda_type_ref_noproctype -> tkColon, fptype_noproctype + case 912: // lambda_type_ref_noproctype -> tkColon, fptype_noproctype { CurrentSemanticValue.td = ValueStack[ValueStack.Depth-1].td; } break; - case 908: // common_lambda_body -> compound_stmt + case 913: // common_lambda_body -> compound_stmt { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 909: // common_lambda_body -> if_stmt + case 914: // common_lambda_body -> if_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 910: // common_lambda_body -> while_stmt + case 915: // common_lambda_body -> while_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 911: // common_lambda_body -> repeat_stmt + case 916: // common_lambda_body -> repeat_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 912: // common_lambda_body -> for_stmt + case 917: // common_lambda_body -> for_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 913: // common_lambda_body -> foreach_stmt + case 918: // common_lambda_body -> foreach_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 914: // common_lambda_body -> loop_stmt + case 919: // common_lambda_body -> loop_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 915: // common_lambda_body -> case_stmt + case 920: // common_lambda_body -> case_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 916: // common_lambda_body -> try_stmt + case 921: // common_lambda_body -> try_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 917: // common_lambda_body -> lock_stmt + case 922: // common_lambda_body -> lock_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 918: // common_lambda_body -> yield_stmt + case 923: // common_lambda_body -> yield_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 919: // common_lambda_body -> raise_stmt + case 924: // common_lambda_body -> raise_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 920: // lambda_function_body -> expr_l1 + case 925: // lambda_function_body -> expr_l1 { var id = SyntaxVisitors.ExprHasNameVisitor.HasName(ValueStack[ValueStack.Depth-1].ex, "Result"); if (id != null) @@ -6961,22 +6991,22 @@ public partial class GPPGParser: ShiftReduceParser common_lambda_body + case 926: // lambda_function_body -> common_lambda_body { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 922: // lambda_procedure_body -> proc_call + case 927: // lambda_procedure_body -> proc_call { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 923: // lambda_procedure_body -> assignment + case 928: // lambda_procedure_body -> assignment { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 924: // lambda_procedure_body -> common_lambda_body + case 929: // lambda_procedure_body -> common_lambda_body { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } diff --git a/SyntaxTree/tree/AbstractVisitor.cs b/SyntaxTree/tree/AbstractVisitor.cs index 72f078c4a..de699e371 100644 --- a/SyntaxTree/tree/AbstractVisitor.cs +++ b/SyntaxTree/tree/AbstractVisitor.cs @@ -1217,6 +1217,16 @@ namespace PascalABCCompiler.SyntaxTree { DefaultVisit(_collection_pattern_gap_parameter); } + + public virtual void visit(collection_pattern_wild_card _collection_pattern_wild_card) + { + DefaultVisit(_collection_pattern_wild_card); + } + + public virtual void visit(collection_pattern_var_parameter _collection_pattern_var_parameter) + { + DefaultVisit(_collection_pattern_var_parameter); + } } diff --git a/SyntaxTree/tree/HierarchyVisitor.cs b/SyntaxTree/tree/HierarchyVisitor.cs index f299e51ac..708620a96 100644 --- a/SyntaxTree/tree/HierarchyVisitor.cs +++ b/SyntaxTree/tree/HierarchyVisitor.cs @@ -1941,6 +1941,22 @@ namespace PascalABCCompiler.SyntaxTree { } + public virtual void pre_do_visit(collection_pattern_wild_card _collection_pattern_wild_card) + { + } + + public virtual void post_do_visit(collection_pattern_wild_card _collection_pattern_wild_card) + { + } + + public virtual void pre_do_visit(collection_pattern_var_parameter _collection_pattern_var_parameter) + { + } + + public virtual void post_do_visit(collection_pattern_var_parameter _collection_pattern_var_parameter) + { + } + public override void visit(expression _expression) { DefaultVisit(_expression); @@ -4014,6 +4030,22 @@ namespace PascalABCCompiler.SyntaxTree pre_do_visit(_collection_pattern_gap_parameter); post_do_visit(_collection_pattern_gap_parameter); } + + public override void visit(collection_pattern_wild_card _collection_pattern_wild_card) + { + DefaultVisit(_collection_pattern_wild_card); + pre_do_visit(_collection_pattern_wild_card); + post_do_visit(_collection_pattern_wild_card); + } + + public override void visit(collection_pattern_var_parameter _collection_pattern_var_parameter) + { + DefaultVisit(_collection_pattern_var_parameter); + pre_do_visit(_collection_pattern_var_parameter); + visit(collection_pattern_var_parameter.identifier); + visit(collection_pattern_var_parameter.type); + post_do_visit(_collection_pattern_var_parameter); + } } diff --git a/SyntaxTree/tree/SyntaxTreeStreamReader.cs b/SyntaxTree/tree/SyntaxTreeStreamReader.cs index f6c17ea1d..d9a832b2c 100644 --- a/SyntaxTree/tree/SyntaxTreeStreamReader.cs +++ b/SyntaxTree/tree/SyntaxTreeStreamReader.cs @@ -504,6 +504,10 @@ namespace PascalABCCompiler.SyntaxTree return new collection_pattern(); case 241: return new collection_pattern_gap_parameter(); + case 242: + return new collection_pattern_wild_card(); + case 243: + return new collection_pattern_var_parameter(); } return null; } @@ -4258,6 +4262,30 @@ namespace PascalABCCompiler.SyntaxTree read_pattern_parameter(_collection_pattern_gap_parameter); } + + public void visit(collection_pattern_wild_card _collection_pattern_wild_card) + { + read_collection_pattern_wild_card(_collection_pattern_wild_card); + } + + public void read_collection_pattern_wild_card(collection_pattern_wild_card _collection_pattern_wild_card) + { + read_pattern_parameter(_collection_pattern_wild_card); + } + + + public void visit(collection_pattern_var_parameter _collection_pattern_var_parameter) + { + read_collection_pattern_var_parameter(_collection_pattern_var_parameter); + } + + public void read_collection_pattern_var_parameter(collection_pattern_var_parameter _collection_pattern_var_parameter) + { + read_pattern_parameter(_collection_pattern_var_parameter); + _collection_pattern_var_parameter.identifier = _read_node() as ident; + _collection_pattern_var_parameter.type = _read_node() as type_definition; + } + } diff --git a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs index af91d80f9..d3bfb488a 100644 --- a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs +++ b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs @@ -6673,6 +6673,48 @@ namespace PascalABCCompiler.SyntaxTree write_pattern_parameter(_collection_pattern_gap_parameter); } + + public void visit(collection_pattern_wild_card _collection_pattern_wild_card) + { + bw.Write((Int16)242); + write_collection_pattern_wild_card(_collection_pattern_wild_card); + } + + public void write_collection_pattern_wild_card(collection_pattern_wild_card _collection_pattern_wild_card) + { + write_pattern_parameter(_collection_pattern_wild_card); + } + + + public void visit(collection_pattern_var_parameter _collection_pattern_var_parameter) + { + bw.Write((Int16)243); + write_collection_pattern_var_parameter(_collection_pattern_var_parameter); + } + + public void write_collection_pattern_var_parameter(collection_pattern_var_parameter _collection_pattern_var_parameter) + { + write_pattern_parameter(_collection_pattern_var_parameter); + if (_collection_pattern_var_parameter.identifier == null) + { + bw.Write((byte)0); + } + else + { + bw.Write((byte)1); + _collection_pattern_var_parameter.identifier.visit(this); + } + if (_collection_pattern_var_parameter.type == null) + { + bw.Write((byte)0); + } + else + { + bw.Write((byte)1); + _collection_pattern_var_parameter.type.visit(this); + } + } + } diff --git a/SyntaxTree/tree/Tree.cs b/SyntaxTree/tree/Tree.cs index 4e209597c..9b3ea7cd9 100644 --- a/SyntaxTree/tree/Tree.cs +++ b/SyntaxTree/tree/Tree.cs @@ -49653,18 +49653,20 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public deconstructor_pattern(type_definition _type) + public deconstructor_pattern(type_definition _type,expression _const_params_check) { this._type=_type; + this._const_params_check=_const_params_check; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// - public deconstructor_pattern(type_definition _type,SourceContext sc) + public deconstructor_pattern(type_definition _type,expression _const_params_check,SourceContext sc) { this._type=_type; + this._const_params_check=_const_params_check; source_context = sc; FillParentsInDirectChilds(); } @@ -49672,20 +49674,22 @@ namespace PascalABCCompiler.SyntaxTree /// ///Конструктор с параметрами. /// - public deconstructor_pattern(List _parameters,type_definition _type) + public deconstructor_pattern(List _parameters,type_definition _type,expression _const_params_check) { this._parameters=_parameters; this._type=_type; + this._const_params_check=_const_params_check; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// - public deconstructor_pattern(List _parameters,type_definition _type,SourceContext sc) + public deconstructor_pattern(List _parameters,type_definition _type,expression _const_params_check,SourceContext sc) { this._parameters=_parameters; this._type=_type; + this._const_params_check=_const_params_check; source_context = sc; FillParentsInDirectChilds(); } @@ -51987,7 +51991,7 @@ namespace PascalABCCompiler.SyntaxTree /// public collection_pattern() { - + } @@ -52219,6 +52223,280 @@ namespace PascalABCCompiler.SyntaxTree } + /// + /// + /// + [Serializable] + public partial class collection_pattern_wild_card : pattern_parameter + { + + /// + ///Конструктор без параметров. + /// + public collection_pattern_wild_card() + { + + } + + /// Создает копию узла + public override syntax_tree_node Clone() + { + collection_pattern_wild_card copy = new collection_pattern_wild_card(); + copy.Parent = this.Parent; + if (source_context != null) + copy.source_context = new SourceContext(source_context); + return copy; + } + + /// Получает копию данного узла корректного типа + public new collection_pattern_wild_card TypedClone() + { + return Clone() as collection_pattern_wild_card; + } + + /// Заполняет поля Parent в непосредственных дочерних узлах + public override void FillParentsInDirectChilds() + { + } + + /// Заполняет поля Parent во всем поддереве + public override void FillParentsInAllChilds() + { + FillParentsInDirectChilds(); + } + + /// + ///Свойство для получения количества всех подузлов без элементов поля типа List + /// + public override Int32 subnodes_without_list_elements_count + { + get + { + return 0; + } + } + /// + ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List + /// + public override Int32 subnodes_count + { + get + { + return 0; + } + } + /// + ///Индексатор для получения всех подузлов + /// + public override syntax_tree_node this[Int32 ind] + { + get + { + if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) + throw new IndexOutOfRangeException(); + return null; + } + set + { + if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) + throw new IndexOutOfRangeException(); + } + } + /// + ///Метод для обхода дерева посетителем + /// + ///Объект-посетитель. + ///Return value is void + public override void visit(IVisitor visitor) + { + visitor.visit(this); + } + + } + + + /// + ///Возможно без типа + /// + [Serializable] + public partial class collection_pattern_var_parameter : pattern_parameter + { + + /// + ///Конструктор без параметров. + /// + public collection_pattern_var_parameter() + { + + } + + /// + ///Конструктор с параметрами. + /// + public collection_pattern_var_parameter(ident _identifier,type_definition _type) + { + this._identifier=_identifier; + this._type=_type; + FillParentsInDirectChilds(); + } + + /// + ///Конструктор с параметрами. + /// + public collection_pattern_var_parameter(ident _identifier,type_definition _type,SourceContext sc) + { + this._identifier=_identifier; + this._type=_type; + source_context = sc; + FillParentsInDirectChilds(); + } + protected ident _identifier; + protected type_definition _type; + + /// + /// + /// + public ident identifier + { + get + { + return _identifier; + } + set + { + _identifier=value; + if (_identifier != null) + _identifier.Parent = this; + } + } + + /// + /// + /// + public type_definition type + { + get + { + return _type; + } + set + { + _type=value; + if (_type != null) + _type.Parent = this; + } + } + + + /// Создает копию узла + public override syntax_tree_node Clone() + { + collection_pattern_var_parameter copy = new collection_pattern_var_parameter(); + copy.Parent = this.Parent; + if (source_context != null) + copy.source_context = new SourceContext(source_context); + if (identifier != null) + { + copy.identifier = (ident)identifier.Clone(); + copy.identifier.Parent = copy; + } + if (type != null) + { + copy.type = (type_definition)type.Clone(); + copy.type.Parent = copy; + } + return copy; + } + + /// Получает копию данного узла корректного типа + public new collection_pattern_var_parameter TypedClone() + { + return Clone() as collection_pattern_var_parameter; + } + + /// Заполняет поля Parent в непосредственных дочерних узлах + public override void FillParentsInDirectChilds() + { + if (identifier != null) + identifier.Parent = this; + if (type != null) + type.Parent = this; + } + + /// Заполняет поля Parent во всем поддереве + public override void FillParentsInAllChilds() + { + FillParentsInDirectChilds(); + identifier?.FillParentsInAllChilds(); + type?.FillParentsInAllChilds(); + } + + /// + ///Свойство для получения количества всех подузлов без элементов поля типа List + /// + public override Int32 subnodes_without_list_elements_count + { + get + { + return 2; + } + } + /// + ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List + /// + public override Int32 subnodes_count + { + get + { + return 2; + } + } + /// + ///Индексатор для получения всех подузлов + /// + public override syntax_tree_node this[Int32 ind] + { + get + { + if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) + throw new IndexOutOfRangeException(); + switch(ind) + { + case 0: + return identifier; + case 1: + return type; + } + return null; + } + set + { + if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) + throw new IndexOutOfRangeException(); + switch(ind) + { + case 0: + identifier = (ident)value; + break; + case 1: + type = (type_definition)value; + break; + } + } + } + /// + ///Метод для обхода дерева посетителем + /// + ///Объект-посетитель. + ///Return value is void + public override void visit(IVisitor visitor) + { + visitor.visit(this); + } + + } + + } diff --git a/SyntaxTree/tree/Visitor.cs b/SyntaxTree/tree/Visitor.cs index dab164012..3011216ab 100644 --- a/SyntaxTree/tree/Visitor.cs +++ b/SyntaxTree/tree/Visitor.cs @@ -1456,6 +1456,18 @@ namespace PascalABCCompiler.SyntaxTree ///Node to visit /// Return value is void void visit(collection_pattern_gap_parameter _collection_pattern_gap_parameter); + /// + ///Method to visit collection_pattern_wild_card. + /// + ///Node to visit + /// Return value is void + void visit(collection_pattern_wild_card _collection_pattern_wild_card); + /// + ///Method to visit collection_pattern_var_parameter. + /// + ///Node to visit + /// Return value is void + void visit(collection_pattern_var_parameter _collection_pattern_var_parameter); } diff --git a/SyntaxTree/tree/tree.xml b/SyntaxTree/tree/tree.xml index c72d050f4..951b01653 100644 --- a/SyntaxTree/tree/tree.xml +++ b/SyntaxTree/tree/tree.xml @@ -3075,8 +3075,12 @@ - - + + 0 + + + 9 + @@ -3129,6 +3133,33 @@ + + + + + + 0 + + + 9 + + + + + + + + + + + + 0 + + + 9 + + + Tree.cs @@ -3154,7 +3185,7 @@ - + @@ -3411,6 +3442,10 @@ + + + + diff --git a/SyntaxVisitors/SugarVisitors/PatternsDesugaringVisitor.cs b/SyntaxVisitors/SugarVisitors/PatternsDesugaringVisitor.cs index 19c4f7d98..93f4d6d7c 100644 --- a/SyntaxVisitors/SugarVisitors/PatternsDesugaringVisitor.cs +++ b/SyntaxVisitors/SugarVisitors/PatternsDesugaringVisitor.cs @@ -60,6 +60,15 @@ namespace SyntaxVisitors.SugarVisitors } } + public class CollectionDesugaringResult + { + public List VarParametersDeclarations { get; set; } = new List(); + + public expression SuccessMatchingCheck { get; set; } + + public List VarParametersAssignments { get; set; } = new List(); + } + public class PatternsDesugaringVisitor : BaseChangeVisitor { private enum PatternLocation { Unknown, IfCondition, Assign } @@ -68,6 +77,7 @@ namespace SyntaxVisitors.SugarVisitors private const string IsTestMethodName = compiler_string_consts.is_test_function_name; private const string WildCardsTupleEqualFunctionName = compiler_string_consts.wild_cards_tuple_equal_function_name; private const string SeqFunctionName = compiler_string_consts.seq_function_name; + private const string CountPropertyName = compiler_string_consts.count_property_name; private const string GeneratedPatternNamePrefix = "<>pattern"; private const string GeneratedDeconstructParamPrefix = "<>deconstructParam"; @@ -252,7 +262,8 @@ namespace SyntaxVisitors.SugarVisitors if (possibleTupleDotNode != null) { var possibleTupleCallString = possibleTupleDotNode.ToString(); - if (possibleTupleCallString.Contains("System.Tuple.Create")) { + if (possibleTupleCallString.Contains("System.Tuple.Create")) + { var elemsToCompare = new List(); for (int currentInd = 0; currentInd < possibleTupleCase.parameters.Count; ++currentInd) { @@ -260,7 +271,8 @@ namespace SyntaxVisitors.SugarVisitors if (!(tupleElem is tuple_wild_card)) { elemsToCompare.Add(currentInd); - } else + } + else { possibleTupleCase.parameters[currentInd] = new int32_const(0, patternCase.source_context); } @@ -325,18 +337,20 @@ namespace SyntaxVisitors.SugarVisitors AddDesugaredCaseToResult(ifCheck, ifCheck); } - private expression GetCollectionItemsEqualCheckBeforeGap(addressed_value matchingExpression, List toCompare) + private expression GetCollectionItemsEqualCheckBeforeGap(addressed_value matchingExpression, + List toCompare, + CollectionDesugaringResult desugaringResult) { var fromIndex = 0; expression equalChecks = null; foreach (var param in toCompare) { - if (param is const_pattern_parameter const_params) + if (param is const_pattern_parameter constParam) { var indexerCall = new indexer( matchingExpression, new expression_list( - new int32_const(fromIndex++, matchingExpression.source_context), + new int32_const(fromIndex, matchingExpression.source_context), matchingExpression.source_context), matchingExpression.source_context); @@ -344,7 +358,7 @@ namespace SyntaxVisitors.SugarVisitors new List() { indexerCall, - const_params.const_param + constParam.const_param } ); @@ -358,19 +372,27 @@ namespace SyntaxVisitors.SugarVisitors equalChecks = equalChecks == null ? (expression)equalCall : bin_expr.LogicalAnd(equalChecks, equalCall); } + + if (param is collection_pattern_var_parameter varParam) + { + desugaringResult.VarParametersDeclarations.Add( + new var_statement(varParam.identifier, + GetIndexerCallForCollectionPattern(matchingExpression as addressed_value, fromIndex))); + } + ++fromIndex; } return equalChecks; } - private expression GetCollectionItemsEqualCheckAfterGap(addressed_value matchingExpression, List toCompare) + private expression GetCollectionItemsEqualCheckAfterGap(addressed_value matchingExpression, + List toCompare, + CollectionDesugaringResult desugaringResult) { var elemFromTail = 1; expression equalChecks = null; foreach (var param in toCompare) { - if (param is const_pattern_parameter const_param) - { - var indexerCall = new indexer( + var indexerCall = new indexer( matchingExpression, new expression_list( new bin_expr( @@ -379,16 +401,18 @@ namespace SyntaxVisitors.SugarVisitors matchingExpression, new ident("Count", matchingExpression.source_context)), new expression_list()), - new int32_const(elemFromTail++, matchingExpression.source_context), + new int32_const(elemFromTail, matchingExpression.source_context), Operators.Minus), matchingExpression.source_context), matchingExpression.source_context); + if (param is const_pattern_parameter constParam) + { var eqParams = new expression_list( new List() { indexerCall, - const_param.const_param + constParam.const_param } ); @@ -402,10 +426,23 @@ namespace SyntaxVisitors.SugarVisitors equalChecks = equalChecks == null ? (expression)equalCall : bin_expr.LogicalAnd(equalChecks, equalCall); } + + if (param is collection_pattern_var_parameter varParam) + { + desugaringResult.VarParametersDeclarations.Add( + new var_statement(varParam.identifier, indexerCall)); + } + ++elemFromTail; } return equalChecks; } + private expression GetIndexerCallForCollectionPattern(addressed_value matchingExpression, int ind) + { + var indexerCall = new indexer(matchingExpression, new int32_const(ind), matchingExpression.source_context); + return indexerCall; + } + private ident NewGeneralName() => new ident(GeneratedPatternNamePrefix + "GenVar" + generalVariableCounter++); private ident NewSuccessName() => new ident(GeneratedPatternNamePrefix + "Success" + successVariableCounter++); @@ -462,10 +499,11 @@ namespace SyntaxVisitors.SugarVisitors return desugarResult; } - private expression DesugarCollectionPattern(collection_pattern pattern, expression matchingExpression) + private CollectionDesugaringResult DesugarCollectionPattern(collection_pattern pattern, expression matchingExpression) { Debug.Assert(!pattern.IsRecursive, "All recursive patterns should be desugared into simple patterns at this point"); - + + var desugaringResult = new CollectionDesugaringResult(); var collectionItems = pattern.parameters; var gapItemMet = false; var gapIndex = 0; @@ -495,14 +533,37 @@ namespace SyntaxVisitors.SugarVisitors } } - var itemsEqualCalls = GetCollectionItemsEqualCheckBeforeGap(matchingExpression as addressed_value, exprBeforeGap); + var successMatchingCheck = GetCollectionItemsEqualCheckBeforeGap( + matchingExpression as addressed_value, exprBeforeGap, desugaringResult); + if (gapItemMet && exprAfterGap.Count != 0) { - var afterGapEqual = GetCollectionItemsEqualCheckAfterGap(matchingExpression as addressed_value, exprAfterGap); - itemsEqualCalls = itemsEqualCalls == null ? afterGapEqual : bin_expr.LogicalAnd(itemsEqualCalls, afterGapEqual); + var afterGapEqual = GetCollectionItemsEqualCheckAfterGap( + matchingExpression as addressed_value, exprAfterGap, desugaringResult); + + if (afterGapEqual != null) + { + successMatchingCheck = successMatchingCheck == null ? + afterGapEqual : + bin_expr.LogicalAnd(successMatchingCheck, afterGapEqual); + } } - return itemsEqualCalls; + var collectionLengthCheck = new bin_expr( + new dot_node(matchingExpression as addressed_value, new ident(CountPropertyName), pattern.source_context), + new int32_const(exprBeforeGap.Count + exprAfterGap.Count), + Operators.GreaterEqual, + pattern.source_context + ); + + successMatchingCheck = successMatchingCheck == null ? + collectionLengthCheck : + bin_expr.LogicalAnd(collectionLengthCheck, successMatchingCheck); + + desugaringResult.SuccessMatchingCheck = successMatchingCheck == null ? + new bool_const(true) : + successMatchingCheck; + return desugaringResult; } private void DesugarIsExpression(is_pattern_expr isPatternExpr) @@ -516,29 +577,16 @@ namespace SyntaxVisitors.SugarVisitors } var patternLocation = GetLocation(isPatternExpr); - switch (isPatternExpr.right) + if (isPatternExpr.right is deconstructor_pattern pattern) { - case deconstructor_pattern pattern: - { - var constParamCheck = DesugarDeconstructorPatternParameters(isPatternExpr.right as deconstructor_pattern); - pattern.const_params_check = constParamCheck; - - //AddDefinitionsInUpperStatementList(isPatternExpr, new[] { GetTypeCompatibilityCheck(isPatternExpr) }); - switch (patternLocation) - { - case PatternLocation.IfCondition: DesugarIsExpressionInIfCondition(isPatternExpr); break; - case PatternLocation.Assign: DesugarIsExpressionInAssignment(isPatternExpr); break; - } - break; - } - case collection_pattern pattern: - { - switch (patternLocation) - { - case PatternLocation.IfCondition: DesugarIsExpressionInIfCondition(isPatternExpr); break; - } - break; - } + var constParamCheck = DesugarDeconstructorPatternParameters(isPatternExpr.right as deconstructor_pattern); + pattern.const_params_check = constParamCheck; + } + //AddDefinitionsInUpperStatementList(isPatternExpr, new[] { GetTypeCompatibilityCheck(isPatternExpr) }); + switch (patternLocation) + { + case PatternLocation.IfCondition: DesugarIsExpressionInIfCondition(isPatternExpr); break; + case PatternLocation.Assign: DesugarIsExpressionInAssignment(isPatternExpr); break; } } @@ -563,6 +611,7 @@ namespace SyntaxVisitors.SugarVisitors private void DesugarIsExpressionInAssignment(is_pattern_expr isExpression) { + Debug.Assert(isExpression.right is deconstructor_pattern, "Only deconstructor patterns can be used in assignment"); var statementsToAdd = ProcessDesugaringForDeconstructorPattern(isExpression); AddDefinitionsInUpperStatementList(isExpression, statementsToAdd); } @@ -576,8 +625,8 @@ namespace SyntaxVisitors.SugarVisitors case deconstructor_pattern dp: if (dp.const_params_check != null) { - var ifToAddConstParamsCheck = GetAscendant(isExpression); - ifToAddConstParamsCheck.condition = bin_expr.LogicalAnd(ifToAddConstParamsCheck.condition, dp.const_params_check); + var ifToAddConstParamsCheckTo = GetAscendant(isExpression); + ifToAddConstParamsCheckTo.condition = bin_expr.LogicalAnd(ifToAddConstParamsCheckTo.condition, dp.const_params_check); } statementsToAdd = ProcessDesugaringForDeconstructorPattern(isExpression); break; @@ -620,10 +669,12 @@ namespace SyntaxVisitors.SugarVisitors private List ProcessDesugaringForCollectionPattern(is_pattern_expr isExpression) { var pattern = isExpression.right as collection_pattern; - var successCheck = DesugarCollectionPattern(pattern, isExpression.left); - ReplaceUsingParent(isExpression, successCheck); + var desugaringResult = DesugarCollectionPattern(pattern, isExpression.left); + ReplaceUsingParent(isExpression, desugaringResult.SuccessMatchingCheck); var statementsToAdd = new List(); + statementsToAdd.AddRange(desugaringResult.VarParametersDeclarations); + //statementsToAdd.AddRange(desugaringResult.VarParametersAssignments); return statementsToAdd; } @@ -734,12 +785,12 @@ namespace SyntaxVisitors.SugarVisitors private PatternLocation GetLocation(syntax_tree_node node) { var firstStatement = GetAscendant(node); - + switch (firstStatement) { case if_node _: return PatternLocation.IfCondition; case var_statement _: return PatternLocation.Assign; - case assign _ : return PatternLocation.Assign; + case assign _: return PatternLocation.Assign; default: return PatternLocation.Unknown; } } @@ -758,7 +809,7 @@ namespace SyntaxVisitors.SugarVisitors return null; } - + private string NewDeconstructParamId() { return GeneratedPatternNamePrefix + "DeconstructParam" + deconstructParamVariableCounter++.ToString(); diff --git a/TreeConverter/TreeConversion/compiler_string_consts.cs b/TreeConverter/TreeConversion/compiler_string_consts.cs index 5b56370fb..8a781279c 100644 --- a/TreeConverter/TreeConversion/compiler_string_consts.cs +++ b/TreeConverter/TreeConversion/compiler_string_consts.cs @@ -373,7 +373,7 @@ namespace PascalABCCompiler.TreeConverter public const string is_test_function_name = "__TypeCheckAndAssignForIsMatch"; public const string wild_cards_tuple_equal_function_name = "__WildCardsTupleEqual"; public const string seq_function_name = "Seq"; - + public const string count_property_name = "Count"; public static string bounded_array_printable_name_template = "array [{0}..{1}] of {2}"; public static string array_printable_name_template = "array of {0}"; public static string multi_dim_array_printable_name_template = "array [{0}] of {1}";