Commit Graph
157 Commits
Author SHA1 Message Date
Karl ZylinskiandClaude Opus 5 1f9b4c4555 Add text field to utf8.Grapheme, fix caret translation by grapheme
`decode_grapheme_iterate` already computed the text of each grapheme
cluster, but `decode_grapheme_clusters` discarded it, forcing callers to
reconstruct each cluster's range by looking ahead to the next grapheme's
`byte_index`. Store it on `Grapheme` instead; it is a slice of the input
string, so no allocation is involved.

`core:text/edit` was using `Grapheme.width` -- the number of monospace
cells -- as a byte count when moving the caret by grapheme, so it landed
in the middle of a cluster for anything wider than one byte per cell. Use
`len(Grapheme.text)`, and add a test package for the translations.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 12:27:31 +02:00
George Potoshin 8f3418c914 support every quote 2026-08-01 15:05:45 +02:00
George Potoshin 487648d7fa fix octal escape parsing 2026-07-31 18:47:46 +02:00
George Potoshin 6a14e5e068 #7153 2026-07-30 19:24:36 +02:00
gingerBill 5647a1b2fc Merge pull request #6873 from bennyyip/regex/inject
core:text/regex: improve compiler performance
2026-06-23 22:34:26 +01:00
bennyyip f58d7edb39 pack consecutive inject 2026-06-23 22:19:59 +08:00
bennyyip 55e513fbd7 align struct fields 2026-06-23 22:19:26 +08:00
gingerBill a1fe7222bb Remove using fmt for example docs 2026-06-23 12:28:27 +01:00
bennyyip 7bbfc50430 core:text/regex: improve compiler performance 2026-06-23 09:45:10 +08:00
George Potoshin 5335bdbe34 [core:text/regex] Follow up to fix #6323 and add test case. As was said in the issue discussion I had suspicion that there may be a sibling bug in .Assert_Non_Word_Boundary implementation and I was able to confirm that with re.findall(rB", ") python code. Odin implementation outputed an empty string wherase python gave "'". That is the same bug related to incorrect logic on string ends. This commit makes implementation of those 2 instructions cleaner and adds a test case. 2026-02-25 14:33:09 +01:00
Jeroen van Rijn e696073d7b [core:text/regex] Fix #6323 and add test case
Thanks to @GPotoshin for the fix.
2026-02-25 10:49:27 +01:00
Jeroen van Rijn 545d17fd8d Fix core:sys/regex debug output 2026-02-24 22:40:32 +01:00
Jeroen van Rijn e7dbabf668 core:os -> core:os/old && core:os/os2 -> core:os 2026-02-09 15:50:21 +01:00
Jeroen van Rijn 8ed264680b Remove all core:os imports from JS targets
Fix `local_tz_name` on FreeBSD.
2026-02-09 15:07:27 +01:00
Jeroen van Rijn 89fccd6056 One more fix. 2026-02-08 13:17:39 +01:00
Jeroen van Rijn 2efefaac1a Update example 2026-02-08 12:56:07 +01:00
Jeroen van Rijn c0da9be4a9 core:text/table -> core:os/os2 2026-02-08 12:44:13 +01:00
Jeroen van Rijn a497019172 core:text/regex -> core:os/os2 2026-02-08 12:44:12 +01:00
Jeroen van Rijn 586355f4ac core:text/i18n -> core:os/os2 2026-02-08 12:44:11 +01:00
Fabian Erdmann 55ab089ffc text/regex: Pass given allocator on in create_iterator 2026-02-02 19:41:37 +01:00
gingerBill 548e4f3373 Add translate_by_grapheme: bool field 2025-12-16 14:42:40 +00:00
gingerBill e5153a937b Merge pull request #5859 from odin-lang/bill/change-license
Change Odin's LICENSE to zlib from BSD 3-clause
2025-11-04 13:53:13 +00:00
mtarik34b 7738f4ef9a Add missing case for octal prefix 2025-11-03 22:20:21 +01:00
gingerBill 842cfee0f3 Change Odin's LICENSE to zlib from BSD 3-clause
This change was made in order to allow things produced with Odin and using Odin's core library, to not require the LICENSE to also be distributed alongside the binary form.
2025-10-28 14:38:25 +00:00
Jeroen van Rijn 7a9ea3ee6d Further overhaul of package line comments. 2025-10-09 23:05:29 +02:00
gingerBill 66401b2e73 Minor formatting changes 2025-10-07 10:16:13 +01:00
gingerBill 787c3a7298 Remove @(require_results) on find_aux 2025-10-07 09:50:05 +01:00
gingerBill fb93713f24 Add @(rodata) and @(require_results) to core:text/match 2025-10-07 09:45:54 +01:00
Feoramund 09690691b6 text/regex: Remove old docmentation and unneeded flag
`Unsupported_Flag` was used back when the iterator did not handle
`.Multiline`.
2025-06-20 10:45:48 -04:00
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
Jeroen van Rijn 142dd58b27 Merge pull request #5209 from Feoramund/regex-fixes
Fix RegEx iterator, remove `.Global`, make patterns unanchored by default (breaking change)
2025-05-24 15:38:26 +02: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 8b657379f3 Typo fix 2025-05-23 17:07:08 +02:00
Jeroen van Rijn 3d60b219c1 Allow text/scanner to scan 0h hex floats 2025-05-23 14:02:49 +02:00
Jeroen van Rijn 716bd479a9 Disallow .Multiline in iterator. 2025-04-07 21:33:57 +02:00
Jeroen van Rijn 2b26c0b39e Remove now unused field. 2025-04-07 15:02:36 +02: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 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
James Duran 13640620ce Fix captures not begin zeroed when haystack length is 0 2025-01-15 15:56:40 -08:00
James Duran a7971f9f6f Allow captures in gfind and gmatch to be used in-loop 2025-01-15 11:02:46 -08:00
Ycros 7edc46f1b9 fix: regex's match_with_preallocated_capture returning num_groups 2024-12-04 13:51:27 +11:00
Doeke Wartena b492b73ff2 Update scanner.odin
remove duplicated wording in comment
2024-11-07 20:15:22 +01:00
Laytan Laats 288312a812 core: improve package doc comments for the documentation generator 2024-09-03 19:59:04 +02:00
gingerBill eb799393d5 Fix -vet-tabs issues 2024-08-24 13:56:41 +01:00
gingerBill 58e811eea5 Merge pull request #3962 from Feoramund/regex
Add `core:text/regex`
2024-08-21 13:55:11 +01:00
Laytan Laats c9b69d76b0 text/edit: fix undo_state_push wrong builder check 2024-08-07 17:21:56 +02:00
Feoramund 8f5b838a07 Review manual for loops in core:text/regex 2024-08-05 03:49:29 -04:00