mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
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
1 changed files with 6 additions and 6 deletions
|
@ -334,26 +334,26 @@ public:
|
||||||
{
|
{
|
||||||
|
|
||||||
// FORKJUMP _ALT
|
// FORKJUMP _ALT
|
||||||
// REGEXP ALT1
|
// REGEXP ALT2
|
||||||
// JUMP _END
|
// JUMP _END
|
||||||
// LABEL _ALT
|
// LABEL _ALT
|
||||||
// REGEXP ALT2
|
// REGEXP ALT1
|
||||||
// LABEL _END
|
// LABEL _END
|
||||||
|
|
||||||
ByteCode byte_code;
|
ByteCode byte_code;
|
||||||
|
|
||||||
empend(static_cast<ByteCodeValueType>(OpCodeId::ForkJump));
|
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));
|
append(move(op));
|
||||||
|
|
||||||
empend(static_cast<ByteCodeValueType>(OpCodeId::Jump));
|
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
|
// LABEL _ALT = bytecode.size() + 2
|
||||||
|
|
||||||
for (auto& op : right)
|
for (auto& op : left)
|
||||||
append(move(op));
|
append(move(op));
|
||||||
|
|
||||||
// LABEL _END = alterantive_bytecode.size
|
// LABEL _END = alterantive_bytecode.size
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue