Skip to content

Commit

Permalink
Rename position line and column getters.
Browse files Browse the repository at this point in the history
  • Loading branch information
nielssp committed Nov 14, 2015
1 parent e893b62 commit 06362e6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/lexer.php
Expand Up @@ -149,9 +149,9 @@ public function __invoke($input)
foreach ($tokens as $token)
echo ' ' . $token;
} catch (\Parco\ParseException $e) {
echo 'Syntax Error: ' . $e->getMessage() . ' on line ' . $e->posLine() . ' column ' . $e->posColumn() . PHP_EOL;
echo 'Syntax Error: ' . $e->getMessage() . ' on line ' . $e->line() . ' column ' . $e->column() . PHP_EOL;
echo $input . PHP_EOL;
echo str_repeat('-', $e->posColumn() - 1) . '^';
echo str_repeat('-', $e->column() - 1) . '^';
}


Expand Down
3 changes: 1 addition & 2 deletions examples/tokens.php
@@ -1,5 +1,4 @@
<?php
use Parco\Combinator\RegexParsers;
use Parco\Positional;
use Parco\Position;
use Parco\Combinator\PositionalParsers;
Expand Down Expand Up @@ -243,7 +242,7 @@ public function __invoke($input)
echo 'Abstract syntax tree:' . PHP_EOL;
print_r($ast);
} catch (\Parco\ParseException $e) {
echo 'Syntax Error: ' . $e->getMessage() . ' on line ' . $e->posLine() . ' column ' . $e->posColumn() . PHP_EOL;
echo 'Syntax Error: ' . $e->getMessage() . ' on line ' . $e->line() . ' column ' . $e->column() . PHP_EOL;
}

echo '</pre>';
4 changes: 2 additions & 2 deletions src/Position.php
Expand Up @@ -43,7 +43,7 @@ public function setPosition(array $pos)
*
* @return int Line number (starting from 1).
*/
public function posLine()
public function line()
{
return $this->pos[0];
}
Expand All @@ -53,7 +53,7 @@ public function posLine()
*
* @return int Column number (starting from 1).
*/
public function posColumn()
public function column()
{
return $this->pos[1];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/PositionTest.php
Expand Up @@ -13,7 +13,7 @@ public function testPosition()
$mock->setPosition(array(5, 17));
$this->assertEquals(array(5, 17), $mock->getPosition());

$this->assertEquals(5, $mock->posLine());
$this->assertEquals(17, $mock->posColumn());
$this->assertEquals(5, $mock->line());
$this->assertEquals(17, $mock->column());
}
}

0 comments on commit 06362e6

Please sign in to comment.