Commit graph

299 commits

Author SHA1 Message Date
AlexanderZemlyak c2111cf375
Change type of language field in syntax tree to be string (#3119)
* Change syntax tree language field to be string

Тип LanguageId заменен на string

* Fix unit language name assigning

* Update lexer and parser

* Add checks to avoid NullReferenceException

Проверки на null для SyntaxTree. (К падению компилятора они не приводили, т.к. они связаны с другими ошибками, например синтаксическими), но мешали отладке.

* Return initial lexer and parser versions

* Revert language name assigning
2024-05-28 14:16:49 +03:00
AlexanderZemlyak 8acf536300
Make changes for spython compatibility (#3131)
* Update parser tools

* Update NodesBuilder

* Update syntax_tree_visitor

* Update CompilationErrors
2024-05-28 14:16:03 +03:00
AlexanderZemlyak efb4a4338f
New checks for directives added (#3099)
* Extract base classes from ParserTools (local) and GPPGParserHelper

* Fix string resources error

* Extract base class for unexpected token error

* Update ParserTools project file

* Add comments for compiler directives usages in compiler

* Add directives checks

* Move string constants to new project

* Implement scalable directives checks

* Remove known directives from compiler

* Fix PABCSystem namespace error

* Allow region and endregion with no params

* Allow parameters to endif directive

* Delete directive parameters extension checks

* Replace error with warning for uknown directive case

* Fix generate native code (semantic rule) assigning

* Improve error messages for directives

* Rename RunParseThread to SwitchOnIntellisence

Для отладки может требоваться отключение Intellisence на уровне кода. Для понятности метод назван SwitchOnIntellisence.

* Resolve merge conflicts

* Add new compiler errors for unsupported target framework and output file type

* Add documentation to directives checks

* Fix directives check loop
2024-05-04 20:21:50 +03:00
Mikhalkovich Stanislav f2d4637338 assign с first_assignment_defines_type и тестовым примером 2024-03-29 13:53:46 +03:00
Mikhalkovich Stanislav c66bfa7d92 Многострочные строковые литералы 2024-03-21 21:21:59 +03:00
Mikhalkovich Stanislav 4bf9c36d49 Исправление реализации (var b := 1) методом синтаксического сахара 2024-01-02 14:43:48 +03:00
Mikhalkovich Stanislav 30668e650a function f(n: integer): integer;
begin
  if n = 0 then Result := 1
  else Result := n*f(n-1);
end;

begin
  var a := (var b := f(5)) + b;
  Print(a,b);
end.
2023-12-31 21:56:13 +03:00
AlexanderZemlyak 0c29ac92b2
Refactoring of Compiler.cs (#2984)
* Add first comments

* Finish commenting for Compile and CompileUnit

* Write TODO sections

* Add a few clarifications

* splitted some functions from compile

* Written some methods from Compile to functions

* Update variable names

* Refactor - stage 1

Refactor GetUsesSection and IsPossibleNameSpace

* Refactor - stage 2

Rename a few functions and variables

* Correct an inaccuracy

* Added comments, look through CompileUnit

* Rename a few functions and add new comments

* Split CompileUnit to Subfunctions

Add IsUnitCompiled, IsUnitInPCU, InitializeNewUnit, GetSourceCode, GenSyntaxTree, GenUnitDocumentation, CheckDLLDirectiveOnlyForLibraries, MatchErrorsToBadNodes, CheckIfUnitModule, SetUseDLLForSystemUnits,
CompileInterfaceDependencies, CompileCurrentUnitInterface, GetImplementationUsesSection, CompileImplementationDependencies, CompileCurrentUnitImplementation

* Added some TODOs

* Return uses_unit_in original name

Renaming of syntax tree nodes leads to internal compiler errors

* Extract GenerateILCode method

* Add checking if recompilation needed method

Needs to be discussed and revised

* Add functions for catch blocks in Compile

* Extract building semantic tree method

Creating main function to be moved to another class

* Rename UnitsSortedList

* Edit CompileUnitsFromDelayedList method

* Change a few variable names, make CreateRCFile function and add comments

* Make code more "user-friendly"

* Add TODOs 31.11.23

* Create PrebuildSemanticTreeActionsMethod

* Refactor semantic checks section in initialize new unit method

* Refactor Adding standard units to uses method

* Return file_name and compiler_directives original names to avoid internal compilation errors

* Refactor GetReferences Method

* Initial refactoring of IncludeNamespaces function

* Create three more methods and wrap important code in regions

* Add TODO's

* Resolve merge conflicts

* Add returned value to ConstructSyntaxTree method

* Fix UnitsSortedList NotFoundError in PCUWriter

* Workaround commit

* Update PABCSystem after tests' changes

* Rename syntax trees in some methods

* Delete CurrentSyntaxUnit variable

* Revert unnecessary project files changes

* Squashed commit of the following:

commit f4d7599f1a39252feac97bd5391f46dfdc25f6f4
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 22 11:43:29 2023 +0300

    added links to identarranger

commit 3bd5d33e2b2969884e61a3279ff9c353013b57fe
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 22 11:43:03 2023 +0300

    Change extension for verybasic to yavb

commit 61294c6e7d405e1c68516cc81d3a109e8a1ee295
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Tue Nov 21 09:33:57 2023 +0300

    Change Program Example

commit 86971488341ed6bf13c39e13a513d7ac0c51c285
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Tue Nov 21 09:28:59 2023 +0300

    Add IndentArranger to Compile

commit 2ce50bbbf9db22c4243b247b870f6935ce206d26
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Fri Nov 17 10:00:31 2023 +0300

    Add Semicolon After Each Statement

commit 796309d340e8d8ba730ff9418fa376f34fb7fd36
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Wed Nov 15 18:49:11 2023 +0300

    Add Alpha Version of Python-style If-statement

commit 5eb88f946fe8254b4f5c5a56ed0a567b3be51227
Merge: ab4ce5b0 0162b637
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 15 16:54:26 2023 +0300

    Merge branch 'IndentArranger' into VeryBasicLanguage

commit ab4ce5b0e32d42004726e3dc45cc0d8a65e53f56
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 15 16:53:51 2023 +0300

    Fixes from seminar

commit af74012289d0d08517c13499a2a66cb543fc06d2
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Sun Nov 12 18:57:29 2023 +0300

    finally working!

    fully implemented compatibility

commit 58a39c313324b468d1eec207ba3f5f6eddf74ef2
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Sun Nov 12 11:58:16 2023 +0300

    more compatibility with pabc

    Now verybasic statements translate to pascal compiler
    added .bat script for autobuilding verybasic

commit 0162b6376b8fe970704f26213bf9f0f670dfb12e
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Sun Nov 12 10:06:14 2023 +0300

    Update test.txt

commit 1b759ab1cd7ee2ffeb14afff0418ddf0f30b0399
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Sun Nov 12 10:05:36 2023 +0300

    Add Indent and Unindent Keywords to Generated File

commit cabda7f3985651cff2a8740f1a5bdea8fe7ac892
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Fri Nov 10 21:25:52 2023 +0300

    Add Generation of Output File

commit 306f033d0176ab559e3622b8505427dbe2e0e203
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Thu Nov 9 20:42:18 2023 +0300

    Update IndentArranger.sln

commit 60c0ceced1aa3a7d2e33de0facb1126e295f43b5
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Thu Nov 9 20:41:22 2023 +0300

    Add IndentArranger

commit 1f4556c4573dae154fcc167b41ff6ab9e8122136
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Mon Nov 6 22:48:36 2023 +0300

    Made my own VeryBasicParser project

    Copied some code from SaushkinParser
    Tried to compile it and implement into Pascal
    Doesn't work due to grammatik issue

* Squashed commit of the following:

commit 4e73d9ac3ffef68312f06a74dc83afffcf3ccbee
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 22 15:08:10 2023 +0300

    Fixed GPPG (i think so at least)

commit e5cfc220828b37fb2f35e565683019716ec3f0ce
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 22 11:44:27 2023 +0300

    Update Compiler.cs

commit 4698e2e75a5f3b4f523a8bc7733a50e8abb4fca1
Merge: 22aaf2b2 f4d7599f
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 22 11:43:54 2023 +0300

    Merge branch 'IndentArrangerTemp' into VeryBasicLanguage

commit f4d7599f1a39252feac97bd5391f46dfdc25f6f4
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 22 11:43:29 2023 +0300

    added links to identarranger

commit 3bd5d33e2b2969884e61a3279ff9c353013b57fe
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 22 11:43:03 2023 +0300

    Change extension for verybasic to yavb

commit 22aaf2b2508278a9ffce525ffed52419bf72c23f
Merge: c326174f 61294c6e
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 22 11:26:36 2023 +0300

    Merge branch 'IndentArrangerTemp' into VeryBasicLanguage

commit 61294c6e7d405e1c68516cc81d3a109e8a1ee295
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Tue Nov 21 09:33:57 2023 +0300

    Change Program Example

commit 86971488341ed6bf13c39e13a513d7ac0c51c285
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Tue Nov 21 09:28:59 2023 +0300

    Add IndentArranger to Compile

commit c326174ff5ecccf9c4f76d58aea4653f047af049
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Sun Nov 19 15:03:19 2023 +0300

    Added UniversalParserHelper and GPPG

    ShiftReduceParser moved to another project
    UniversalParserHelper project added, most of it copied from SaushkinParser

commit 2ce50bbbf9db22c4243b247b870f6935ce206d26
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Fri Nov 17 10:00:31 2023 +0300

    Add Semicolon After Each Statement

commit 796309d340e8d8ba730ff9418fa376f34fb7fd36
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Wed Nov 15 18:49:11 2023 +0300

    Add Alpha Version of Python-style If-statement

commit 5eb88f946fe8254b4f5c5a56ed0a567b3be51227
Merge: ab4ce5b0 0162b637
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 15 16:54:26 2023 +0300

    Merge branch 'IndentArranger' into VeryBasicLanguage

commit ab4ce5b0e32d42004726e3dc45cc0d8a65e53f56
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Wed Nov 15 16:53:51 2023 +0300

    Fixes from seminar

commit af74012289d0d08517c13499a2a66cb543fc06d2
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Sun Nov 12 18:57:29 2023 +0300

    finally working!

    fully implemented compatibility

commit 58a39c313324b468d1eec207ba3f5f6eddf74ef2
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Sun Nov 12 11:58:16 2023 +0300

    more compatibility with pabc

    Now verybasic statements translate to pascal compiler
    added .bat script for autobuilding verybasic

commit 0162b6376b8fe970704f26213bf9f0f670dfb12e
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Sun Nov 12 10:06:14 2023 +0300

    Update test.txt

commit 1b759ab1cd7ee2ffeb14afff0418ddf0f30b0399
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Sun Nov 12 10:05:36 2023 +0300

    Add Indent and Unindent Keywords to Generated File

commit cabda7f3985651cff2a8740f1a5bdea8fe7ac892
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Fri Nov 10 21:25:52 2023 +0300

    Add Generation of Output File

commit 306f033d0176ab559e3622b8505427dbe2e0e203
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Thu Nov 9 20:42:18 2023 +0300

    Update IndentArranger.sln

commit 60c0ceced1aa3a7d2e33de0facb1126e295f43b5
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date:   Thu Nov 9 20:41:22 2023 +0300

    Add IndentArranger

commit 1f4556c4573dae154fcc167b41ff6ab9e8122136
Author: Владислав Крылов <krylov@sfedu.ru>
Date:   Mon Nov 6 22:48:36 2023 +0300

    Made my own VeryBasicParser project

    Copied some code from SaushkinParser
    Tried to compile it and implement into Pascal
    Doesn't work due to grammatik issue

* Changed GPPG project NET Framework version, added .dll to gitignore

* Adding UniversalParserHelper to project, trying to include VeryBasic

* Managed dependencies and got VeryBasicLanguage to work

* Change extension of a test program

* Rebuild changes

What should be added to .gitignore?

* Fix bug related to err0524_res_unit.pas

* Rebuild Parser

* Change Indent and Unindent tokens

* Add Symbol Table to ParserABC.y

* Change Indent Space Number to 2

* Add While Loop

* Add Some Operations to Parser

* Make Initialization Node at the Beginning of a program

* Create Grammar.txt

* Test program added

* Add ELIF and SyntaxHighlight

* Fix TableSymbol

* Add Division

* Add Method Call

* Add For Loop

* Rename SPython Parser Folder

* Add documented comments for CompileUnit method

* Added Errors to SPython

Added Errors.cs
Removed link to PABCSaushkinParser
Minor fixes

* Create default constructor for SourceContext

* Move null check of currentUnit to upper level in CompileUnit

* Move CreateMainFunction method from Compiler to TreeConverter class

* Add gppg and parserhelper to visualpascalabcnet dependencies

* Updated installer files to include GPPG and UniversalParserHelper

* Rename GPPG to ShiftReduceParser

* Fix ShiftReduceParser project dependencies

* Fix ShiftReduceParserDependencies second iteration

* Workaround commit

* Update PABCSystem after tests' changes

* Refactor ConvertDirectives method

* Get rid of legacy standard modules code

* Return varBeginOffset and beginOffset calculation to Compiler class

Размещение метода в SyntaxTreeToSemanticTreeConverter не целесообразно. В комментарии видимо имелось в виду что-то другое.

* Workaround commit

* Update PABCSystem after tests' changes

* Revert SPython changes

Оставляем только изменения связанные с рефакторингом.

* Update .gitignore

Co-authored-by: Sun Serega <sunserega2@gmail.com>

* Resolve a few Sun Serega treds

* Delete comments in ParsersController.cs

* Replace specific path with path variable in Studio.bat

* Add comment in Studio.bat file and return FileName in CompilerError.cs

* Fix TreeSubsidiary.cs encoding and sectCore.nsh indents

* Return old version of TestRunner.exe

* Rename some variables and polish a few methods

* Uncomment accidentally commented code

* Replace spaces with tabs

* Changed dll name from GPPG

* Revert "Changed dll name from GPPG"

This reverts commit c485cc8cb787809b7e9dfa8a361e75f17ed39893.

* Update .gitignore

* Delete Libraries/ShiftReduceParser.dll

* Delete bin\ShiftReduceParser.dll

* Replace tabs with spaces

* Update encoding in Studio.bat

* Fix bug with PABCrtl excluded files

* Refactor StandardModule class

* Add null checks to make debuging easier

* Delete unnecessary null checks in SymTable.cs

---------

Co-authored-by: Владислав Крылов <krylov@sfedu.ru>
Co-authored-by: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Co-authored-by: Sun Serega <sunserega2@gmail.com>
2023-12-18 22:33:27 +03:00
Mikhalkovich Stanislav 771e1f799c первая версия async в грамматике 2023-12-08 19:37:39 +03:00
Mikhalkovich Stanislav 90a8c6f944 ref_var_def_statement в Syntax Tree для развертывания кортежного присваивания 2023-11-01 22:49:09 +03:00
Sun Serega 7132c64f1e gitignore rework 2023-08-14 00:17:41 +03:00
Mikhalkovich Stanislav af9b6acb91 Ликвидация зависимости проектов PascalABCSaushkinParser и SyntaxVisitors от
проекта TreeConverter, то есть, от семантического уровня

Необходимо применить эти изменения и перекомпилировать в ОС РОСА
2023-05-31 14:04:04 +03:00
Mikhalkovich Stanislav 232f3a2238 lambda_any_type_node_syntax 2023-05-31 10:06:04 +03:00
Mikhalkovich Stanislav 03dea1990c Ускорен (a,b) := (b,a) - работает как Swap 2023-05-16 15:36:00 +03:00
Mikhalkovich Stanislav 49c432411a Именованные аргументы.
Малое покрытие тестами
2023-05-04 23:58:43 +03:00
Mikhalkovich Stanislav 308da7ab5c UnknownID в yield_unknown_ident сделал генерируемым автоматически 2022-08-04 11:19:54 +03:00
Ivan Bondarev 8a9a56f989 #2685 2022-07-24 13:52:14 +02:00
Mikhalkovich Stanislav 3240593d2e Реализован foreach index
Исправлена ошибка for step
Дополнена справка по for step и foreach index
J,yjdkty ntrcnjdsq htlfrnjh? gjlcdtxbdf.obq ыеуз b штвуч rjyntrcnyj d hfvrf[ jlyjq cnhjrb
2022-02-26 12:33:53 +03:00
Mikhalkovich Stanislav aece73f33c for var i:=1 to 5 step 2 do 2022-02-21 17:03:34 +03:00
Ivan Bondarev 4a70f38e39 #2630 2022-02-06 14:30:31 +01:00
Mikhalkovich Stanislav 521895feb7 fix #2570
Изменил имена полей автоклассов на начинающиеся с <f>
2021-11-28 19:04:22 +03:00
Mikhalkovich Stanislav 70576addb0 not in
if (System.Environment.OSVersion.Version.Major >= 6) and (System.Environment.OSVersion.Version.Minor >= 2) then System.Console.OutputEncoding := Encoding.UTF8;

School - таблица истинности - доп. параметр
2021-09-23 18:29:37 +03:00
Mikhalkovich Stanislav de55f99304 Различные ограничения на функции с параметром [Cache] 2021-08-09 22:37:53 +03:00
Mikhalkovich Stanislav 1438b620ab Новsй узел expression_with_let_semantic, expression_with_let_semantic
для конструкции вида
procedure p(b: integer := (var x := b*b; x*x+x-1));
2021-06-29 12:02:42 +03:00
Mikhalkovich Stanislav 450e629598 IsDataClass поле 2021-05-29 14:31:26 +03:00
Mikhalkovich Stanislav 2eaaa1f6cd fix #2482 2021-05-05 23:31:17 +03:00
Mikhalkovich Stanislav 46c439e99e fix #2366 2021-04-24 08:52:13 +03:00
Ivan Bondarev 18e948a328 Merge branch 'master' of https://github.com/pascalabcnet/pascalabcnet
# Conflicts:
#	Parsers/PascalABCParserNewSaushkin/ABCPascal.cs
#	Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs
2021-03-28 14:10:45 +02:00
Ivan Bondarev 31cf309e4e fix #2038
fix #2033
2021-03-28 14:08:47 +02:00
Mikhalkovich Stanislav f85758a059 Исправлена ошибка при распаковке параметров лямбд с несколькими параметрами
Divizors переименован в Divisors
2021-03-26 00:12:48 +03:00
Mikhalkovich Stanislav 4a96036947 work 2021-03-24 12:10:55 +03:00
Mikhalkovich Stanislav 68e50baf9d UsesPath перенёс в TreeHelper.cs т.к. Tree/cs перегенерируется автоматически 2021-03-21 21:17:21 +03:00
Ivan Bondarev 734bbc060f #2035 2021-03-21 14:50:57 +01:00
Mikhalkovich Stanislav 65e7bb188b иСПРАВЛЕН S.ReadInteger(FROM) - теперь с нуля
function_lambda_definition - добавлено поле для неупакованных параметров \(x,y)
Добавлен сахарный визитор - пока для неупакованных параметрво в лямбде - идентификаторов
В грамматике добавлены lambda_unpacked_params
В StandardSyntaxConverter.cs добавлена UnpackLambdaParametersVisitor.New.ProcessNode(root);
2021-03-07 14:03:58 +03:00
Mikhalkovich Stanislav 7c3273aae8 Многомерные срезы без семантических проверок
Разрешил a as array [,] of T
2021-02-24 00:47:39 +03:00
Mikhalkovich Stanislav b1323a6e0e slice-expr - подготовка к слайсам в многомерных массивах 2021-02-22 21:26:52 +03:00
Ivan Bondarev 9a026595ec
Merge pull request #2246 from SunSerega/uses-in-new
Re: Адекватные uses-in
2021-01-24 10:45:03 +01:00
Mikhalkovich Stanislav 6553f62573 fix #2376
Permutations Combinations Cartesian для последовательностей
2021-01-07 14:12:06 +03:00
SunSerega 8c4c5e2d8f Merge branch 'master' into uses-in-new 2020-12-10 21:08:44 +02:00
Mikhalkovich Stanislav 390b4b8a95 расширенный foreach - семантика 2020-12-03 23:08:23 +03:00
Mikhalkovich Stanislav 02c92a378d Форматирование расширенного foreach 2020-11-28 13:07:03 +03:00
SunSerega 2a7d0b10b5 Merge branch 'master' into uses-in-new 2020-11-22 18:00:13 +02:00
Mikhalkovich Stanislav e3b59ae5a1 Константы 123bi
В модуле School - ToBase(BigInteger)
2020-11-20 14:23:49 +03:00
SunSerega bbb4b169dd Merge branch 'master' into uses-in-new 2020-09-27 19:49:37 +03:00
Mikhalkovich Stanislav fc234f7cc4 Исправление ошибки с захватом лямбдой переменной, объявленной в виде var (m,n) := ... 2020-08-15 22:56:19 +03:00
Mikhalkovich Stanislav dc23f3eadd Залил код, в результате которого падает сборка
В принципе, чтобы вернуть - в трёх visit восстановить вначале AddError и включить синтаксический визитор AssignVarTuple

Ещё - ABCStatisticsVisitors.cs - когда откатим - не удалять
2020-08-15 10:14:47 +03:00
Mikhalkovich Stanislav c0906732a5 Правки в Controls и примерах
Исправления ошибок в параметрах Pyramid Prism в Graph3D
2020-08-03 21:26:25 +03:00
Mikhalkovich Stanislav 15a9445216 x → x (стрелочка :))
|1,2,3|.Print
2020-07-29 11:29:51 +03:00
SunSerega 855bf972b7 folder priority when searching module files 2020-07-17 01:58:34 +03:00
Mikhalkovich Stanislav 0c6ff2a3ee fix #2276 2020-07-14 18:55:14 +03:00