polserver/pol-core/bscript/compiler/astbuilder
Kevin Eady 5cf6949ea7
Add support for regular expressions (#818)
* implementation

* tests

* maybe fix windows compilation?

* undo change of match_flag_type

* switch to boost regex

* move flags to BRegExp object

* fix tests due to cmake 4 update

* update grammar

* update prettifier

* move flag parsing to BRegExp ctor

* add AST nodes, update instr generation and execution

* copy tests but use regular expression literals

* fix grammar for handling division correctly

* modify return values a bit, update tests
- string.match: make groups hold structs of matched, offset
- string.match: add offset
- string.replace: use a groups array like string.match vs individual arguments

* bundle of changes

- standardize error messages
- add more tests for coverage
- move BRegExp creation to static method:  previous implementation had
  ctor throwing, which was no good inside executor since it didn't have
  a try/catch

* more tests; add OT_REGEXP to basic.em

* move string regex stuff to bregexp and support regex/wregex via std::visit

* maybe fix compilation errors?

* add unicode escape sequence handling

* really maybe fix compilation error?

* fix compiler warnings

* refactor a bit to remove duplicate code

* address discord comments
- just return wstring, no need for vector<wchar_t> method

* Add string.split by string and regexp

* Use Max_Split instead of Limit
This makes it match basic::SplitWords

* add support for empty string delim in SplitWords

* remove duplicate code across string.split and mf_SplitWords

* Squashed commit of the following:

commit b3148e069f
Author: turleypol <turley@polserver.com>
Date:   Sat Sep 27 17:02:22 2025 +0200

    memorylocation of input string is not allowed to changed, switched back
    to uniqueptr

commit 5a4d1c8fcb
Author: turleypol <turley@polserver.com>
Date:   Sat Sep 27 10:18:01 2025 +0200

    no need to use ptr for input

commit 90fa0edc66
Author: turleypol <turley@polserver.com>
Date:   Sat Sep 27 09:56:29 2025 +0200

    fixed typo

commit bed4ff3ac9
Author: turleypol <turley@polserver.com>
Date:   Sat Sep 27 09:47:36 2025 +0200

    make Callback for BContinuation move only

* use uninit when group isn't matched

* fix multiline flag handling; add test

* add docs and doc example tests

* some cleanup

* address review comments
- allow move assignment

* add core-changes
2025-11-17 18:02:45 +01:00
..
AvailableParseTree.cpp Generate constructors for child classes (#703) 2024-10-10 18:06:04 +02:00
AvailableParseTree.h Generate constructors for child classes (#703) 2024-10-10 18:06:04 +02:00
BuilderWorkspace.cpp Add Escript support for enum class (#804) 2025-08-18 20:50:18 +02:00
BuilderWorkspace.h Properly scope the compiler includes to the Bscript folder. (#360) 2021-02-25 16:53:22 +01:00
CompilerWorkspaceBuilder.cpp Fix generated function (constructor, super) registration (#809) 2025-09-04 17:37:40 +00:00
CompilerWorkspaceBuilder.h Internal work to remove OGC (#384) 2021-03-06 01:39:26 +01:00
CompoundStatementBuilder.cpp Enum class fixes (#805) 2025-08-19 09:07:02 +02:00
CompoundStatementBuilder.h Properly scope the compiler includes to the Bscript folder. (#360) 2021-02-25 16:53:22 +01:00
ExpressionBuilder.cpp Add support for spread operator in dictionary and struct initializers; FormatterEllipsisSpacing formatter option (#763) 2025-02-19 18:33:56 +01:00
ExpressionBuilder.h Fix super-scoped function resolution; Fix SourceLocation for scoped function calls (#730) 2024-10-25 11:20:41 +02:00
FunctionResolver.cpp Fix generated function (constructor, super) registration (#809) 2025-09-04 17:37:40 +00:00
FunctionResolver.h Fix generated function (constructor, super) registration (#809) 2025-09-04 17:37:40 +00:00
GeneratedFunctionBuilder.cpp Fix handling of byref, rest, and default parameters in uninitialized functions (#814) 2025-09-06 17:26:06 +02:00
GeneratedFunctionBuilder.h Generate constructors for child classes (#703) 2024-10-10 18:06:04 +02:00
ModuleDeclarationBuilder.cpp Fix handling of byref, rest, and default parameters in uninitialized functions (#814) 2025-09-06 17:26:06 +02:00
ModuleDeclarationBuilder.h Properly scope the compiler includes to the Bscript folder. (#360) 2021-02-25 16:53:22 +01:00
ModuleProcessor.cpp Properly scope the compiler includes to the Bscript folder. (#360) 2021-02-25 16:53:22 +01:00
ModuleProcessor.h Move more specialized expression types from optimizer to AST builder (#334) 2020-09-30 08:19:05 -07:00
ProgramBuilder.cpp Properly scope the compiler includes to the Bscript folder. (#360) 2021-02-25 16:53:22 +01:00
ProgramBuilder.h Properly scope the compiler includes to the Bscript folder. (#360) 2021-02-25 16:53:22 +01:00
SimpleStatementBuilder.cpp Enum class fixes (#805) 2025-08-19 09:07:02 +02:00
SimpleStatementBuilder.h Add support for sequence and index bindings (#760) 2025-02-17 21:59:42 +01:00
SimpleValueCloner.cpp Add support for spread operator in dictionary and struct initializers; FormatterEllipsisSpacing formatter option (#763) 2025-02-19 18:33:56 +01:00
SimpleValueCloner.h Fix varargs in constructors with super; Remove restriction that base-classes must be constructable (#698) 2024-10-10 18:06:04 +02:00
SourceFileProcessor.cpp Changes to default construction and base-class semantic analysis (#693) 2024-10-10 18:06:04 +02:00
SourceFileProcessor.h Update grammar, parser, semantic analyzer for classes; skeleton codegen and executor (#688) 2024-10-10 18:06:04 +02:00
TreeBuilder.cpp Update grammar, parser, semantic analyzer for classes; skeleton codegen and executor (#688) 2024-10-10 18:06:04 +02:00
TreeBuilder.h Update grammar, parser, semantic analyzer for classes; skeleton codegen and executor (#688) 2024-10-10 18:06:04 +02:00
UserFunctionBuilder.cpp Fix handling of byref, rest, and default parameters in uninitialized functions (#814) 2025-09-06 17:26:06 +02:00
UserFunctionBuilder.h Add Escript support for uninitialized class functions (#808) 2025-09-05 23:23:59 +02:00
UserFunctionVisitor.cpp Initial support for class instances in Executor (#699) 2024-10-10 18:06:04 +02:00
UserFunctionVisitor.h Delayed AST building of class variable statements (#692) 2024-10-10 18:06:04 +02:00
ValueBuilder.cpp Add support for regular expressions (#818) 2025-11-17 18:02:45 +01:00
ValueBuilder.h Add support for regular expressions (#818) 2025-11-17 18:02:45 +01:00