Skip to content

Commit

Permalink
Fixed build and add labeled stmt
Browse files Browse the repository at this point in the history
  • Loading branch information
haskellcamargo committed Aug 3, 2016
1 parent 4b419b9 commit 2bb646d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 67 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ install:

script:
- make test module=lexer
- make test module=parser
- hy ./tools/testsuite/run-tests.hy --dir tests --exe "php ./src/Quack.php %s"
5 changes: 4 additions & 1 deletion src/ast/stmt/LabelStmt.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@
class LabelStmt extends Stmt
{
public $name;
public $stmt;

public function __construct($name)
public function __construct($name, $stmt)
{
$this->name = $name;
$this->stmt = $stmt;
}

public function format(Parser $parser)
{
$source = ':- ';
$source .= $this->name;
$source .= PHP_EOL;
$source .= $this->stmt->format($parser);
return $source;
}

Expand Down
19 changes: 0 additions & 19 deletions src/ast/stmt/Stmt.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,6 @@ private function bindTraitDecl($trait)
]);
}

private function bindLabelDecl($label)
{
if ($this->scope->hasLocal($label->name)) {
throw new ScopeError([
'message' => "Symbol for label `{$label->name}` declared twice"
]);
}

$this->scope->insert($label->name, [
'initialized' => true,
'kind' => 'label',
'mutable' => false
]);

}

private function getNodeType($node)
{
$reflect = new ReflectionClass($node);
Expand Down Expand Up @@ -158,9 +142,6 @@ public function bindDeclarations($stmt_list)
case 'TraitStmt':
$this->bindTraitDecl($node);
break;
case 'LabelStmt':
$this->bindLabelDecl($node);
break;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/parser/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ public function _labelStmt()
{
$this->parser->match(':-');
$label_name = $this->identifier();
$stmt = $this->_innerStmt();

return new LabelStmt($label_name);
return new LabelStmt($label_name, $stmt);
}

public function _elifList()
Expand Down
45 changes: 0 additions & 45 deletions tests/ParserTest.php

This file was deleted.

0 comments on commit 2bb646d

Please sign in to comment.