37 Commits

Author SHA1 Message Date
Feoramund
35b157ac83 Fix multiline RegEx iteration
In `.Multiline` mode:

- `^` is now defined to assert the start of the string or that a "\n" or
  "\r" rune was parsed on last VM dispatch.

- `$` is now defined to consume a newline sequence of "\n", "\r", or
  "\r\n" or to assert the end of the string.
2025-05-26 14:48:45 -04:00
Feoramund
5d01acc04f Add more RegEx tests 2025-05-24 07:42:04 -04:00
Feoramund
37d6491300 Remove Global RegEx flag, default to unanchored patterns 2025-05-24 07:42:04 -04:00
Feoramund
fedb9efb41 Make RegEx VM restartable and fix iterator infinite loop 2025-05-24 07:23:04 -04:00
Jeroen van Rijn
a5e513567b Optimize regex match iterator.
Reuse virtual machine and capture groups between matches.
2025-04-07 14:58:41 +02:00
Jeroen van Rijn
9a2b6c01aa Return loop index in regex iterator. 2025-04-06 21:45:37 +02:00
Jeroen van Rijn
66077add33 {.Glboal} implicit in regex allocator. 2025-04-06 21:13:02 +02:00
Jeroen van Rijn
918d57fe01 Keep -vet happy. 2025-04-06 14:24:17 +02:00
Jeroen van Rijn
cdc56dc691 Add iterator for core:text/regex.
Usage:
```odin
haystack := `xxfoobarxfoobarxx`
pattern  := `f(o)ob(ar)`

it := regex.create_iterator(haystack, pattern, {.Global}) or_return
defer regex.destroy(it)

for capture in regex.match(&it) {
	fmt.println(capture)
}
```
2025-04-06 14:19:14 +02:00
Ycros
bf63e9b093 Add test for regex preallocated captures. 2024-12-04 14:38:07 +11:00
gingerBill
c77e8ca401 Fix tests 2024-08-21 14:06:04 +01:00
Feoramund
d0d4f19097 Remove debug line from test 2024-08-05 03:50:41 -04:00
Feoramund
ca7e46d56f Add explicit test case for Capture pos 2024-08-04 18:56:29 -04:00
Feoramund
743480b1a4 Use regex.destroy for test captures 2024-08-04 18:56:29 -04:00
Feoramund
cd8272557f Test that a RegEx Capture pos corresponds to its groups 2024-08-04 18:33:36 -04:00
Feoramund
042f6de478 Remove printing facilities for Regular_Expression
The `original_pattern` introduced a tenuous dependency to the expression
value as a whole, and after some consideration, I decided that it would
be better for the developer to manage their own pattern strings.

In the event you need to print the text representation of a pattern,
it's usually better that you manage the memory of it as well.
2024-07-24 16:27:20 -04:00
Feoramund
c52a8a5f86 Allow configuring of MAX_CAPTURE_GROUPS for n > 10 2024-07-24 16:27:08 -04:00
Feoramund
e8537a3134 Add test cases for unclosed classes and repetition
Simplified error checking while I was at it, too.
2024-07-24 15:21:41 -04:00
Feoramund
3e49ceb82a Add tests for core:text/regex 2024-07-22 15:07:13 -04:00
Maurizio M. Gavioli
53755824fb Separate the I18N calls for immutable strings and for pluraliseable strings.
Also update tests.
2024-06-19 10:10:26 +02:00
Jeroen van Rijn
8383a45b62 Port tests\core\text\match 2024-06-02 14:47:09 -04:00
Jeroen van Rijn
d7bfbe0552 Port testing\core\text\i18n 2024-06-02 14:47:08 -04:00
Feoramund
852f694bee Get tests passing again
`T` no longer has a writer assigned to it.

`test_core_cbor.odin` has global state and is run with `odin test`,
so I've set it to use only one thread.
2024-06-02 14:34:31 -04:00
Jeroen van Rijn
f8c4ee3d3c i18n: Add section merge + duplicate key detection to gettext. 2024-05-17 15:50:37 +02:00
Jeroen van Rijn
6139da3d41 Fix .mo contexts
Fixes #3590

- `get("key")`
- `get("context", "key")`
2024-05-17 14:15:56 +02:00
Jeroen van Rijn
5a76b3c7c5 Fix .mo parser: Number of plurals
Fixes #3591

Added plur.mo to tests
2024-05-17 12:00:20 +02:00
Yawning Angel
9251e06143 tests/core: Bring the Makefile more in-sync with build.bat 2024-02-24 14:05:15 +09:00
gingerBill
be6f355665 Keep -vet happy by removing using 2023-07-31 12:32:30 +01:00
gingerBill
8aa36072fc Remove using where easily possible 2023-07-31 12:11:17 +01:00
skytrias
e5d0417a6c folder name changed 2022-12-21 21:36:50 +01:00
skytrias
1bea0f3772 fix styling issues and use switches in cases its necessary, add comments to helpers 2022-12-20 15:48:10 +01:00
skytrias
ff7f139fd7 add iter_index and update tests to use easier matcher setup 2022-12-20 12:59:32 +01:00
skytrias
eb5523d5d3 case insensitive helper call 2022-12-18 23:11:23 +01:00
skytrias
3f4bbbec29 add proper unicode walking 2022-12-18 23:11:23 +01:00
skytrias
70bd220f34 balanced string, frontier pattern, gsub_with and their tests added 2022-12-18 23:11:23 +01:00
skytrias
bd3596f012 create lua strlib text package and tests 2022-12-18 23:11:23 +01:00
Jeroen van Rijn
09e1c0fa27 [i18n] Add tests. 2022-04-29 16:19:13 +02:00