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.
This commit is contained in:
parent
6bbb26fdaf
commit
0f468a5013
Notes:
sideshowbarker
2024-07-18 20:55:03 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/0f468a5013f Pull-request: https://github.com/SerenityOS/serenity/pull/6057 Issue: https://github.com/SerenityOS/serenity/issues/6039
1 changed files with 6 additions and 6 deletions
|
@ -334,26 +334,26 @@ public:
|
|||
{
|
||||
|
||||
// FORKJUMP _ALT
|
||||
// REGEXP ALT1
|
||||
// REGEXP ALT2
|
||||
// JUMP _END
|
||||
// LABEL _ALT
|
||||
// REGEXP ALT2
|
||||
// REGEXP ALT1
|
||||
// LABEL _END
|
||||
|
||||
ByteCode byte_code;
|
||||
|
||||
empend(static_cast<ByteCodeValueType>(OpCodeId::ForkJump));
|
||||
empend(left.size() + 2); // Jump to the _ALT label
|
||||
empend(right.size() + 2); // Jump to the _ALT label
|
||||
|
||||
for (auto& op : left)
|
||||
for (auto& op : right)
|
||||
append(move(op));
|
||||
|
||||
empend(static_cast<ByteCodeValueType>(OpCodeId::Jump));
|
||||
empend(right.size()); // Jump to the _END label
|
||||
empend(left.size()); // Jump to the _END label
|
||||
|
||||
// LABEL _ALT = bytecode.size() + 2
|
||||
|
||||
for (auto& op : right)
|
||||
for (auto& op : left)
|
||||
append(move(op));
|
||||
|
||||
// LABEL _END = alterantive_bytecode.size
|
||||
|
|
Loading…
Add table
Reference in a new issue