Skip to content

Commit cd74be3

Browse files
committed
Fixed bugs in Conveyor::readNamespace, FieldState::step
1 parent 56bbb8d commit cd74be3

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

Test.php-data

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
namespace fjdjb98\988hhgg;
2-
3-
use 6847\fufu9gyfug;
4-
5-
class 9Test {
1+
class Test {
62

73
val A;
84
val A1: string;
@@ -21,7 +17,7 @@ class 9Test {
2117
direct val C;
2218
direct val C1: string;
2319
direct val C2 = "Foo";
24-
direct val C3 := "Fee"
20+
direct val C3 := "Fee";
2521
direct val C4: string = "Bar";
2622
direct val C5: string := "Baz";
2723

app/Parsing/Conveyor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function skipComment() {
171171
* @return string Namespace
172172
*/
173173
public function readNamespace(): string {
174-
if (preg_match('/^[a-z_][\\w\\\\]*\\w/i', $this->next, $matches) === 1) {
174+
if (preg_match('/^[a-z_]\\w*(\\\\[a-z_]\\w*)*/i', $this->next, $matches) === 1) {
175175
$this->move(strlen($matches[0]));
176176

177177
return $matches[0];

app/Parsing/FieldState.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,25 @@ public function step(Conveyor $conveyor): State {
148148
case 7:
149149
$matches = [];
150150

151+
$fail = false;
151152
if ($conveyor->readOperator('```')) {
152153
if (preg_match('/^([\\s\\S]*?)```/', $conveyor, $matches) !== 1) {
153-
throw new \Exception('Error occured while default value parsing');
154+
$fail = true;
154155
}
155156
} elseif ($conveyor->readOperator('`')) {
156157
if (preg_match('/^(.*?)`/', $conveyor, $matches) !== 1) {
157-
throw new \Exception('Error occured while default value parsing');
158+
$fail = true;
158159
}
159160
} else {
160161
if (preg_match('/^(.*?);/', $conveyor, $matches) !== 1) {
161-
throw new \Exception('Error occured while default value parsing');
162+
$fail = true;
163+
} else {
164+
$matches[0] = substr($matches[0], 0, strlen($matches[1]));
162165
}
166+
}
163167

164-
$matches[0] = substr($matches[0], 0, strlen($matches[1]));
168+
if ($fail) {
169+
throw $conveyor->makeException('Error occured while default value parsing');
165170
}
166171

167172
$conveyor->move(strlen($matches[0]));

0 commit comments

Comments
 (0)