Skip to content

Commit 707c252

Browse files
committed
wip php 8.3
1 parent db72598 commit 707c252

20 files changed

+124
-78
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
- ubuntu-latest
4242
- windows-latest
4343
php:
44+
- '8.3'
4445
- '8.4'
4546

4647
fail-fast: false

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
],
3030
"name": "vojtech-dobes/php-grammar-processing",
3131
"require": {
32-
"php": "~8.4",
32+
"php": "~8.3",
3333
"ext-pcre": "*"
3434
},
3535
"require-dev": {

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GrammarProcessing/AbstractSyntaxTree.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ public function __construct(
1919

2020

2121

22+
/**
23+
* @return TName
24+
*/
25+
public function getName(): string
26+
{
27+
return $this->name;
28+
}
29+
30+
31+
32+
public function getValue(): mixed
33+
{
34+
return $this->value;
35+
}
36+
37+
38+
2239
public function interpret(Interpretation $interpretation): mixed
2340
{
2441
$nodeInterpretations = $interpretation->nodeInterpretations;
@@ -33,23 +50,23 @@ public function interpret(Interpretation $interpretation): mixed
3350
$subnode = $currentGenerator->current();
3451

3552
if ($subnode instanceof SelectedNode) {
36-
$subnode = $subnode->value;
53+
$subnode = $subnode->getValue();
3754
}
3855

3956
if ($subnode === NULL) {
4057
$currentGenerator->send(NULL);
4158
} elseif ($subnode instanceof Token) {
4259
$currentGenerator->send($subnode->value);
4360
} elseif ($subnode instanceof TokenNode) {
44-
if (isset($nodeInterpretations[$subnode->name])) {
61+
if (isset($nodeInterpretations[$subnode->getName()])) {
4562
$generatorStack[] = $currentGenerator;
46-
$currentGenerator = $nodeInterpretations[$subnode->name]->interpret($subnode);
63+
$currentGenerator = $nodeInterpretations[$subnode->getName()]->interpret($subnode);
4764
} else {
4865
$currentGenerator->send($subnode->value->value);
4966
}
5067
} else {
5168
$generatorStack[] = $currentGenerator;
52-
$currentGenerator = $nodeInterpretations[$subnode->name]->interpret($subnode->value);
69+
$currentGenerator = $nodeInterpretations[$subnode->getName()]->interpret($subnode->getValue());
5370
}
5471
} else {
5572
$currentNodeValue = $currentGenerator->getReturn();

src/GrammarProcessing/Ebnf/Nodes/Alternation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ final class Alternation implements GrammarProcessing\NodeInterpretation
1212
public function interpret(GrammarProcessing\Node $node): Generator
1313
{
1414
$result = [
15-
yield $node->value[1],
15+
yield $node->getValue()[1],
1616
];
1717

18-
foreach ($node->value[3]->value as $item) {
19-
$result[] = yield $item->value[2];
18+
foreach ($node->getValue()[3]->getValue() as $item) {
19+
$result[] = yield $item->getValue()[2];
2020
}
2121

2222
if (count($result) === 1) {

src/GrammarProcessing/Ebnf/Nodes/Concatenation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ final class Concatenation implements GrammarProcessing\NodeInterpretation
1212
public function interpret(GrammarProcessing\Node $node): Generator
1313
{
1414
$result = [
15-
yield $node->value[1],
15+
yield $node->getValue()[1],
1616
];
1717

18-
foreach ($node->value[3]->value as $item) {
19-
$result[] = yield $item->value[2];
18+
foreach ($node->getValue()[3]->getValue() as $item) {
19+
$result[] = yield $item->getValue()[2];
2020
}
2121

2222
if (count($result) === 1) {

src/GrammarProcessing/Ebnf/Nodes/Factor.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ public function interpret(GrammarProcessing\Node $node): Generator
1616

1717
return match ($node->index) {
1818
0 => new GrammarProcessing\Vocabulary\Repeat(
19-
yield $node->value[0],
19+
yield $node->getValue()[0],
2020
0,
2121
1,
2222
),
2323
1 => new GrammarProcessing\Vocabulary\Repeat(
24-
yield $node->value[0],
24+
yield $node->getValue()[0],
2525
0,
2626
null,
2727
),
2828
2 => new GrammarProcessing\Vocabulary\Repeat(
29-
yield $node->value[0],
29+
yield $node->getValue()[0],
3030
1,
3131
null,
3232
),
3333
3 => new GrammarProcessing\Vocabulary\Subtract(
34-
yield $node->value[0],
35-
yield $node->value[4],
34+
yield $node->getValue()[0],
35+
yield $node->getValue()[4],
3636
),
37-
4 => yield $node->value[0],
37+
4 => yield $node->getValue()[0],
3838
default => throw new LogicException("This can't happen"),
3939
};
4040
}

src/GrammarProcessing/Ebnf/Nodes/Grammar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public function interpret(GrammarProcessing\Node $node): Generator
3030
{
3131
$result = [];
3232

33-
foreach ($node->value as $item) {
34-
[$identifier, $production] = yield $item->value[1];
33+
foreach ($node->getValue() as $item) {
34+
[$identifier, $production] = yield $item->getValue()[1];
3535

3636
$result[$identifier->nonterminal] = $production;
3737
}

src/GrammarProcessing/Ebnf/Nodes/Identifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class Identifier implements GrammarProcessing\NodeInterpretation
1111

1212
public function interpret(GrammarProcessing\Node $node): Generator
1313
{
14-
return new GrammarProcessing\Vocabulary\Nonterminal(yield $node->value);
14+
return new GrammarProcessing\Vocabulary\Nonterminal(yield $node->getValue());
1515
}
1616

1717
}

src/GrammarProcessing/Ebnf/Nodes/Rule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ final class Rule implements GrammarProcessing\NodeInterpretation
1111

1212
public function interpret(GrammarProcessing\Node $node): Generator
1313
{
14-
$identifier = yield $node->value[0];
15-
$production = yield $node->value[4];
14+
$identifier = yield $node->getValue()[0];
15+
$production = yield $node->getValue()[4];
1616

1717
return [$identifier, $production];
1818
}

0 commit comments

Comments
 (0)