Skip to content

Commit 2a6a7a8

Browse files
committed
Fixed bugs in Conveyor
1 parent 3085404 commit 2a6a7a8

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

Test.php-data

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

37
val A;
48
val A1: string;
@@ -17,7 +21,7 @@ class Test {
1721
direct val C;
1822
direct val C1: string;
1923
direct val C2 = "Foo";
20-
direct val C3 := "Fee";
24+
direct val C3 := "Fee"
2125
direct val C4: string = "Bar";
2226
direct val C5: string := "Baz";
2327

app/Parsing/Conveyor.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ class Conveyor {
4747
protected $length = 0;
4848

4949
/**
50-
* @var int Current cursor line
50+
* @var int Current cursor row
5151
*/
52-
protected $line = 0;
52+
protected $row = 0;
5353

5454
/**
55-
* @var int Current cursor row
55+
* @var int Current cursor column
5656
*/
57-
protected $row = 0;
57+
protected $column = 0;
5858

5959
/**
6060
* @param string $source Source of conveyor
@@ -75,7 +75,7 @@ public function length(): int {
7575
return $this->length;
7676
}
7777

78-
public function makeException(string $description, int $code = 0, \Throwable $previous): ParsingException {
78+
public function makeException(string $description, int $code = 0, \Throwable $previous = null): ParsingException {
7979
$offset = strlen($this->source) - $this->length;
8080

8181
for (; $offset > 0; --$offset) {
@@ -84,7 +84,6 @@ public function makeException(string $description, int $code = 0, \Throwable $pr
8484
break;
8585
}
8686
}
87-
++$offset;
8887

8988
$line = substr($this->source, $offset);
9089
$line = substr($line, 0, strpos($line, "\n"));
@@ -105,10 +104,10 @@ public function move(int $offset) {
105104

106105
for ($i = 0; $i < $offset; ++$i) {
107106
if ($this->next[$i] == "\n") {
108-
$this->row = 0;
109-
++$this->line;
110-
} else {
107+
$this->column = 0;
111108
++$this->row;
109+
} else {
110+
++$this->column;
112111
}
113112
}
114113

0 commit comments

Comments
 (0)