Commit graph

7 commits

Author SHA1 Message Date
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
Kevin Eady
00b928217a
Fix infinite loop in lexer on EOF in FORMAT_STRING (#722) 2024-10-17 06:54:28 +02:00
Kevin Eady
d7cdcff383 Add classinst.function member; Add is binary operator; Add funcref MTH_NEW (#701)
* Update grammar

* Implement selfIs in BObjectImp

* Add tests

* Update grammar

* Support obj.function as a MemberAccess [1/2]
- AST generation changes

* Support obj.function as a MemberAccess [2/2]
- add funcref index to eprog class table ctor entry
- allow check_mro on non-class inst (skip ctor calls)

* Move address of funcref into funcref table

* Add funcref.new()
- Add class index to funcref table entry
- Add MTH_NEW

* Fix formatting

* Address self-review comments

* Some more tests

* Address self-review comments

* Update grammar

* Remove ObjMember read_only, hidden
No need to special-handle MBR_FUNCTION

* Addres GitHub CI annotations
- '=': conversion from 'size_t' to 'unsigned int', possible loss of data
2024-10-10 18:06:04 +02:00
Kevin Eady
4ae9519343 Update grammar, parser, semantic analyzer for classes; skeleton codegen and executor (#688)
* Update grammar

* WIP with tracking classes
- Refactor AvailableUserFunction to AvailableParseTree
- Track ClassDeclarationContexts similarly to user functions

* Skeleton AST + tracking

* Finish up AST building

* Implement AST building
- TODO decide better name for UserFunctionBuilder/Visitor,
since it does both user functions and classes

* Update Prettifier

* Crude, first-round semantic analysis + codegen
- Currently, no real difference from regular functions

* Move class var statements to top level statements

* Add semantic analysis for base class existence

* Introduce ClassInstance AST node for generating `this` parameter

* Skeleton create class instance instruction

* Default ctor; 'this' byref; Error if multiple same baseclass

* Update grammar for scoped funcrefs and scoped identifiers

* Update prettifier, builders for scoped funcref, identifiers

* Fix CI issues
- Styling
- Shadowing

* Add grammar tests for scope; Remove scope from switch label

* Final draft todos
- Rename `VarStatement::class_name` to `scope`
- Comment why identifiers dont have scopes in enum declarations
- Remove code comment
2024-10-10 18:06:04 +02:00
Kevin Eady
93645f0770
Add variable arguments to user functions (#679)
* Update grammar

* Update parser and AST generator

* Update semantic analysis

* Executor implementation
- Move Executor stack modification logic to BFunctionRef
- Handle user function calls
- Handle expression function calls

* Tests

* Update existing listfile snapshots
- Adds variadic boolean to instruction stack
- Changes instruction counts and offsets

* Fix test issue

* Better implementation of calling user functions

* Add var-args-captures test

* Refactor continuation handling + handle variadic args
- Move stack modifications from make/withContinuation into the executor's handling of the continuation
- Only trim args in continuation call if function is not variadic

* Add var-args-continuation test (via array.filter)

* update escriptguide + formatting, docs

* Fix CI annotations
- '=': conversion from 'size_t' to 'unsigned int', possible loss of data
- declaration of 'continuation' hides previous local declaration
2024-08-04 17:13:30 +02:00
Kevin Eady
2de1995c19
Fix compiler for escaping } correctly in interpolated strings (#620)
* Update grammar; add tests
String literals inside an interpolated string cannot start with `}`, as it must be a DOUBLE_RBRACE `}}`

* Fix interpolate string token reading

* Update core-changes
2024-02-06 10:44:26 +01:00
turleypol
271a1105ba
added explicit targets for every 3rd party lib (#612)
* added explicit targets for every 3rd party lib
these contain include dirs/libs/compiler defs

* moved each 3rd party lib into a version folder, to give each target a
dedicated include directory.
Now noone should add lib root folder as include dir
Used private linking where possible
disabled building of boost, wasnt used at all

* regnerate boost cache
adapted targets for coverity
2024-01-27 09:06:23 +01:00
Renamed from lib/EscriptGrammar/EscriptLexer.cpp (Browse further)