From 6d15540895ee1257baf2e1dd777f756ea3b0fa4f Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Sun, 31 Aug 2025 17:21:18 +0300 Subject: [PATCH] =?UTF-8?q?SPython=20=D0=B2=203.11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 +- .../SPython/GraphWPF_use_example.pys | 10 ++++ InstallerSamples/SPython/argmin.pys | 15 ++++++ .../SPython/compound_conditions_example.pys | 27 +++++++++++ InstallerSamples/SPython/delete_by_mouse.pys | 42 ++++++++++++++++ InstallerSamples/SPython/game_example.pys | 26 ++++++++++ InstallerSamples/SPython/in_out_example.pys | 24 ++++++++++ InstallerSamples/SPython/list_methods.pys | 9 ++++ InstallerSamples/SPython/list_use_example.pys | 13 +++++ InstallerSamples/SPython/py1.pys | 3 ++ InstallerSamples/SPython/py10.pys | 8 ++++ InstallerSamples/SPython/py11.pys | 3 ++ InstallerSamples/SPython/py12.pys | 20 ++++++++ InstallerSamples/SPython/py13.pys | 13 +++++ InstallerSamples/SPython/py14.pys | 17 +++++++ InstallerSamples/SPython/py15.pys | 12 +++++ InstallerSamples/SPython/py16.pys | 3 ++ InstallerSamples/SPython/py2.pys | 5 ++ InstallerSamples/SPython/py3.pys | 5 ++ InstallerSamples/SPython/py4.pys | 7 +++ InstallerSamples/SPython/py5.pys | 15 ++++++ InstallerSamples/SPython/py6.pys | 2 + InstallerSamples/SPython/py7.pys | 11 +++++ InstallerSamples/SPython/py8.pys | 3 ++ InstallerSamples/SPython/py9.pys | 6 +++ InstallerSamples/SPython/random.pys | 5 ++ InstallerSamples/SPython/random1.pys | 8 ++++ InstallerSamples/SPython/set_example.pys | 11 +++++ .../SPython/time_measurement_example.pas | 18 +++++++ .../SPython/time_measurement_example.pys | 16 +++++++ InstallerSamples/SPython/unit_example.pys | 18 +++++++ InstallerSamples/SPython/unit_use_example.pas | 15 ++++++ InstallerSamples/SPython/unit_use_example.pys | 19 ++++++++ Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_end.nsh | 4 ++ ReleaseGenerators/PascalABCNET_sections.nsh | 1 + ReleaseGenerators/PascalABCNET_version.nsh | 2 +- .../RebuildStandartModulesSPython.pas | 11 +++++ ReleaseGenerators/sect_Core.nsh | 32 +++++++++++++ ReleaseGenerators/sect_SPythonParser.nsh | 48 +++++++++++++++++++ _GenerateAllSetups.bat | 2 + bin/Lib/time1.pas | 15 ++++++ 43 files changed, 527 insertions(+), 5 deletions(-) create mode 100644 InstallerSamples/SPython/GraphWPF_use_example.pys create mode 100644 InstallerSamples/SPython/argmin.pys create mode 100644 InstallerSamples/SPython/compound_conditions_example.pys create mode 100644 InstallerSamples/SPython/delete_by_mouse.pys create mode 100644 InstallerSamples/SPython/game_example.pys create mode 100644 InstallerSamples/SPython/in_out_example.pys create mode 100644 InstallerSamples/SPython/list_methods.pys create mode 100644 InstallerSamples/SPython/list_use_example.pys create mode 100644 InstallerSamples/SPython/py1.pys create mode 100644 InstallerSamples/SPython/py10.pys create mode 100644 InstallerSamples/SPython/py11.pys create mode 100644 InstallerSamples/SPython/py12.pys create mode 100644 InstallerSamples/SPython/py13.pys create mode 100644 InstallerSamples/SPython/py14.pys create mode 100644 InstallerSamples/SPython/py15.pys create mode 100644 InstallerSamples/SPython/py16.pys create mode 100644 InstallerSamples/SPython/py2.pys create mode 100644 InstallerSamples/SPython/py3.pys create mode 100644 InstallerSamples/SPython/py4.pys create mode 100644 InstallerSamples/SPython/py5.pys create mode 100644 InstallerSamples/SPython/py6.pys create mode 100644 InstallerSamples/SPython/py7.pys create mode 100644 InstallerSamples/SPython/py8.pys create mode 100644 InstallerSamples/SPython/py9.pys create mode 100644 InstallerSamples/SPython/random.pys create mode 100644 InstallerSamples/SPython/random1.pys create mode 100644 InstallerSamples/SPython/set_example.pys create mode 100644 InstallerSamples/SPython/time_measurement_example.pas create mode 100644 InstallerSamples/SPython/time_measurement_example.pys create mode 100644 InstallerSamples/SPython/unit_example.pys create mode 100644 InstallerSamples/SPython/unit_use_example.pas create mode 100644 InstallerSamples/SPython/unit_use_example.pys create mode 100644 ReleaseGenerators/RebuildStandartModulesSPython.pas create mode 100644 ReleaseGenerators/sect_SPythonParser.nsh create mode 100644 bin/Lib/time1.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 425e7ed8a..ab43cef0e 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 = "11"; public const string Build = "0"; - public const string Revision = "3654"; + public const string Revision = "3661"; 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 6bc48a1dd..d529b23dc 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=0 -%REVISION%=3654 %MINOR%=11 +%REVISION%=3661 +%COREVERSION%=0 %MAJOR%=3 diff --git a/InstallerSamples/SPython/GraphWPF_use_example.pys b/InstallerSamples/SPython/GraphWPF_use_example.pys new file mode 100644 index 000000000..fd9d70def --- /dev/null +++ b/InstallerSamples/SPython/GraphWPF_use_example.pys @@ -0,0 +1,10 @@ +from GraphWPF import * + +color = RandomColor() + +def MouseMove(x: float, y: float, mb: int): + if mb == 1: + FillCircle(x, y, 10, color) + + +OnMouseMove = MouseMove diff --git a/InstallerSamples/SPython/argmin.pys b/InstallerSamples/SPython/argmin.pys new file mode 100644 index 000000000..b09c03971 --- /dev/null +++ b/InstallerSamples/SPython/argmin.pys @@ -0,0 +1,15 @@ +# индекс минимального элемента +def argmin(arr: list[int]) -> int: + if len(arr) == 0: + return -1 + res = 0 + for i in range(1, len(arr)): + if arr[i] < arr[res]: + res = i + return res + +print(argmin([1, 2, 3])) +print(argmin([3, 2, 1])) +# a = [4,9,16,8,2,15,13,13,15,2,8,16,9,4] +a = [i ** 2 % 17 for i in range(2, 16)] +print(argmin([i ** 2 % 17 for i in range(2, 16)])) diff --git a/InstallerSamples/SPython/compound_conditions_example.pys b/InstallerSamples/SPython/compound_conditions_example.pys new file mode 100644 index 000000000..20332be55 --- /dev/null +++ b/InstallerSamples/SPython/compound_conditions_example.pys @@ -0,0 +1,27 @@ +N = 7 + +# Выводит первые N чисел, +# которые можно тремя различными +# способами представить как +# сумму двух квадратов целых чисел +def print_sequence(N: int): + a = 0 + while True: + a += 1 + for b in range(1, a): + for c in range(1, b): + for d in range(1, c + 1): + for e in range(1, d): + for f in range(1, e): + if a ** 2 + f ** 2 == b ** 2 + e ** 2 == c ** 2 + d ** 2: + print(a ** 2 + f ** 2, '\t= ', + a, '^2 + ', f, '^2 \t= ', + b, '^2 + ', e, '^2 \t= ', + c, '^2 + ', d, '^2', sep='') + + N -= 1 + if N == 0: + return + + +print_sequence(N) \ No newline at end of file diff --git a/InstallerSamples/SPython/delete_by_mouse.pys b/InstallerSamples/SPython/delete_by_mouse.pys new file mode 100644 index 000000000..1a0c29675 --- /dev/null +++ b/InstallerSamples/SPython/delete_by_mouse.pys @@ -0,0 +1,42 @@ +from WPFObjects import RectangleWPF, ObjectUnderPoint +from WPFObjects import Colors, Window, OnMouseDown +from PABCSystem import Random, Inc, Milliseconds + +CountSquares = 10 +StatusRect: RectangleWPF +CurrentDigit = 1 +Mistakes = 0 + +def DrawStatusText(): + if CurrentDigit <= CountSquares: + StatusRect.Text = ('Удалено квадратов: ' + str(CurrentDigit-1) + + '\tОшибок: ' + str(Mistakes)) + else: + StatusRect.Text = ('Игра окончена. Время: ' + str(Milliseconds() // 1000) + + ' с.\tОшибок: ' + str(Mistakes)) + + +def MyMouseDown(x: float, y: float, mb: int): + ob = ObjectUnderPoint(x, y) + if ob is RectangleWPF and ob != StatusRect: + if ob.Number == CurrentDigit: + ob.Destroy() + Inc(CurrentDigit) + DrawStatusText() + else: + ob.Color = Colors.Red + Inc(Mistakes) + DrawStatusText() + + +Window.Title = 'Игра: удали все квадраты по порядку' +for i in range(1, CountSquares + 1): + x = Random(Window.Width - 50) + y = Random(Window.Height - 100) + ob = new RectangleWPF(x, y, 50, 50, Colors.LightGreen, 1) + ob.FontSize = 25 + ob.Number = i +StatusRect = new RectangleWPF(0, Window.Height - 40, + Window.Width, 40, Colors.LightBlue) +DrawStatusText() +OnMouseDown = MyMouseDown \ No newline at end of file diff --git a/InstallerSamples/SPython/game_example.pys b/InstallerSamples/SPython/game_example.pys new file mode 100644 index 000000000..12f30b832 --- /dev/null +++ b/InstallerSamples/SPython/game_example.pys @@ -0,0 +1,26 @@ +import random as rnd + +hidden_number = rnd.randint(1, 100) +print('Угадай число от 1 до 100') +attempts = 0 +left_border = 1 +right_border = 100 +while True: + attempts += 1 + guess = int(input('Попытка ' + str(attempts) + ':')) + if guess < left_border or right_border < guess: + print('Число', guess, 'не из диапазона', + '[' + str(left_border) + ',', str(right_border) + ']') + continue + if guess < hidden_number: + left_border = guess + 1 + print('Загаданное число больше', guess); + elif guess > hidden_number: + right_border = guess - 1 + print('Загаданное число меньше', guess); + else: + print('Победа!!!') + break + print('Попробуй число от', left_border, + 'до', right_border) +print('Тебе понадобилось', attempts, 'попыток') \ No newline at end of file diff --git a/InstallerSamples/SPython/in_out_example.pys b/InstallerSamples/SPython/in_out_example.pys new file mode 100644 index 000000000..c5bf877f2 --- /dev/null +++ b/InstallerSamples/SPython/in_out_example.pys @@ -0,0 +1,24 @@ +a = int(input('Введите первое число:')) +b = int(input('Введите второе число:')) + +def print_expressions(a: int, b: int): + print(a, ' +', b, '=', a + b, end = '\n') + print(a, ' -', b, '=', a - b, end = '\n') + print(a, ' *', b, '=', a * b, end = '\n') + print(a, ' %', b, '=', a % b, end = '\n') + print(a, ' /', b, '=', a / b, end = '\n') + print(a, '//', b, '=', a // b, end = '\n') + print(a, '**', b, '=', a ** b, end = '\n') + +print_expressions(a, b) + + +# Введите первое число: 10 +# Введите второе число: 6 +# 10 + 6 = 16 +# 10 - 6 = 4 +# 10 * 6 = 60 +# 10 % 6 = 4 +# 10 / 6 = 1.66666666666667 +# 10 // 6 = 1 +# 10 ** 6 = 1000000 diff --git a/InstallerSamples/SPython/list_methods.pys b/InstallerSamples/SPython/list_methods.pys new file mode 100644 index 000000000..dcd45a73c --- /dev/null +++ b/InstallerSamples/SPython/list_methods.pys @@ -0,0 +1,9 @@ +a = [1, 2, 3] +a.append(4) +a.insert(4, 2) +b = a.copy() +b.reverse() +print(b) +print(a) +print(a.count(2)) +print(a.pop(1)) diff --git a/InstallerSamples/SPython/list_use_example.pys b/InstallerSamples/SPython/list_use_example.pys new file mode 100644 index 000000000..a00806436 --- /dev/null +++ b/InstallerSamples/SPython/list_use_example.pys @@ -0,0 +1,13 @@ +def print_matr(matr: list[list[int]]): + for row in matr: + for elem in row: + print(elem, '\t', end=' ') + print() + + +matrix_of_integers: list[list[int]] +matrix_of_integers = [ + [j * i for j in range(1, 10)] + for i in range(1, 10) if i % 2 == 0 + ] +print_matr(matrix_of_integers) \ No newline at end of file diff --git a/InstallerSamples/SPython/py1.pys b/InstallerSamples/SPython/py1.pys new file mode 100644 index 000000000..499b7f840 --- /dev/null +++ b/InstallerSamples/SPython/py1.pys @@ -0,0 +1,3 @@ +n = int(input("Введите двузначние число:")) + +print(n // 10, n % 10) \ No newline at end of file diff --git a/InstallerSamples/SPython/py10.pys b/InstallerSamples/SPython/py10.pys new file mode 100644 index 000000000..effc61edb --- /dev/null +++ b/InstallerSamples/SPython/py10.pys @@ -0,0 +1,8 @@ +from PABCSystem import Sin,KV,Dict + +graph = { 'A': {'C': 3, 'D': 1}} + +graph1 = Dict(KV(1,2)) + +print(Sin(3.1415/2),graph1,graph1) + diff --git a/InstallerSamples/SPython/py11.pys b/InstallerSamples/SPython/py11.pys new file mode 100644 index 000000000..00d091ddc --- /dev/null +++ b/InstallerSamples/SPython/py11.pys @@ -0,0 +1,3 @@ +fruits = ['apple', 'banana', 'cherry'] +for i, fruit in enumerate(fruits, 1): # начнём с 1 + print(i, fruit) \ No newline at end of file diff --git a/InstallerSamples/SPython/py12.pys b/InstallerSamples/SPython/py12.pys new file mode 100644 index 000000000..edae4bf9a --- /dev/null +++ b/InstallerSamples/SPython/py12.pys @@ -0,0 +1,20 @@ +a = 1 + +def fun(): + global a + # изменение глобальной a + a = 2 + +def fun2(): + # создание локальной a + a = 3 + +print(a) +fun() +print(a) +fun2() +# a не меняется +print(a) + + + \ No newline at end of file diff --git a/InstallerSamples/SPython/py13.pys b/InstallerSamples/SPython/py13.pys new file mode 100644 index 000000000..b2db07265 --- /dev/null +++ b/InstallerSamples/SPython/py13.pys @@ -0,0 +1,13 @@ +lst = [3,6,2,5,1,4] + +def even(x: int) -> bool: + return x % 2 == 0 + +def square(x: int) -> int: + return x * x + +# Стиль SPython и PascalABC.NET +lst.Where(even).Select(square).Order.Println() + +# Стиль Python +print(sorted(map(square,filter(even,lst)))) \ No newline at end of file diff --git a/InstallerSamples/SPython/py14.pys b/InstallerSamples/SPython/py14.pys new file mode 100644 index 000000000..294a4e6a9 --- /dev/null +++ b/InstallerSamples/SPython/py14.pys @@ -0,0 +1,17 @@ +students = [ + {"name": "Alice", "grade": "90"}, + {"name": "Bob", "grade": "85"}, + {"name": "Charlie", "grade": "92"} +] + +print(students) +print(type(students)) + +def grade_sort(d: dict[str,str]) -> int: + return int(d["grade"]) + +# отсортировать студентов по убыванию рейтинга +sorted_students = sorted(students, grade_sort, True) +print(sorted_students) + + diff --git a/InstallerSamples/SPython/py15.pys b/InstallerSamples/SPython/py15.pys new file mode 100644 index 000000000..2110689aa --- /dev/null +++ b/InstallerSamples/SPython/py15.pys @@ -0,0 +1,12 @@ +def product(a: list[int], **kwargs: int) -> list[list[int]]: + repeat = kwargs['repeat'] + if repeat == 1: + return [[a[i]] for i in range(len(a))] + prev = product(a, repeat = repeat - 1) + res: list[list[int]] = [] + for elem in a: + for p in prev: + res.append([elem] + p) + return res + +print(product([1,2,3], repeat = 3)); \ No newline at end of file diff --git a/InstallerSamples/SPython/py16.pys b/InstallerSamples/SPython/py16.pys new file mode 100644 index 000000000..ec61628fd --- /dev/null +++ b/InstallerSamples/SPython/py16.pys @@ -0,0 +1,3 @@ +import random +b = [random.randint(0, 99) for i in range(20)] +print(b) diff --git a/InstallerSamples/SPython/py2.pys b/InstallerSamples/SPython/py2.pys new file mode 100644 index 000000000..a1d2b5b03 --- /dev/null +++ b/InstallerSamples/SPython/py2.pys @@ -0,0 +1,5 @@ +def ip2int( s: str ) -> int: + n = [ int(p) for p in s.split('.') ] + return n[0]*256**3 + n[1]*256**2 + n[2]*256 + n[3] + +print(ip2int('127.0.0.1')) diff --git a/InstallerSamples/SPython/py3.pys b/InstallerSamples/SPython/py3.pys new file mode 100644 index 000000000..84ac36881 --- /dev/null +++ b/InstallerSamples/SPython/py3.pys @@ -0,0 +1,5 @@ +s = '123 456' + +res = map(int,s.split) + +print(res) diff --git a/InstallerSamples/SPython/py4.pys b/InstallerSamples/SPython/py4.pys new file mode 100644 index 000000000..1f6944f06 --- /dev/null +++ b/InstallerSamples/SPython/py4.pys @@ -0,0 +1,7 @@ +def f() -> tuple[int,int]: + return (1,1) + +print((1,2) != (2,3)) + +s = 'ds1h' +print('1' in s) diff --git a/InstallerSamples/SPython/py5.pys b/InstallerSamples/SPython/py5.pys new file mode 100644 index 000000000..4f15b7e14 --- /dev/null +++ b/InstallerSamples/SPython/py5.pys @@ -0,0 +1,15 @@ +def F( n : int) -> int: + return 1 if n == 20 else \ + 0 if n > 20 else \ + F(n+1) + F(2*n) + +graph = { 'A': {'C': 3, 'D': 1}, + 'B': {'C': 4, 'D': 5, 'E': 1}, + 'C': {'A': 3, 'B': 4, 'E': 2}, + 'D': {'A': 1, 'B': 5, 'E': 1}, + 'E': {'B': 1, 'C': 2, 'D': 1} } + +print(graph,type(graph),sep = "\n") + +#d = float(1) +#e = int('e') diff --git a/InstallerSamples/SPython/py6.pys b/InstallerSamples/SPython/py6.pys new file mode 100644 index 000000000..4166ff2ac --- /dev/null +++ b/InstallerSamples/SPython/py6.pys @@ -0,0 +1,2 @@ +for x in range(10): + print(x,end = ' ') diff --git a/InstallerSamples/SPython/py7.pys b/InstallerSamples/SPython/py7.pys new file mode 100644 index 000000000..0e7ecb2eb --- /dev/null +++ b/InstallerSamples/SPython/py7.pys @@ -0,0 +1,11 @@ +season = int(input()) +if season == 1: + print("весна") +elif season == 2: + print("лето") +elif season == 3: + print("осень") +elif season == 4: + print("зима") + + \ No newline at end of file diff --git a/InstallerSamples/SPython/py8.pys b/InstallerSamples/SPython/py8.pys new file mode 100644 index 000000000..05b6e596c --- /dev/null +++ b/InstallerSamples/SPython/py8.pys @@ -0,0 +1,3 @@ +a = [x for x in range(10) if x % 2 == 0] + +print(a) \ No newline at end of file diff --git a/InstallerSamples/SPython/py9.pys b/InstallerSamples/SPython/py9.pys new file mode 100644 index 000000000..7310d695b --- /dev/null +++ b/InstallerSamples/SPython/py9.pys @@ -0,0 +1,6 @@ +d = {'1': [1, 2]} + +if '1' in d: + print(true) + + diff --git a/InstallerSamples/SPython/random.pys b/InstallerSamples/SPython/random.pys new file mode 100644 index 000000000..a227f6e18 --- /dev/null +++ b/InstallerSamples/SPython/random.pys @@ -0,0 +1,5 @@ +#unit random +import PABCSystem + +def randint(a: int, b: int) -> int: + return PABCSystem.random(a, b) \ No newline at end of file diff --git a/InstallerSamples/SPython/random1.pys b/InstallerSamples/SPython/random1.pys new file mode 100644 index 000000000..d7e159ad4 --- /dev/null +++ b/InstallerSamples/SPython/random1.pys @@ -0,0 +1,8 @@ +#unit random +import PABCSystem + +def random() -> float: + return PABCSystem.random() + +def randint(a: int, b: int) -> int: + return PABCSystem.random(a, b) \ No newline at end of file diff --git a/InstallerSamples/SPython/set_example.pys b/InstallerSamples/SPython/set_example.pys new file mode 100644 index 000000000..0ee467c80 --- /dev/null +++ b/InstallerSamples/SPython/set_example.pys @@ -0,0 +1,11 @@ +from time import time + +s: set[int] = set() +t1 = time() + +for i in range(1, 1000000): + s |= {i} + +t2 = time() +print(t2 - t1) +print(len(s)) \ No newline at end of file diff --git a/InstallerSamples/SPython/time_measurement_example.pas b/InstallerSamples/SPython/time_measurement_example.pas new file mode 100644 index 000000000..ffe9bdad8 --- /dev/null +++ b/InstallerSamples/SPython/time_measurement_example.pas @@ -0,0 +1,18 @@ +begin + var n := 60000; + var t1 := Milliseconds; + var sm := 0.0; + var i := 1.0; + while i < n do + begin + var j := 1.0; + while j < n do + begin + sm += 1.0 / i / j; + j += 1; + end; + i += 1; + end; + var t2 := Milliseconds; + print(t2 - t1); +end. \ No newline at end of file diff --git a/InstallerSamples/SPython/time_measurement_example.pys b/InstallerSamples/SPython/time_measurement_example.pys new file mode 100644 index 000000000..fe054776e --- /dev/null +++ b/InstallerSamples/SPython/time_measurement_example.pys @@ -0,0 +1,16 @@ +import time + +n = 60000 +start = time.time() +sm: float = 0 + +i = 1.0 +while i < n: + j = 1.0 + while j < n: + sm += 1.0 / i / j + j += 1 + i += 1 + +end = time.time(); +print(end - start) \ No newline at end of file diff --git a/InstallerSamples/SPython/unit_example.pys b/InstallerSamples/SPython/unit_example.pys new file mode 100644 index 000000000..a70ba349b --- /dev/null +++ b/InstallerSamples/SPython/unit_example.pys @@ -0,0 +1,18 @@ +# Рекурсивная функция вычисления факториала +def factorial(n: int)-> bigint: + if n == 0: + return 1 + return n * factorial(n - 1) + + +# Не рекурсивная функция вычисления числа Фибоначчи +def fibonacci(n: int)-> bigint: + if n <= 1: + return n + f1: bigint = 0 + f2: bigint = 1 + for i in range(n - 1): + t = f1 + f2 + f1 = f2 + f2 = t + return f2 diff --git a/InstallerSamples/SPython/unit_use_example.pas b/InstallerSamples/SPython/unit_use_example.pas new file mode 100644 index 000000000..fc31a373d --- /dev/null +++ b/InstallerSamples/SPython/unit_use_example.pas @@ -0,0 +1,15 @@ +Uses unit_example; + +const N: integer = 10; + +begin + println('Последовательность чисел Фибоначчи:'); + for var i := 1 to N do + println('F(' + i + ')=', fibonacci(i)); + println(); + + println('Последовательность факториалов:'); + for var i := 1 to N do + println(i + '!=', factorial(i)); + println(); +end. diff --git a/InstallerSamples/SPython/unit_use_example.pys b/InstallerSamples/SPython/unit_use_example.pys new file mode 100644 index 000000000..87308e0eb --- /dev/null +++ b/InstallerSamples/SPython/unit_use_example.pys @@ -0,0 +1,19 @@ +from unit_example import fibonacci as F, factorial as fact + +N = 10 + +fibs = [F(i) for i in range(1, N + 1)] +print("Последовательность чисел Фибоначчи:") +i = 0 +for fib_num in fibs: + i += 1 + print('F(' + str(i) + ')\t=', fib_num) +print() + +facts = [fact(i) for i in range(1, N + 1)] +print("Последовательность факториалов:") +i = 0 +for fact_num in facts: + i += 1 + print(str(i) + '!\t=', fact_num) +print() \ No newline at end of file diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 1f666d4e0..04b44a18f 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.11.0.3654 +3.11.0.3661 diff --git a/ReleaseGenerators/PascalABCNET_end.nsh b/ReleaseGenerators/PascalABCNET_end.nsh index f92427a5b..12a1430fe 100644 --- a/ReleaseGenerators/PascalABCNET_end.nsh +++ b/ReleaseGenerators/PascalABCNET_end.nsh @@ -80,6 +80,10 @@ SectionEnd LangString DESC_Minimal ${LANG_ENGLISH} "Minimal" LangString DESC_PascalABCNET_Language ${LANG_RUSSIAN} "Язык PascalABC.NET" LangString DESC_PascalABCNET_Language ${LANG_ENGLISH} "PascalABC.NET language" + + LangString DESC_SPython_Language ${LANG_RUSSIAN} "Язык SPython" + LangString DESC_SPython_Language ${LANG_ENGLISH} "SPython language" + LangString DESC_Compiler ${LANG_RUSSIAN} "Компилятор" LangString DESC_Compiler ${LANG_ENGLISH} "Compiler" LangString DESC_Envr ${LANG_RUSSIAN} "Оболочка" diff --git a/ReleaseGenerators/PascalABCNET_sections.nsh b/ReleaseGenerators/PascalABCNET_sections.nsh index a0816670a..e10187383 100644 --- a/ReleaseGenerators/PascalABCNET_sections.nsh +++ b/ReleaseGenerators/PascalABCNET_sections.nsh @@ -2,6 +2,7 @@ SectionGroup $(DESC_InputLanguages) Languages !include sect_PascalABCParser.nsh + !include sect_SPythonParser.nsh SectionGroupEnd SectionGroup $(DESC_Envr) Envr diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index d43638537..1079ce7ea 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.11.0.3654' +!define VERSION '3.11.0.3661' diff --git a/ReleaseGenerators/RebuildStandartModulesSPython.pas b/ReleaseGenerators/RebuildStandartModulesSPython.pas new file mode 100644 index 000000000..5f358b84a --- /dev/null +++ b/ReleaseGenerators/RebuildStandartModulesSPython.pas @@ -0,0 +1,11 @@ +uses + // SPython + //SPythonSystem, SPythonHidden, + time1, + SPythonSystemPys, itertools, math + ; + +begin + writeln(cos(pi)); + readln; +end. \ No newline at end of file diff --git a/ReleaseGenerators/sect_Core.nsh b/ReleaseGenerators/sect_Core.nsh index c8afa344f..2fb572e23 100644 --- a/ReleaseGenerators/sect_Core.nsh +++ b/ReleaseGenerators/sect_Core.nsh @@ -179,6 +179,13 @@ File ..\bin\Lib\Tasks1Arr.pcu File ..\bin\Lib\WPF.pcu + File ..\bin\Lib\SPythonHidden.pcu + File ..\bin\Lib\SPythonSystem.pcu + File ..\bin\Lib\time1.pcu + File ..\bin\Lib\SPythonSystemPys.pcu + File ..\bin\Lib\itertools.pcu + File ..\bin\Lib\math.pcu + File ..\bin\Lib\PABCRtl.dll File ..\bin\Lib\HelixToolkit.Wpf.dll File ..\bin\Lib\HelixToolkit.dll @@ -271,6 +278,13 @@ ${AddFile} "Tasks1Arr.pcu" ${AddFile} "WPF.pcu" + ;SPython + ${AddFile} "SPythonHidden.pcu" + ${AddFile} "SPythonSystem.pcu" + ${AddFile} "time1.pcu" + ${AddFile} "SPythonSystemPys.pcu" + ${AddFile} "itertools.pcu" + ${AddFile} "math.pcu" ${AddFile} "turtle.png" @@ -379,6 +393,15 @@ File ..\bin\Lib\Мозаика.pas File ..\bin\Lib\WPF.pas + ;SPython + File ..\bin\Lib\SPythonHidden.pas + File ..\bin\Lib\SPythonSystem.pas + File ..\bin\Lib\time1.pas + + File ..\bin\Lib\SPythonSystemPys.pys + File ..\bin\Lib\itertools.pys + File ..\bin\Lib\math.pys + File ..\bin\Lib\__RedirectIOMode.vb File ..\bin\Lib\VBSystem.vb @@ -458,6 +481,15 @@ ${AddFile} "Мозаика.pas" ${AddFile} "WPF.pas" + ;SPython + ${AddFile} "SPythonHidden.pas" + ${AddFile} "SPythonSystem.pas" + ${AddFile} "time1.pas" + + ${AddFile} "SPythonSystemPys.pys" + ${AddFile} "itertools.pys" + ${AddFile} "math.pys" + ${AddFile} "__RedirectIOMode.vb" ${AddFile} "VBSystem.vb" diff --git a/ReleaseGenerators/sect_SPythonParser.nsh b/ReleaseGenerators/sect_SPythonParser.nsh new file mode 100644 index 000000000..3e14d57be --- /dev/null +++ b/ReleaseGenerators/sect_SPythonParser.nsh @@ -0,0 +1,48 @@ +Section $(DESC_SPython_Language) SPythonSection + SectionIn 1 2 + + ; Установка файлов SPython + SetOutPath "$INSTDIR" + File "..\bin\SPythonParser.dll" + File "..\bin\SPythonLanguageInfo.dll" + File "..\bin\SPythonStandardTreeConverter.dll" + File "..\bin\SPythonSyntaxTreeVisitor.dll" + + ${AddFile} "SPythonParser.dll" + ${AddFile} "SPythonLanguageInfo.dll" + ${AddFile} "SPythonStandardTreeConverter.dll" + ${AddFile} "SPythonSyntaxTreeVisitor.dll" + + ; Файл подсветки синтаксиса + SetOutPath "$INSTDIR\Highlighting" + File "..\bin\Highlighting\SPython.xshd" + ${AddFile} "SPython.xshd" + + ; Оптимизация .NET библиотек через NGEN + SetOutPath "$INSTDIR" + Push "SPythonParser.dll" + Call NGEN + Push "SPythonLanguageInfo.dll" + Call NGEN + Push "SPythonStandardTreeConverter.dll" + Call NGEN + Push "SPythonSyntaxTreeVisitor.dll" + Call NGEN + + DeleteRegKey HKCR "pys" + ;insalling pys file type + ReadRegStr $R0 HKCR ".pys" "" + StrCmp $R0 "PascalABCNET.SPythonParser" 0 +2 + DeleteRegKey HKCR "PascalABCNET.SPythonParser" + WriteRegStr HKCR ".pys" "" "PascalABCNET.SPythonParser" + WriteRegStr HKCR "PascalABCNET.SPythonParser" "" "SPython Program" + WriteRegStr HKCR "PascalABCNET.SPythonParser\DefaultIcon" "" "$INSTDIR\Ico\pas.ico" + ReadRegStr $R0 HKCR "PascalABCNET.SPythonParser\shell\open\command" "" + StrCmp $R0 "" 0 no_nshopen + WriteRegStr HKCR "PascalABCNET.SPythonParser\shell" "" "open" + WriteRegStr HKCR "PascalABCNET.SPythonParser\shell\open\command" "" '"$INSTDIR\PascalABCNET.exe" "%1"' + no_nshopen: + WriteRegStr HKCR "PascalABCNET.SPythonParser\shell\compile" "" "Компилировать" + WriteRegStr HKCR "PascalABCNET.SPythonParser\shell\compile\command" "" '"$INSTDIR\pabcnetc.exe" "%1"' + +SectionEnd \ No newline at end of file diff --git a/_GenerateAllSetups.bat b/_GenerateAllSetups.bat index 52e0e6c30..023f69e00 100644 --- a/_GenerateAllSetups.bat +++ b/_GenerateAllSetups.bat @@ -18,6 +18,7 @@ dotnet build -c Release --no-incremental PascalABCNET.sln cd ReleaseGenerators ..\bin\pabcnetc RebuildStandartModules.pas /rebuild +..\bin\pabcnetc RebuildStandartModulesSPython.pas @IF %ERRORLEVEL% NEQ 0 GOTO ERROR cd PABCRtl @@ -33,6 +34,7 @@ ExecHide.exe gacutil.exe /u PABCRtl ExecHide.exe gacutil.exe /i ..\bin\Lib\PABCRtl.dll ..\bin\pabcnetc RebuildStandartModules.pas /rebuild +..\bin\pabcnetc RebuildStandartModulesSPython.pas @IF %ERRORLEVEL% NEQ 0 GOTO ERROR diff --git a/bin/Lib/time1.pas b/bin/Lib/time1.pas new file mode 100644 index 000000000..8731ff81f --- /dev/null +++ b/bin/Lib/time1.pas @@ -0,0 +1,15 @@ +unit time1; + +interface + +function time(): real; + +function forty_two(): real; + +implementation + +function time() : real := DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; + +function forty_two() : real := 42; + +end. \ No newline at end of file