Незначительные изменения в грамматике

This commit is contained in:
miks1965 2018-08-13 12:36:59 +03:00
parent 31f153266f
commit fa6270ce7d
9 changed files with 2108 additions and 2013 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "4";
public const string Build = "0";
public const string Revision = "1741";
public const string Revision = "1742";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%COREVERSION%=0
%REVISION%=1741
%MINOR%=4
%REVISION%=1742
%COREVERSION%=0
%MAJOR%=3

View file

@ -2,7 +2,7 @@
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-A6LT9RI
// DateTime: 12.08.2018 14:37:17
// DateTime: 13.08.2018 12:19:26
// UserName: ?????????
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>

View file

@ -4,7 +4,7 @@
// ==========================================================================
// Version: 1.3.6
// Machine: DESKTOP-A6LT9RI
// DateTime: 11.07.2018 23:15:18
// DateTime: 13.08.2018 11:18:26
// UserName: Станислав
// ==========================================================================
@ -44,7 +44,7 @@
%token <ti> tkDirectiveName tkAmpersend tkColon tkDotDot tkPoint tkRoundOpen tkRoundClose tkSemiColon tkSquareOpen tkSquareClose tkQuestion tkQuestionPoint tkDoubleQuestion tkQuestionSquareOpen
%token <ti> tkSizeOf tkTypeOf tkWhere tkArray tkCase tkClass tkAuto tkConst tkConstructor tkDestructor tkElse tkExcept tkFile tkFor tkForeach tkFunction tkMatch tkWhen
%token <ti> tkIf tkImplementation tkInherited tkInterface tkTypeclass tkInstance tkProcedure tkOperator tkProperty tkRaise tkRecord tkSet tkType tkThen tkUses tkVar tkWhile tkWith tkNil
%token <ti> tkIf tkImplementation tkInherited tkInterface /* tkTypeclass tkInstance */ tkProcedure tkOperator tkProperty tkRaise tkRecord tkSet tkType tkThen tkUses tkVar tkWhile tkWith tkNil
%token <ti> tkGoto tkOf tkLabel tkLock tkProgram tkEvent tkDefault tkTemplate tkPacked tkExports tkResourceString tkThreadvar tkSealed tkPartial tkTo tkDownto
%token <ti> tkLoop
%token <ti> tkSequence tkYield
@ -104,7 +104,7 @@
%type <id> 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 <id> program_param identifier identifier_keyword_operatorname func_class_name_ident /*optional_identifier*/ visibility_specifier
%type <id> property_specifier_directives non_reserved
%type <id> typeclass_restriction
//%type <id> typeclass_restriction
%type <stn> if_stmt
%type <stn> initialization_part
%type <stn> template_arguments label_list ident_or_keyword_pointseparator_list ident_list param_name_list
@ -166,7 +166,7 @@
%type <ex> typeof_expr
%type <stn> simple_fp_sect
%type <stn> template_param_list template_type_params
%type <stn> template_type_or_typeclass_params typeclass_params
//%type <stn> template_type_or_typeclass_params typeclass_params
%type <td> template_type
%type <stn> try_stmt
%type <stn> uses_clause used_units_list
@ -189,8 +189,6 @@
%type <stn> pattern pattern_optional_var match_with pattern_case pattern_cases pattern_out_param pattern_out_param_optional_var
%type <ob> pattern_out_param_list pattern_out_param_list_optional_var
%%
// Warning: NonTerminal symbol "typed_var_init_expression" is unreachable
// ----------------------------------------------------------------------
parse_goal
: program_file
@ -875,10 +873,10 @@ const_factor
}
| new_expr
{ $$ = $1; }
| tkDeref const_factor
{
$$ = new roof_dereference($2 as addressed_value, @$);
}
// | tkDeref const_factor
// {
// $$ = new roof_dereference($2 as addressed_value, @$);
// }
;
const_set
@ -919,7 +917,7 @@ const_variable
{
$$ = NewConstVariable($1, $2, @$);
}
| const_variable tkAmpersend template_type_or_typeclass_params
| const_variable tkAmpersend template_type_params
{
$$ = new ident_with_templateparams($1 as addressed_value, $3 as template_param_list, @$);
}
@ -1132,7 +1130,7 @@ 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, @$), @$);
@ -1140,9 +1138,9 @@ simple_type_decl
| 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
{
@ -1166,7 +1164,8 @@ template_type_or_typeclass_params
{
$$ = $1;
}
;
;*/
type_decl_identifier
: identifier
{ $$ = $1; }
@ -1519,30 +1518,42 @@ object_type
foreach (var prop in ccnt)
{
var td = prop.property_type;
var ra = prop.accessors.read_accessor;
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)
{
(ra.pr.proc_header as function_header).return_type = td;
cm.Add(ra.pr);
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)
{
ra.pr.proc_header.class_keyword = true;
rapr.proc_header.class_keyword = true;
procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static);
pa.source_context = ra.pr.proc_header.source_context;
ra.pr.proc_header.proc_attributes = new procedure_attributes_list(pa);
pa.source_context = rapr.proc_header.source_context;
rapr.proc_header.proc_attributes = new procedure_attributes_list(pa);
}
}
var wa = prop.accessors.write_accessor;
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)
{
wa.pr.proc_header.parameters.params_list[0].vars_type = td;
cm.Add(wa.pr);
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)
{
wa.pr.proc_header.class_keyword = true;
wapr.proc_header.class_keyword = true;
procedure_attribute pa = new procedure_attribute(proc_attribute.attr_static);
pa.source_context = wa.pr.proc_header.source_context;
wa.pr.proc_header.proc_attributes = new procedure_attributes_list(pa);
pa.source_context = wapr.proc_header.source_context;
wapr.proc_header.proc_attributes = new procedure_attributes_list(pa);
}
}
}
@ -1555,6 +1566,51 @@ 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<simple_property>().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);
}
;
@ -1646,12 +1702,12 @@ base_class_name
: simple_type_identifier
{ $$ = $1; }
| template_type
{ $$ = $1; }
{ $$ = $1; }/*
| typeclass_restriction
{
var names = new List<ident>();
names.Add(($1 as typeclass_restriction).name);
$$ = new typeclass_reference(null, names, ($1 as typeclass_restriction).restriction_args); }
$$ = new typeclass_reference(null, names, ($1 as typeclass_restriction).restriction_args); }*/
;
template_arguments
@ -1684,11 +1740,11 @@ 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
@ -1955,6 +2011,8 @@ simple_property_definition
pa = proc_attribute.attr_virtual;
else if ($6.name.ToLower() == "override")
pa = proc_attribute.attr_override;
else if ($6.name.ToLower() == "abstract")
pa = proc_attribute.attr_abstract;
$$ = NewSimplePropertyDefinition($2 as method_name, $3 as property_interface, $4 as property_accessors, pa, $8 as property_array_default, @$);
}
;
@ -2028,15 +2086,17 @@ property_specifiers
:
| tkRead optional_read_expr write_property_specifiers
{
if ($2 == null || $2 is ident)
if ($2 == null || $2 is ident) // ñòàíäàðòíûå ñâîéñòâà
{
$$ = NewPropertySpecifiersRead($1, $2 as ident, null, $3 as property_accessors, @$);
$$ = NewPropertySpecifiersRead($1, $2 as ident, null, null, $3 as property_accessors, @$);
}
else
else // ðàñøèðåííûå ñâîéñòâà
{
var id = NewId("#GetGen");
var pr = CreateAndAddToClassReadFunc($2,id,@2);
$$ = NewPropertySpecifiersRead($1, id, pr, $3 as property_accessors, @$);
procedure_definition pr = null;
if (!parsertools.build_tree_for_formatter)
pr = CreateAndAddToClassReadFunc($2, id, @2);
$$ = NewPropertySpecifiersRead($1, id, pr, $2, $3 as property_accessors, @$); // $2 ïåðåäà¸òñÿ äëÿ ôîðìàòèðîâàíèÿ
}
}
| tkWrite unlabelled_stmt read_property_specifiers
@ -2044,18 +2104,20 @@ property_specifiers
if ($2 is empty_statement)
{
$$ = NewPropertySpecifiersWrite($1, null, null, $3 as property_accessors, @$);
$$ = NewPropertySpecifiersWrite($1, null, null, null, $3 as property_accessors, @$);
}
else if ($2 is procedure_call && ($2 as procedure_call).is_ident)
else if ($2 is procedure_call && ($2 as procedure_call).is_ident) // ñòàíäàðòíûå ñâîéñòâà
{
$$ = NewPropertySpecifiersWrite($1, ($2 as procedure_call).func_name as ident, null, $3 as property_accessors, @$); // ñòàðûå ñâîéñòâà - ñ èäåíòèôèêàòîðîì
$$ = NewPropertySpecifiersWrite($1, ($2 as procedure_call).func_name as ident, null, null, $3 as property_accessors, @$); // ñòàðûå ñâîéñòâà - ñ èäåíòèôèêàòîðîì
}
else
else // ðàñøèðåííûå ñâîéñòâà
{
var id = NewId("#SetGen");
var pr = CreateAndAddToClassWriteProc($2 as statement,id,@2);
$$ = NewPropertySpecifiersWrite($1, id, pr, $3 as property_accessors, @$);
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 ïåðåäà¸òñÿ äëÿ ôîðìàòèðîâàíèÿ
}
}
;
@ -2066,17 +2128,19 @@ write_property_specifiers
if ($2 is empty_statement)
{
$$ = NewPropertySpecifiersWrite($1, null, null, null, @$);
$$ = NewPropertySpecifiersWrite($1, null, null, null, null, @$);
}
else if ($2 is procedure_call && ($2 as procedure_call).is_ident)
{
$$ = NewPropertySpecifiersWrite($1, ($2 as procedure_call).func_name as ident, null, null, @$); // ñòàðûå ñâîéñòâà - ñ èäåíòèôèêàòîðîì
$$ = NewPropertySpecifiersWrite($1, ($2 as procedure_call).func_name as ident, null, null, null, @$); // ñòàðûå ñâîéñòâà - ñ èäåíòèôèêàòîðîì
}
else
{
var id = NewId("#SetGen");
var pr = CreateAndAddToClassWriteProc($2 as statement,id,@2);
$$ = NewPropertySpecifiersWrite($1, id, pr, null, @$);
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, @$);
}
}
;
@ -2087,13 +2151,15 @@ read_property_specifiers
{
if ($2 == null || $2 is ident)
{
$$ = NewPropertySpecifiersRead($1, $2 as ident, null, null, @$);
$$ = NewPropertySpecifiersRead($1, $2 as ident, null, null, null, @$);
}
else
{
var id = NewId("#GetGen");
var pr = CreateAndAddToClassReadFunc($2,id,@2);
$$ = NewPropertySpecifiersRead($1, id, pr, null, @$);
procedure_definition pr = null;
if (!parsertools.build_tree_for_formatter)
pr = CreateAndAddToClassReadFunc($2,id,@2);
$$ = NewPropertySpecifiersRead($1, id, pr, $2, null, @$);
}
}
;
@ -2132,7 +2198,7 @@ var_decl_part
{
$$ = new var_def_statement($1 as ident_list, null, $3, definition_attribute.None, false, @$);
}
| ident_list tkColon type_ref tkAssignOrEqual expr_l1 // typed_const_plus óæå äàâíî íå êîíñòàíòà :) Íî ñþäà íå ïîïàëè Tuples, ïîñêîëüêó îíè êîíêóðèðóþò ñ äóðàöêèìè ñòàðûìè èíèöèàëèçàòîðàìè ìàññèâîâ
| ident_list tkColon type_ref tkAssignOrEqual typed_var_init_expression // typed_const_plus óæå äàâíî íå êîíñòàíòà :) Íî ñþäà íå ïîïàëè Tuples, ïîñêîëüêó îíè êîíêóðèðóþò ñ äóðàöêèìè ñòàðûìè èíèöèàëèçàòîðàìè ìàññèâîâ
{
$$ = new var_def_statement($1 as ident_list, $3, $5, definition_attribute.None, false, @$);
}
@ -3101,7 +3167,7 @@ simple_or_template_type_reference
{
$$ = new template_type_reference((named_type_reference)$1, (template_param_list)$2, @$);
}
| simple_type_identifier tkAmpersend template_type_or_typeclass_params
| simple_type_identifier tkAmpersend template_type_params
{
$$ = new template_type_reference((named_type_reference)$1, (template_param_list)$3, @$);
}
@ -3522,10 +3588,10 @@ factor
$$ = new un_expr($2, $1.type, @$);
}
| tkDeref factor
{
$$ = new roof_dereference($2 as addressed_value, @$);
}
// | tkDeref factor // ýòî åðóíäà êàêàÿ-òî
// {
// $$ = new roof_dereference($2 as addressed_value, @$);
// }
| var_reference
{ $$ = $1; }
| tuple
@ -3640,10 +3706,13 @@ variable
| variable tkQuestionSquareOpen format_expr tkSquareClose
{
var fe = $3 as format_expr; // SSM 9/01/17
if (fe.expr == null)
fe.expr = new int32_const(int.MaxValue,@3);
if (fe.format1 == null)
fe.format1 = new int32_const(int.MaxValue,@3);
if (!parsertools.build_tree_for_formatter)
{
if (fe.expr == null)
fe.expr = new int32_const(int.MaxValue,@3);
if (fe.format1 == null)
fe.format1 = new int32_const(int.MaxValue,@3);
}
$$ = new slice_expr_question($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$);
}
| variable tkRoundOpen optional_expr_list tkRoundClose
@ -3666,7 +3735,7 @@ variable
{
$$ = new roof_dereference($1 as addressed_value,@$);
}
| variable tkAmpersend template_type_or_typeclass_params
| variable tkAmpersend template_type_params
{
$$ = new ident_with_templateparams($1 as addressed_value, $3 as template_param_list, @$);
}
@ -3832,6 +3901,8 @@ property_modificator
{ $$ = $1; }
| tkOverride
{ $$ = $1; }
| tkAbstract
{ $$ = $1; }
;
property_specifier_directives
@ -4003,7 +4074,9 @@ keyword
| tkMatch
{ $$ = $1; }
| tkWhen
{ $$ = $1; }
{ $$ = $1; }/*
| tkInstance
{ $$ = $1; }*/
;
reserved_keyword

View file

@ -2827,7 +2827,15 @@ case_stmt
: tkCase expr_l1 tkOf case_list else_case tkEnd
{
$$ = new case_node($2, $4 as case_variants, $5 as statement, @$);
}
}
| tkCase expr_l1 tkOf case_list tkSemiColon else_case tkEnd
{
$$ = new case_node($2, $4 as case_variants, $6 as statement, @$);
}
| tkCase expr_l1 tkOf else_case tkEnd
{
$$ = new case_node($2, NewCaseItem(new empty_statement(), null), $4 as statement, @$);
}
;
case_list
@ -2844,11 +2852,7 @@ case_list
;
case_item
:
{
$$ = new empty_statement();
}
| case_label_list tkColon unlabelled_stmt
: case_label_list tkColon unlabelled_stmt
{
$$ = new case_variant($1 as expression_list, $3 as statement, @$);
}

File diff suppressed because it is too large Load diff

View file

@ -208,5 +208,6 @@ script=

View file

@ -1 +1 @@
!define VERSION '3.4.0.1741'
!define VERSION '3.4.0.1742'

View file

@ -0,0 +1,7 @@
begin
var i := 1;
case i of;
1:Write(2);
else Print(666)
end
end.