From a489e63bc88f7cf5c87dae1cc5cb28e6939bcac7 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Mon, 5 Jul 2021 23:33:44 +0300 Subject: [PATCH] Intellisense |1,2,3|. --- CodeCompletion/ExpressionVisitor.cs | 10 +- CodeCompletion/SymTable.cs | 13 ++ Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 +- .../ParserTools/DefaultLanguageInformation.cs | 113 +++++++++++------- Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/CompilationSamples/PABCSystem.pas | 10 +- .../convertion_data_and_alghoritms.cs | 1 + bin/Lib/PABCSystem.pas | 10 +- 10 files changed, 105 insertions(+), 62 deletions(-) diff --git a/CodeCompletion/ExpressionVisitor.cs b/CodeCompletion/ExpressionVisitor.cs index 7982bcfd0..8f9a59c24 100644 --- a/CodeCompletion/ExpressionVisitor.cs +++ b/CodeCompletion/ExpressionVisitor.cs @@ -1,6 +1,7 @@ // Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Linq; using System.Collections.Generic; using System.Text; using PascalABCCompiler.SyntaxTree; @@ -2023,7 +2024,14 @@ namespace CodeCompletion public override void visit(array_const_new acn) { - + acn.elements.expressions[0].visit(this); + 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("PABCSystem"), new ident("Arr"), acn.source_context); + var el = new expression_list(acn.elements.expressions[0], acn.source_context); + var nn = new method_call(dn, el, acn.source_context); + visit(nn); } } } diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index 04107a455..09a6ccd2a 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -3543,7 +3543,20 @@ namespace CodeCompletion public override SymInfo[] GetNames(ExpressionVisitor ev, PascalABCCompiler.Parsers.KeywordKind keyword, bool called_in_base) { + if (is_dynamic_arr || IsMultiDynArray) + { + List syms = new List(); + syms.AddRange(base.GetNames(ev, keyword, called_in_base)); + if (!IsMultiDynArray && implemented_interfaces != null) + { + foreach (TypeScope ts in implemented_interfaces) + syms.AddRange(ts.GetNamesAsInObject(ev)); + } + return syms.ToArray(); + } return new SymInfo[0]; + //return new SymInfo[0]; + //return base.GetNames(ev, keyword, called_in_base); } //u staticheskogo massiva prinimaem, chto net metodov i sv-v, u dinam. est diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index ef5770225..5dc2dc5c1 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 = "8"; public const string Build = "0"; - public const string Revision = "2918"; + public const string Revision = "2919"; 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 b2a7274d9..8a3896def 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=0 -%REVISION%=2918 %MINOR%=8 +%REVISION%=2919 +%COREVERSION%=0 %MAJOR%=3 diff --git a/ParserTools/ParserTools/DefaultLanguageInformation.cs b/ParserTools/ParserTools/DefaultLanguageInformation.cs index 5ebc6ca42..98aea72e0 100644 --- a/ParserTools/ParserTools/DefaultLanguageInformation.cs +++ b/ParserTools/ParserTools/DefaultLanguageInformation.cs @@ -2923,57 +2923,78 @@ namespace PascalABCCompiler.Parsers break; case '[': case '(': - if (kav.Count == 0) + case '|': + if (ch == '|' && ((tokens.Count == 0) || (tokens.Peek()==']') || (tokens.Peek() == ')') || (tokens.Peek() == ','))) + // Закрывающий | - после него (tokens.Pop()) - пусто или ] ) , { - if (tokens.Count > 0) + if (kav.Count == 0) + { + string tmps = sb.ToString().Trim(' ', '\r', '\t', '\n'); + if (tmps.Length >= 1 && (char.IsLetter(tmps[0]) || tmps[0] == '_' || tmps[0] == '&' || tmps[0] == '?') && tokens.Count == 0) + end = true; + else + tokens.Push(ch); + } + if (!end) { - tokens.Pop(); - punkt_sym = true; sb.Insert(0, ch); - if (ch == '(') - { - int tmp = i--; - /*while (i >= 0 && (char.IsLetterOrDigit(Text[i]) || Text[i] == '_' || Text[i] == '&')) - { - i--; - }*/ - while (i >= 0 && (Text[i] == ' ' || char.IsControl(Text[i]) || Text[i] == '}')) - { - if (Text[i] != '}') - i--; - else - { - while (i >= 0 && Text[i] != '{') //propusk kommentariev - i--; - if (i >= 0) - i--; - } - } - if (i >= 0 && (char.IsLetterOrDigit(Text[i]) || Text[i] == '_' || Text[i] == '&' || Text[i] == '?' && IsPunctuation(Text, i+1))) - { - bound = i + 1; - TestForKeyword(Text, i, ref bound, punkt_sym, out keyw); - if (keyw != KeywordKind.None && tokens.Count == 0) - { - end = true; - } - else bound = 0; - } - else if (i >= 0 && Text[i] == '\'') return ""; - i = tmp; - } + punkt_sym = true; } - else - { - end = true; - if (ch == '[') - { - keyw = KeywordKind.SquareBracket; - } - } - } - else sb.Insert(0, ch); punkt_sym = true; + else + { + if (kav.Count == 0) // в т.ч. открывающий | + { + if (tokens.Count > 0) + { + tokens.Pop(); + punkt_sym = true; + sb.Insert(0, ch); + if (ch == '(') + { + int tmp = i--; + /*while (i >= 0 && (char.IsLetterOrDigit(Text[i]) || Text[i] == '_' || Text[i] == '&')) + { + i--; + }*/ + while (i >= 0 && (Text[i] == ' ' || char.IsControl(Text[i]) || Text[i] == '}')) + { + if (Text[i] != '}') + i--; + else + { + while (i >= 0 && Text[i] != '{') //propusk kommentariev + i--; + if (i >= 0) + i--; + } + } + if (i >= 0 && (char.IsLetterOrDigit(Text[i]) || Text[i] == '_' || Text[i] == '&' || Text[i] == '?' && IsPunctuation(Text, i+1))) + { + bound = i + 1; + TestForKeyword(Text, i, ref bound, punkt_sym, out keyw); + if (keyw != KeywordKind.None && tokens.Count == 0) + { + end = true; + } + else bound = 0; + } + else if (i >= 0 && Text[i] == '\'') return ""; + i = tmp; + } + } + else + { + end = true; + if (ch == '[') + { + keyw = KeywordKind.SquareBracket; + } + } + + } + else sb.Insert(0, ch); punkt_sym = true; + } break; case '\'': if (kav.Count == 0) kav.Push(ch); else kav.Pop(); diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index e45b20cd4..6f0c8a596 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.8.0.2918 +3.8.0.2919 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 120c15395..1ab768251 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.8.0.2918' +!define VERSION '3.8.0.2919' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 13fac01b9..b85984e4a 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -8687,16 +8687,16 @@ begin Result := integer(a); end; -function Chr(a: word): char; -begin - Result := Convert.ToChar(a); -end; - function Ord(a: char): word; begin Result := word(a); end; +function Chr(a: word): char; +begin + Result := Convert.ToChar(a); +end; + function ChrUnicode(a: word): char; begin Result := Convert.ToChar(a); diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index 576148b1f..8a8ac444b 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -1348,6 +1348,7 @@ namespace PascalABCCompiler.TreeConverter public enum MoreSpecific { Left, Right, None} + // SSM 04/07/2021 public MoreSpecific compare_more_specific(function_node left_func, function_node right_func) { bool LeftIsMoreSpecific = false; diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 13fac01b9..b85984e4a 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -8687,16 +8687,16 @@ begin Result := integer(a); end; -function Chr(a: word): char; -begin - Result := Convert.ToChar(a); -end; - function Ord(a: char): word; begin Result := word(a); end; +function Chr(a: word): char; +begin + Result := Convert.ToChar(a); +end; + function ChrUnicode(a: word): char; begin Result := Convert.ToChar(a);