Skip to content

Commit 50eea30

Browse files
committed
use only 32-bit sets for ATN
1 parent 0afe35b commit 50eea30

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

src/Atn/ATNDeserializer.php

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,7 @@ public function deserialize(array $data): ATN
7373
$this->readRules($atn);
7474
$this->readModes($atn);
7575
$sets = [];
76-
77-
// First, deserialize sets with 16-bit arguments <= U+FFFF.
78-
$this->readSets($sets, function () {
79-
return $this->readInt();
80-
});
81-
82-
// Next, deserialize sets with 32-bit arguments <= U+10FFFF.
83-
$this->readSets($sets, function () {
84-
return $this->readInt32();
85-
});
86-
76+
$this->readSets($sets);
8777
$this->readEdges($atn, $sets);
8878
$this->readDecisions($atn);
8979
$this->readLexerActions($atn);
@@ -250,7 +240,7 @@ private function readModes(ATN $atn): void
250240
/**
251241
* @param array<IntervalSet> $sets
252242
*/
253-
private function readSets(array &$sets, callable $readUnicode): void
243+
private function readSets(array &$sets): void
254244
{
255245
$m = $this->readInt();
256246

@@ -266,8 +256,8 @@ private function readSets(array &$sets, callable $readUnicode): void
266256
}
267257

268258
for ($j=0; $j < $n; $j++) {
269-
$i1 = $readUnicode();
270-
$i2 = $readUnicode();
259+
$i1 = $this->readInt();
260+
$i2 = $this->readInt();
271261
$iset->addRange($i1, $i2);
272262
}
273263
}
@@ -608,14 +598,6 @@ private function readInt(): int
608598
return $this->data[$this->pos++];
609599
}
610600

611-
private function readInt32(): int
612-
{
613-
$low = $this->readInt();
614-
$high = $this->readInt();
615-
616-
return $low | ($high << 16);
617-
}
618-
619601
/**
620602
* @param array<IntervalSet> $sets
621603
*/

0 commit comments

Comments
 (0)