diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 3a838eae9..f439b1339 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "3"; public const string Build = "0"; - public const string Revision = "1556"; + public const string Revision = "1561"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index ab8dcccaf..66203bdec 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=3 -%REVISION%=1556 %COREVERSION%=0 +%REVISION%=1561 +%MINOR%=3 %MAJOR%=3 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 0938f9e48..40ffda79f 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.3.0.1556' +!define VERSION '3.3.0.1561' diff --git a/SyntaxTreeConverters/StandardSyntaxConverter.cs b/SyntaxTreeConverters/StandardSyntaxConverter.cs index 670b15a15..fcd692187 100644 --- a/SyntaxTreeConverters/StandardSyntaxConverter.cs +++ b/SyntaxTreeConverters/StandardSyntaxConverter.cs @@ -49,9 +49,9 @@ namespace PascalABCCompiler.SyntaxTreeConverters #if DEBUG - /*var cv = CollectLightSymInfoVisitor.New; - cv.ProcessNode(root); - cv.Output(@"d:\\Light1.txt");*/ + //var cv = CollectLightSymInfoVisitor.New; + //cv.ProcessNode(root); + //cv.Output(@"Light1.txt"); /*try { diff --git a/SyntaxVisitors/LightSymInfoVisitors/LightScopeHelperClasses.cs b/SyntaxVisitors/LightSymInfoVisitors/LightScopeHelperClasses.cs index eaa984561..ba8032d9b 100644 --- a/SyntaxVisitors/LightSymInfoVisitors/LightScopeHelperClasses.cs +++ b/SyntaxVisitors/LightSymInfoVisitors/LightScopeHelperClasses.cs @@ -17,7 +17,10 @@ using System.Text; namespace PascalABCCompiler.SyntaxTree { - public enum SymKind { var, field, param, procname, funcname }; + public enum SymKind { var, field, param, procname, funcname, classname, recordname, interfacename }; + + [Flags] + public enum Attributes { class_attr = 1, varparam_attr = 2}; public class SymInfoSyntax { @@ -27,16 +30,24 @@ namespace PascalABCCompiler.SyntaxTree if (SK == SymKind.var || SK == SymKind.field || SK == SymKind.field || SK == SymKind.param) typepart = ": " + (Td == null ? "NOTYPE" : Td.ToString()); typepart = typepart.Replace("PascalABCCompiler.SyntaxTree.", ""); - return "(" + Id.ToString() + "{" + SK.ToString() + "}" + typepart + ")"; + var attrstr = Attr != 0 ? "[" + Attr.ToString() + "]" : ""; + var s = "(" + Id.ToString() + "{" + SK.ToString() + "}" + typepart + attrstr + ")"; + return s; } public ident Id { get; set; } public type_definition Td { get; set; } public SymKind SK { get; set; } - public SymInfoSyntax(ident Id, SymKind SK, type_definition Td = null) + public Attributes Attr { get; set; } + public SymInfoSyntax(ident Id, SymKind SK, type_definition Td = null, Attributes Attr = 0) { this.Id = Id; this.Td = Td; this.SK = SK; + this.Attr = Attr; + } + public void AddAttribute(Attributes attr) + { + Attr &= attr; } } @@ -70,6 +81,10 @@ namespace PascalABCCompiler.SyntaxTree { public RecordScopeSyntax(ident Name) : base(Name) { } } // + public class InterfaceScopeSyntax : NamedScopeSyntax + { + public InterfaceScopeSyntax(ident Name) : base(Name) { } + } public class LightScopeSyntax : ScopeSyntax // предок всех легковесных { public override string ToString() @@ -91,6 +106,5 @@ namespace PascalABCCompiler.SyntaxTree public class ForScopeSyntax : LightScopeSyntax { } // statement_list public class ForeachScopeSyntax : LightScopeSyntax { } // statement_list public class LambdaScopeSyntax : ScopeSyntax { } - } diff --git a/SyntaxVisitors/LightSymInfoVisitors/SymInfoCollect1.cs b/SyntaxVisitors/LightSymInfoVisitors/SymInfoCollect1.cs index 93b5a37e4..62225a4a0 100644 --- a/SyntaxVisitors/LightSymInfoVisitors/SymInfoCollect1.cs +++ b/SyntaxVisitors/LightSymInfoVisitors/SymInfoCollect1.cs @@ -36,9 +36,10 @@ namespace PascalABCCompiler.SyntaxTree break; case procedure_definition p: var name = p.proc_header.name.meth_name; + var attr = p.proc_header.class_keyword ? Attributes.class_attr : 0; if (p.proc_header is function_header) - AddSymbol(name, SymKind.funcname); - else AddSymbol(name, SymKind.procname); + AddSymbol(name, SymKind.funcname,null, attr); + else AddSymbol(name, SymKind.procname, null, attr); t = new ProcScopeSyntax(name); break; case formal_parameters p: @@ -61,13 +62,22 @@ namespace PascalABCCompiler.SyntaxTree break; case class_definition p: var td = p.Parent as type_declaration; - var tname = td.type_name; - t = new ClassScopeSyntax(tname); - break; - case record_type p: - var td1 = p.Parent as type_declaration; - var rname = td1.type_name; - t = new RecordScopeSyntax(rname); + var tname = td==null ? "NONAME" : td.type_name; + if (p.keyword == class_keyword.Class) + { + AddSymbol(tname, SymKind.classname); + t = new ClassScopeSyntax(tname); + } + else if (p.keyword == class_keyword.Record) + { + AddSymbol(tname, SymKind.recordname); + t = new RecordScopeSyntax(tname); + } + else if (p.keyword == class_keyword.Interface) + { + AddSymbol(tname, SymKind.interfacename); + t = new InterfaceScopeSyntax(tname); + } break; case function_lambda_definition p: t = new LambdaScopeSyntax(); @@ -109,10 +119,11 @@ namespace PascalABCCompiler.SyntaxTree } public override void visit(var_def_statement vd) { + var attr = vd.var_attr == definition_attribute.Static ? Attributes.class_attr : 0; if (vd == null || vd.vars == null || vd.vars.list == null) return; var type = vd.vars_type; - var q = vd.vars.list.Select(x => new SymInfoSyntax(x, SymKind.var, type)); + var q = vd.vars.list.Select(x => new SymInfoSyntax(x, SymKind.var, type, attr)); if (q.Count() > 0) Current.Symbols.AddRange(q); base.visit(vd); diff --git a/SyntaxVisitors/LightSymInfoVisitors/SymInfoCollect1Helper.cs b/SyntaxVisitors/LightSymInfoVisitors/SymInfoCollect1Helper.cs index 41867e982..00a7145ca 100644 --- a/SyntaxVisitors/LightSymInfoVisitors/SymInfoCollect1Helper.cs +++ b/SyntaxVisitors/LightSymInfoVisitors/SymInfoCollect1Helper.cs @@ -20,9 +20,9 @@ namespace PascalABCCompiler.SyntaxTree { public partial class CollectLightSymInfoVisitor : BaseEnterExitVisitor { - public void AddSymbol(ident name, SymKind kind, type_definition td = null) + public void AddSymbol(ident name, SymKind kind, type_definition td = null, Attributes attr = 0) { - Current.Symbols.Add(new SymInfoSyntax(name, kind, td)); + Current.Symbols.Add(new SymInfoSyntax(name, kind, td, attr)); } public string Spaces(int n) => new string(' ', n); public void OutputString(string s) => System.IO.File.AppendAllText(fname, s); diff --git a/TestSuite/CompilationSamples/RobotField.pas b/TestSuite/CompilationSamples/RobotField.pas index 1dbeb5584..e017a5ef6 100644 --- a/TestSuite/CompilationSamples/RobotField.pas +++ b/TestSuite/CompilationSamples/RobotField.pas @@ -1064,7 +1064,6 @@ begin labelExState.Text := 'Робот: Работа окончена' else labelExState.Text := 'Робот: Работа окончена, задание не выполнено'; - System.Console.Write(RobField.TaskName); end; var diff --git a/TestSuite/CompilationSamples/foreach_Grouping.pas b/TestSuite/CompilationSamples/foreach_Grouping.pas new file mode 100644 index 000000000..0ec32c1b4 --- /dev/null +++ b/TestSuite/CompilationSamples/foreach_Grouping.pas @@ -0,0 +1,17 @@ +type + = record + : string; + : integer; + end; + +begin + var p: ; + p. := 'dfh'; + var pupils: array of := Arr(p,p,p); + var question := pupils.GroupBy(p->p.); + foreach var group in question do + begin + foreach var pp: in group do + Println(pp); + end; +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index e957ef903..72841477d 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -16869,11 +16869,16 @@ namespace PascalABCCompiler.TreeConverter else { var ip = tn.instance_params; + + var IGrTstring = "System.Linq.IGrouping`2"; + if (ct.ToString().StartsWith(IGrTstring)) + elem_type = ip[1]; + else + elem_type = ip[0]; //var Tname = ip[0].name; //elem_type = convert_strong(new SyntaxTree.named_type_reference(Tname, _foreach_stmt.in_what.source_context)); - elem_type = ip[0]; } - + //elem_type.instance_params = tn.instance_params; //var ip = tn.instance_params; //var Tname = new string(tn.name.SkipWhile(c => c != '<').Skip(1).TakeWhile(c => c != ',' && c != '>').ToArray()); diff --git a/bin/Lib/RobotField.pas b/bin/Lib/RobotField.pas index 1dbeb5584..e017a5ef6 100644 --- a/bin/Lib/RobotField.pas +++ b/bin/Lib/RobotField.pas @@ -1064,7 +1064,6 @@ begin labelExState.Text := 'Робот: Работа окончена' else labelExState.Text := 'Робот: Работа окончена, задание не выполнено'; - System.Console.Write(RobField.TaskName); end; var