Skip to content

Commit 1022320

Browse files
committed
Also parse <?hh as valid start tag
1 parent 17118f8 commit 1022320

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ XP Compiler ChangeLog
33

44
## ?.?.? / ????-??-??
55

6+
## 1.3.0 / 2017-11-04
7+
8+
* Made it possible to use `<?hh` as opening tag, too. This way, we are
9+
able to parse Hack language files.
10+
(@thekid)
11+
612
## 1.2.1 / 2017-10-31
713

814
* Changed ambiguity resolution between casts, braced expressions and

src/main/php/lang/ast/Parse.class.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,20 +384,22 @@ private function setup() {
384384
return $node;
385385
});
386386

387-
$this->stmt('<?php', function($node) {
387+
$this->stmt('<?', function($node) {
388388
$node->arity= 'start';
389+
$node->value= $this->token->value;
390+
391+
$this->token= $this->advance();
389392
return $node;
390393
});
391394

392395
$this->stmt('namespace', function($node) {
393-
$package= $this->token->value;
396+
$node->arity= 'package';
397+
$node->value= $this->token->value;
398+
394399
$this->token= $this->advance();
395400
$this->token= $this->expect(';');
396401

397-
$this->scope->package($package);
398-
399-
$node->arity= 'package';
400-
$node->value= $package;
402+
$this->scope->package($node->value);
401403
return $node;
402404
});
403405

src/main/php/lang/ast/Tokens.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Tokens implements \IteratorAggregate {
77
const DELIMITERS = " |&^?!.:;,@%~=<>(){}[]#+-*/'\$\"\r\n\t";
88

99
private $operators= [
10-
'<' => ['<=', '<<', '<>', '<=>', '<<=', '<?php'],
10+
'<' => ['<=', '<<', '<>', '<?', '<=>', '<<='],
1111
'>' => ['>=', '>>', '>>='],
1212
'=' => ['=>', '==', '==>', '==='],
1313
'!' => ['!=', '!=='],

0 commit comments

Comments
 (0)