Commit graph

20 commits

Author SHA1 Message Date
Gunnar Beutner
36e36507d5 Everywhere: Prefer using {:#x} over 0x{:x}
We have a dedicated format specifier which adds the "0x" prefix, so
let's use that instead of adding it manually.
2021-07-22 08:57:01 +02:00
Ali Mohammad Pur
f364fcec5d LibRegex+Everywhere: Make LibRegex more unicode-aware
This commit makes LibRegex (mostly) capable of operating on any of
the three main string views:
- StringView for raw strings
- Utf8View for utf-8 encoded strings
- Utf32View for raw unicode strings

As a result, regexps with unicode strings should be able to properly
handle utf-8 and not stop in the middle of a code point.
A future commit will update LibJS to use the correct type of string
depending on the flags.
2021-07-18 21:10:55 +04:30
Ali Mohammad Pur
addfa1e82e LibRegex: Make the bytecode transformation functions static
They were pretty confusing when compared with other non-transforming
functions.
2021-07-10 13:33:08 +02:00
Andreas Kling
e59bf87374 Userland: Replace VERIFY(is<T>) with verify_cast<T>
Instead of doing a VERIFY(is<T>(x)) and *then* casting it to T, we can
just do the cast right away with verify_cast<T>. :^)
2021-06-24 21:13:09 +02:00
Gunnar Beutner
5bfe601152 LibRegex: Remove unused code 2021-06-14 16:09:58 +04:30
Gunnar Beutner
a167941852 LibRegex: Use a plain pointer for OpCode::m_state 2021-06-14 16:09:58 +04:30
Gunnar Beutner
d3c2a3caea LibRegex: Avoid initialization checks in get_opcode_by_id() 2021-06-14 16:09:58 +04:30
Gunnar Beutner
281f39073d LibRegex: Make get_opcode() return a reference
Previously this would return a pointer which could be null if the
requested opcode was invalid. This should never be the case though
so let's VERIFY() that instead.
2021-06-14 16:09:58 +04:30
Gunnar Beutner
cd49fb0229 LibRegex: Remove return value for setters 2021-06-14 16:09:58 +04:30
Gunnar Beutner
1fb4471506 LibRegex: Use a plain array to store opcodes
Using a hash map is unnecessary because the number of opcodes and their
IDs never change.
2021-06-14 16:09:58 +04:30
Andreas Kling
dc65f54c06 AK: Rename Vector::append(Vector) => Vector::extend(Vector)
Let's make it a bit more clear when we're appending the elements from
one vector to the end of another vector.
2021-06-12 13:24:45 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
c68dcf45b6 LibRegex: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
AnotherTest
e9279d1790 LibRegex: Allow a '?' suffix for brace quantifiers
This fixes another compat point in #6042.
2021-04-10 09:16:03 +02:00
AnotherTest
8d7bcc2476 LibRegex: Give ByteCode a copy ctor and and a move assignment operator
Previously all move assignments were actually copies. oops.
2021-04-10 09:16:03 +02:00
AnotherTest
0f468a5013 LibRegex: Test alternatives in the expected order
That is, first try to match the left side of the alternation, and then
the right side.
Fixes part of #6042.
2021-04-01 21:55:47 +02:00
AnotherTest
6bbb26fdaf LibRegex: Allow references to capture groups that aren't parsed yet
This only applies to the ECMA262 parser.
This behaviour is an ECMA262-specific quirk, such references always
generate zero-length matches (even on subsequent passes).
Also adds a test in LibJS's test suite.

Fixes #6039.
2021-04-01 21:55:47 +02:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Linus Groh
421587c15c Everywhere: Fix typos 2021-01-22 18:41:29 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Renamed from Libraries/LibRegex/RegexByteCode.h (Browse further)