Skip to content

Commit 6d7053e

Browse files
committed
progress
1 parent 517ac61 commit 6d7053e

39 files changed

+1198
-261
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030
},
3131
"scripts": {
32-
"analyze": "phpstan analyze --level 10 src test",
32+
"analyze": "phpstan analyze --level 6 src test",
3333
"test": "vendor/bin/phpunit test"
3434
},
3535
"config": {

grammar/handlebars.y

Lines changed: 185 additions & 105 deletions
Large diffs are not rendered by default.

grammar/parser.template

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,25 @@ $meta #
77

88
namespace DevTheorem\Handlebars;
99

10-
use PhpParser\Error;
11-
use PhpParser\Modifiers;
12-
use PhpParser\Node;
13-
use PhpParser\Node\Stmt;
10+
use DevTheorem\Handlebars\Ast\ArrayLiteral;
11+
use DevTheorem\Handlebars\Ast\BooleanLiteral;
12+
use DevTheorem\Handlebars\Ast\CloseBlock;
13+
use DevTheorem\Handlebars\Ast\CommentStatement;
14+
use DevTheorem\Handlebars\Ast\ContentStatement;
15+
use DevTheorem\Handlebars\Ast\Hash;
16+
use DevTheorem\Handlebars\Ast\HashLiteral;
17+
use DevTheorem\Handlebars\Ast\HashPair;
18+
use DevTheorem\Handlebars\Ast\InverseChain;
19+
use DevTheorem\Handlebars\Ast\NullLiteral;
20+
use DevTheorem\Handlebars\Ast\NumberLiteral;
21+
use DevTheorem\Handlebars\Ast\OpenBlock;
22+
use DevTheorem\Handlebars\Ast\OpenHelper;
23+
use DevTheorem\Handlebars\Ast\OpenPartialBlock;
24+
use DevTheorem\Handlebars\Ast\PartialStatement;
25+
use DevTheorem\Handlebars\Ast\PathSegment;
26+
use DevTheorem\Handlebars\Ast\StringLiteral;
27+
use DevTheorem\Handlebars\Ast\SubExpression;
28+
use DevTheorem\Handlebars\Ast\UndefinedLiteral;
1429
#include;
1530

1631
/* This is an automatically GENERATED file, which should not be manually edited.

src/Ast/ArrayLiteral.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace DevTheorem\Handlebars\Ast;
4+
5+
class ArrayLiteral extends Literal
6+
{
7+
/**
8+
* @param Expression[] $items
9+
*/
10+
public function __construct(
11+
public array $items,
12+
SourceLocation $loc,
13+
) {
14+
parent::__construct('ArrayLiteral', $loc);
15+
}
16+
}

src/Ast/BlockStatement.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace DevTheorem\Handlebars\Ast;
4+
5+
class BlockStatement extends Statement
6+
{
7+
/**
8+
* @param Expression[] $params
9+
*/
10+
public function __construct(
11+
string $type,
12+
public PathExpression $path,
13+
public array $params,
14+
public Hash $hash,
15+
public Program $program,
16+
public ?Program $inverse,
17+
public StripFlags $openStrip,
18+
public ?StripFlags $inverseStrip,
19+
public StripFlags $closeStrip,
20+
SourceLocation $loc,
21+
) {
22+
parent::__construct($type, $loc);
23+
}
24+
}

src/Ast/BooleanLiteral.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace DevTheorem\Handlebars\Ast;
4+
5+
class BooleanLiteral extends Literal
6+
{
7+
public function __construct(
8+
public bool $value,
9+
public bool $original,
10+
SourceLocation $loc,
11+
) {
12+
parent::__construct('BooleanLiteral', $loc);
13+
}
14+
}

src/Ast/CloseBlock.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace DevTheorem\Handlebars\Ast;
4+
5+
readonly class CloseBlock
6+
{
7+
public function __construct(
8+
public PathExpression | Literal $path,
9+
public StripFlags $strip,
10+
) {}
11+
}

src/Ast/CommentStatement.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace DevTheorem\Handlebars\Ast;
4+
5+
class CommentStatement extends Statement
6+
{
7+
public function __construct(
8+
public string $value,
9+
public StripFlags $strip,
10+
SourceLocation $loc,
11+
) {
12+
parent::__construct('CommentStatement', $loc);
13+
}
14+
}

src/Ast/ContentStatement.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace DevTheorem\Handlebars\Ast;
4+
5+
class ContentStatement extends Statement
6+
{
7+
public function __construct(
8+
public string $value,
9+
public StripFlags $original,
10+
SourceLocation $loc,
11+
) {
12+
parent::__construct('ContentStatement', $loc);
13+
}
14+
}

src/Ast/Decorator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
namespace DevTheorem\Handlebars\Ast;
4+
5+
class Decorator extends MustacheStatement {}

0 commit comments

Comments
 (0)