From 8a9788e6f9915df7e9bf925be55e0895753ce022 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Tue, 17 Dec 2024 15:06:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20set=20array?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D1=83=D1=80=D0=BE=D0=B2=D0=B5=D0=BD=D1=8C=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D1=81=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Немного поправил Intellisense по наведению для NewSet По точке там что то другое работает --- CodeCompletion/DomConverter.cs | 5 +++++ CodeCompletion/ExpressionVisitor.cs | 14 +++++++++++--- Parsers/PascalABCParserNewSaushkin/ABCPascal.cs | 2 +- Parsers/PascalABCParserNewSaushkin/ABCPascal.y | 10 +++------- .../PascalABCParserNewSaushkin/ABCPascalYacc.cs | 10 +++++----- Parsers/PascalABCParserNewSaushkin/PABC.ymc | 1 + .../TreeConversion/syntax_tree_visitor.cs | 4 ++-- 7 files changed, 28 insertions(+), 18 deletions(-) diff --git a/CodeCompletion/DomConverter.cs b/CodeCompletion/DomConverter.cs index 3ed8c7738..ac853d540 100644 --- a/CodeCompletion/DomConverter.cs +++ b/CodeCompletion/DomConverter.cs @@ -1060,7 +1060,12 @@ namespace CodeCompletion RestoreCurrentUsedAssemblies(); string description = ss.si.description; if (description != null) + { description = description.Replace("!#", ""); + // Пусть здесь делаем все замены + // Для рекурсивных <<>> нужно писать собственный парсер + description = System.Text.RegularExpressions.Regex.Replace(description, @"NewSet<\s*(.*)\s*>", "set of $1"); + } return description; } RestoreCurrentUsedAssemblies(); diff --git a/CodeCompletion/ExpressionVisitor.cs b/CodeCompletion/ExpressionVisitor.cs index 4b9072b53..500706111 100644 --- a/CodeCompletion/ExpressionVisitor.cs +++ b/CodeCompletion/ExpressionVisitor.cs @@ -1264,10 +1264,18 @@ namespace CodeCompletion method_call_cache[_method_call] = returned_scope; } - public override void visit(pascal_set_constant _pascal_set_constant) + public override void visit(pascal_set_constant psc) { //throw new NotImplementedException(); - returned_scope = null; + // returned_scope = null; + + var dn = new dot_node(new ident(StringConstants.pascalSystemUnitName), new ident("Arr"), psc.source_context); + var el = new expression_list(psc.values.expressions[0], psc.source_context); + var nn = new method_call(dn, el, psc.source_context); + var dn1 = new dot_node(new ident(StringConstants.pascalSystemUnitName), new ident("__NewSetCreatorInternal"), psc.source_context); + var el1 = new expression_list(nn, psc.source_context); + var nn1 = new method_call(dn1, el1, psc.source_context); + visit(nn1); } public override void visit(array_const _array_const) @@ -2048,7 +2056,7 @@ namespace CodeCompletion public override void visit(array_const_new acn) { acn.elements.expressions[0].visit(this); - var rr = this.returned_scope; + //var rr = this.returned_scope; //var nn = new new_expr((syntax_type, plist, true, new SyntaxTree.array_const(acn.elements, acn.elements.source_context), acn.source_context); //var nn = new new_expr($2, el, true, $6 as array_const, @$); var dn = new dot_node(new ident(StringConstants.pascalSystemUnitName), new ident("Arr"), acn.source_context); diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index de89a27c3..176a3b02c 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: LAPTOP-TE3HP881 -// DateTime: 14.12.2024 20:15:39 +// DateTime: 15.12.2024 8:40:15 // UserName: miks // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index fb04296be..63b39feed 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -992,15 +992,15 @@ pascal_set_const : tkSquareOpen elem_list tkSquareClose { // Если elem_list пуст или содержит диапазон, то это множество, иначе массив. С PascalABC.NET 3.10 - /*var is_set = false; + var is_set = false; var el = $2 as expression_list; if (el == null || el.Count == 0) is_set = true; else if (el.expressions.Count(x => x is diapason_expr_new) > 0) is_set = true; - if (is_set)*/ + if (is_set) $$ = new pascal_set_constant($2 as expression_list, @$); - //else $$ = new array_const_new($2 as expression_list, @$); + else $$ = new array_const_new($2 as expression_list, @$); } ; @@ -2781,10 +2781,6 @@ unlabelled_stmt { $$ = $1; } | proc_call { $$ = $1; } - /*| pascal_set_const tkPoint identifier - { - $$ = new dot_node($1 as addressed_value, $3 as addressed_value, @$); - }*/ | goto_stmt { $$ = $1; } | compound_stmt diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index 69c375ae8..396a29ae4 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: LAPTOP-TE3HP881 -// DateTime: 14.12.2024 20:15:40 +// DateTime: 15.12.2024 8:40:16 // UserName: miks // Input file @@ -3670,15 +3670,15 @@ public partial class GPPGParser: ShiftReduceParser tkSquareOpen, elem_list, tkSquareClose { // �?сли elem_list п�?с�? или соде�?жи�? диапазон, �?о э�?о множес�?во, ина�?е массив. С PascalABC.NET 3.10 - /*var is_set = false; - var el = $2 as expression_list; + var is_set = false; + var el = ValueStack[ValueStack.Depth-2].stn as expression_list; if (el == null || el.Count == 0) is_set = true; else if (el.expressions.Count(x => x is diapason_expr_new) > 0) is_set = true; - if (is_set)*/ + if (is_set) CurrentSemanticValue.ex = new pascal_set_constant(ValueStack[ValueStack.Depth-2].stn as expression_list, CurrentLocationSpan); - //else $$ = new array_const_new($2 as expression_list, @$); + else CurrentSemanticValue.ex = new array_const_new(ValueStack[ValueStack.Depth-2].stn as expression_list, CurrentLocationSpan); } break; case 165: // const_set -> pascal_set_const diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index 442b5a145..f5286f9ff 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -389,5 +389,6 @@ script= + diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 7fac9e2c6..91fc72442 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -5233,7 +5233,7 @@ namespace PascalABCCompiler.TreeConverter public override void visit(SyntaxTree.pascal_set_constant _pascal_set_constant) { // Если хоть одно - diapason_expr, то это множество иначе литеральный массив - if (_pascal_set_constant.values == null || + /*if (_pascal_set_constant.values == null || _pascal_set_constant.values.expressions.Any(ex => ex is SyntaxTree.diapason_expr) ) { // это множество @@ -5244,7 +5244,7 @@ namespace PascalABCCompiler.TreeConverter array_const_new ac = new array_const_new(exl,exl.source_context); visit(ac); return; - } + }*/ // надо разбить на 2 списка констант expressions_list consts = new expressions_list(); expressions_list consts_diap = new expressions_list();