@vituum/vite-plugin-latte 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/handler.js +9 -0
- package/index.js +138 -0
- package/index.php +173 -0
- package/latte/AssetFilter.php +11 -0
- package/latte/FetchFunction.php +28 -0
- package/latte/IconFilter.php +14 -0
- package/latte/JsonTag.php +64 -0
- package/latte/PlaceholderFunction.php +11 -0
- package/latte/RandomColorFunction.php +14 -0
- package/latte/TelFilter.php +22 -0
- package/package.json +35 -0
- package/vendor/autoload.php +7 -0
- package/vendor/bin/latte-lint +107 -0
- package/vendor/composer/ClassLoader.php +572 -0
- package/vendor/composer/InstalledVersions.php +350 -0
- package/vendor/composer/LICENSE +21 -0
- package/vendor/composer/autoload_classmap.php +183 -0
- package/vendor/composer/autoload_namespaces.php +9 -0
- package/vendor/composer/autoload_psr4.php +9 -0
- package/vendor/composer/autoload_real.php +57 -0
- package/vendor/composer/autoload_static.php +193 -0
- package/vendor/composer/installed.json +93 -0
- package/vendor/composer/installed.php +32 -0
- package/vendor/composer/platform_check.php +26 -0
- package/vendor/latte/latte/bin/latte-lint +29 -0
- package/vendor/latte/latte/composer.json +53 -0
- package/vendor/latte/latte/license.md +60 -0
- package/vendor/latte/latte/ncs.php +14 -0
- package/vendor/latte/latte/ncs.xml +9 -0
- package/vendor/latte/latte/readme.md +21 -0
- package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +114 -0
- package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +99 -0
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.panel.phtml +98 -0
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.tab.phtml +15 -0
- package/vendor/latte/latte/src/Latte/Compiler/Block.php +44 -0
- package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +244 -0
- package/vendor/latte/latte/src/Latte/Compiler/ExpressionBuilder.php +128 -0
- package/vendor/latte/latte/src/Latte/Compiler/Node.php +28 -0
- package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +132 -0
- package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +77 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AreaNode.php +17 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +27 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +59 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +48 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/BogusTagNode.php +46 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/CommentNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +129 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/QuotedValue.php +53 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/NopNode.php +21 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ComplexTypeNode.php +17 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayAccessNode.php +41 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayItemNode.php +52 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +94 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/BinaryOpNode.php +65 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CastNode.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CloneNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +73 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureUseNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/EmptyNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ErrorSuppressNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FilterCallNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallableNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InRangeNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InstanceofNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MatchNode.php +49 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallNode.php +50 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallableNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NewNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NotNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PropertyFetchNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticCallNode.php +55 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticCallableNode.php +47 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticPropertyFetchNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TernaryNode.php +50 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/VariableNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +17 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/FilterNode.php +67 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IdentifierNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IntersectionTypeNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/MatchArmNode.php +45 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +107 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NameNode.php +89 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NullableTypeNode.php +35 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ParameterNode.php +54 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/BooleanNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/EncapsedStringNode.php +80 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/EncapsedStringPartNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/FloatNode.php +63 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/IntegerNode.php +70 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/NullNode.php +29 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/StringNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ScalarNode.php +15 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/SuperiorTypeNode.php +29 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/UnionTypeNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VarLikeIdentifierNode.php +21 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/StatementNode.php +15 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TemplateNode.php +34 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TextNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +227 -0
- package/vendor/latte/latte/src/Latte/Compiler/Position.php +43 -0
- package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +334 -0
- package/vendor/latte/latte/src/Latte/Compiler/Tag.php +117 -0
- package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +399 -0
- package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +388 -0
- package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +580 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +206 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +391 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +448 -0
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +506 -0
- package/vendor/latte/latte/src/Latte/Compiler/Token.php +259 -0
- package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +151 -0
- package/vendor/latte/latte/src/Latte/ContentType.php +22 -0
- package/vendor/latte/latte/src/Latte/Engine.php +591 -0
- package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +160 -0
- package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +232 -0
- package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +232 -0
- package/vendor/latte/latte/src/Latte/Essential/Filters.php +591 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +161 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +98 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +74 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DebugbreakNode.php +53 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +134 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DoNode.php +49 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DumpNode.php +58 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +125 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +60 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +81 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +91 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +155 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +141 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +82 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +180 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ImportNode.php +49 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +140 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeFileNode.php +81 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +94 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NAttrNode.php +105 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NClassNode.php +54 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +79 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ParametersNode.php +84 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/PrintNode.php +70 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RawPhpNode.php +46 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +37 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SkipNode.php +71 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +62 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +118 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplatePrintNode.php +39 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplateTypeNode.php +38 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TraceNode.php +35 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +104 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +75 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarNode.php +106 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarPrintNode.php +40 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarTypeNode.php +36 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +81 -0
- package/vendor/latte/latte/src/Latte/Essential/Passes.php +115 -0
- package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +28 -0
- package/vendor/latte/latte/src/Latte/Essential/RollbackException.php +16 -0
- package/vendor/latte/latte/src/Latte/Essential/Tracer.php +117 -0
- package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +101 -0
- package/vendor/latte/latte/src/Latte/Extension.php +97 -0
- package/vendor/latte/latte/src/Latte/Helpers.php +96 -0
- package/vendor/latte/latte/src/Latte/Loader.php +37 -0
- package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +95 -0
- package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +76 -0
- package/vendor/latte/latte/src/Latte/Policy.php +24 -0
- package/vendor/latte/latte/src/Latte/PositionAwareException.php +50 -0
- package/vendor/latte/latte/src/Latte/Runtime/Block.php +24 -0
- package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +151 -0
- package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +39 -0
- package/vendor/latte/latte/src/Latte/Runtime/Filters.php +234 -0
- package/vendor/latte/latte/src/Latte/Runtime/Html.php +35 -0
- package/vendor/latte/latte/src/Latte/Runtime/HtmlStringable.php +17 -0
- package/vendor/latte/latte/src/Latte/Runtime/Template.php +381 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallableNode.php +29 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +32 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallableNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/PropertyFetchNode.php +32 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +73 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticCallNode.php +31 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticCallableNode.php +30 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticPropertyFetchNode.php +32 -0
- package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +116 -0
- package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +132 -0
- package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +185 -0
- package/vendor/latte/latte/src/Latte/Strict.php +101 -0
- package/vendor/latte/latte/src/Latte/attributes.php +24 -0
- package/vendor/latte/latte/src/Latte/exceptions.php +69 -0
- package/vendor/latte/latte/src/Tools/Linter.php +175 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\CompileException;
|
|
13
|
+
use Latte\Compiler\Nodes\FragmentNode;
|
|
14
|
+
use Latte\Compiler\Nodes\Php\Expression\ArrayNode;
|
|
15
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
16
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
17
|
+
use Latte\Compiler\Nodes\TextNode;
|
|
18
|
+
use Latte\Compiler\PrintContext;
|
|
19
|
+
use Latte\Compiler\Tag;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* {switch} ... {case} ... {default}
|
|
24
|
+
*/
|
|
25
|
+
class SwitchNode extends StatementNode
|
|
26
|
+
{
|
|
27
|
+
public ?ExpressionNode $expression;
|
|
28
|
+
|
|
29
|
+
/** @var array<array{?ArrayNode, int, FragmentNode}> */
|
|
30
|
+
public array $cases = [];
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/** @return \Generator<int, ?array, array{FragmentNode, Tag}, static> */
|
|
34
|
+
public static function create(Tag $tag): \Generator
|
|
35
|
+
{
|
|
36
|
+
if ($tag->isNAttribute()) {
|
|
37
|
+
throw new CompileException('Attribute n:switch is not supported.', $tag->position);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
$node = new static;
|
|
41
|
+
$node->expression = $tag->parser->isEnd()
|
|
42
|
+
? null
|
|
43
|
+
: $tag->parser->parseExpression();
|
|
44
|
+
|
|
45
|
+
[$content, $nextTag] = yield ['case', 'default'];
|
|
46
|
+
foreach ($content->children as $child) {
|
|
47
|
+
if (!$child instanceof TextNode || !$child->isWhitespace()) {
|
|
48
|
+
throw new CompileException('No content is allowed between {switch} and {case}', $child->position);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
$default = 0;
|
|
53
|
+
while (true) {
|
|
54
|
+
if ($nextTag->name === 'case') {
|
|
55
|
+
$nextTag->expectArguments();
|
|
56
|
+
[$case, $line] = [$nextTag->parser->parseArguments(), $nextTag->position];
|
|
57
|
+
[$content, $nextTag] = yield ['case', 'default'];
|
|
58
|
+
$node->cases[] = [$case, $line, $content];
|
|
59
|
+
|
|
60
|
+
} elseif ($nextTag->name === 'default') {
|
|
61
|
+
if ($default++) {
|
|
62
|
+
throw new CompileException('Tag {switch} may only contain one {default} clause.', $nextTag->position);
|
|
63
|
+
}
|
|
64
|
+
$line = $nextTag->position;
|
|
65
|
+
[$content, $nextTag] = yield ['case', 'default'];
|
|
66
|
+
$node->cases[] = [null, $line, $content];
|
|
67
|
+
|
|
68
|
+
} else {
|
|
69
|
+
return $node;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
public function print(PrintContext $context): string
|
|
76
|
+
{
|
|
77
|
+
$res = $context->format(
|
|
78
|
+
'$ʟ_switch = (%node) %line;',
|
|
79
|
+
$this->expression,
|
|
80
|
+
$this->position,
|
|
81
|
+
);
|
|
82
|
+
$first = true;
|
|
83
|
+
$default = null;
|
|
84
|
+
foreach ($this->cases as [$case, $line, $content]) {
|
|
85
|
+
if (!$case) {
|
|
86
|
+
$default = $content->print($context);
|
|
87
|
+
continue;
|
|
88
|
+
} elseif (!$first) {
|
|
89
|
+
$res .= 'else';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
$first = false;
|
|
93
|
+
$res .= $context->format(
|
|
94
|
+
'if (in_array($ʟ_switch, %node, true)) %line { %node } ',
|
|
95
|
+
$case,
|
|
96
|
+
$line,
|
|
97
|
+
$content,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if ($default) {
|
|
102
|
+
$res .= $first ? $default : 'else { ' . $default . ' } ';
|
|
103
|
+
}
|
|
104
|
+
return $res;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
public function &getIterator(): \Generator
|
|
109
|
+
{
|
|
110
|
+
yield $this->expression;
|
|
111
|
+
foreach ($this->cases as [&$case, , &$stmt]) {
|
|
112
|
+
if ($case) {
|
|
113
|
+
yield $case;
|
|
114
|
+
}
|
|
115
|
+
yield $stmt;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
13
|
+
use Latte\Compiler\PhpHelpers;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
use Latte\Compiler\Tag;
|
|
16
|
+
use Latte\Compiler\Token;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* {templatePrint [ClassName]}
|
|
21
|
+
*/
|
|
22
|
+
class TemplatePrintNode extends StatementNode
|
|
23
|
+
{
|
|
24
|
+
public ?string $template;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public static function create(Tag $tag): static
|
|
28
|
+
{
|
|
29
|
+
$node = new static;
|
|
30
|
+
$node->template = $tag->parser->stream->tryConsume(Token::Php_Identifier, Token::Php_NameFullyQualified, Token::Php_NameQualified)?->text;
|
|
31
|
+
return $node;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
public function print(PrintContext $context): string
|
|
36
|
+
{
|
|
37
|
+
return '(new Latte\Essential\Blueprint)->printClass($this, ' . PhpHelpers::dump($this->template) . '); exit;';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\CompileException;
|
|
13
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
use Latte\Compiler\Tag;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* {templateType ClassName}
|
|
20
|
+
*/
|
|
21
|
+
class TemplateTypeNode extends StatementNode
|
|
22
|
+
{
|
|
23
|
+
public static function create(Tag $tag): static
|
|
24
|
+
{
|
|
25
|
+
if (!$tag->isInHead()) {
|
|
26
|
+
throw new CompileException('{templateType} is allowed only in template header.', $tag->position);
|
|
27
|
+
}
|
|
28
|
+
$tag->expectArguments('class name');
|
|
29
|
+
$tag->parser->parseExpression();
|
|
30
|
+
return new static;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
public function print(PrintContext $context): string
|
|
35
|
+
{
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
use Latte\Compiler\Tag;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* {trace}
|
|
19
|
+
*/
|
|
20
|
+
class TraceNode extends StatementNode
|
|
21
|
+
{
|
|
22
|
+
public static function create(Tag $tag): static
|
|
23
|
+
{
|
|
24
|
+
return new static;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
public function print(PrintContext $context): string
|
|
29
|
+
{
|
|
30
|
+
return $context->format(
|
|
31
|
+
'Latte\Essential\Tracer::throw() %line;',
|
|
32
|
+
$this->position,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\NodeHelpers;
|
|
13
|
+
use Latte\Compiler\Nodes\AreaNode;
|
|
14
|
+
use Latte\Compiler\Nodes\NopNode;
|
|
15
|
+
use Latte\Compiler\Nodes\Php;
|
|
16
|
+
use Latte\Compiler\Nodes\Php\ModifierNode;
|
|
17
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
18
|
+
use Latte\Compiler\Nodes\TextNode;
|
|
19
|
+
use Latte\Compiler\PrintContext;
|
|
20
|
+
use Latte\Compiler\Tag;
|
|
21
|
+
use Latte\Essential\TranslatorExtension;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* {translate} ... {/translate}
|
|
26
|
+
*/
|
|
27
|
+
class TranslateNode extends StatementNode
|
|
28
|
+
{
|
|
29
|
+
public AreaNode $content;
|
|
30
|
+
public ModifierNode $modifier;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/** @return \Generator<int, ?array, array{AreaNode, ?Tag}, static|NopNode> */
|
|
34
|
+
public static function create(Tag $tag, ?callable $translator): \Generator
|
|
35
|
+
{
|
|
36
|
+
$tag->outputMode = $tag::OutputKeepIndentation;
|
|
37
|
+
|
|
38
|
+
$node = new static;
|
|
39
|
+
$args = $tag->parser->parseArguments();
|
|
40
|
+
$node->modifier = $tag->parser->parseModifier();
|
|
41
|
+
$node->modifier->escape = true;
|
|
42
|
+
if ($tag->void) {
|
|
43
|
+
return new NopNode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[$node->content] = yield;
|
|
47
|
+
|
|
48
|
+
if ($text = NodeHelpers::toText($node->content)) {
|
|
49
|
+
if ($translator
|
|
50
|
+
&& is_array($values = TranslatorExtension::toValue($args))
|
|
51
|
+
&& is_string($translation = $translator($text, ...$values))
|
|
52
|
+
) {
|
|
53
|
+
$node->content = new TextNode($translation);
|
|
54
|
+
return $node;
|
|
55
|
+
}
|
|
56
|
+
$node->content = new TextNode($text);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
array_unshift($node->modifier->filters, new Php\FilterNode(new Php\IdentifierNode('translate'), $args->toArguments()));
|
|
60
|
+
|
|
61
|
+
return $node;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
public function print(PrintContext $context): string
|
|
66
|
+
{
|
|
67
|
+
if ($this->content instanceof TextNode) {
|
|
68
|
+
return $context->format(
|
|
69
|
+
<<<'XX'
|
|
70
|
+
$ʟ_fi = new LR\FilterInfo(%dump);
|
|
71
|
+
echo %modifyContent(%dump) %line;
|
|
72
|
+
XX,
|
|
73
|
+
$context->getEscaper()->export(),
|
|
74
|
+
$this->modifier,
|
|
75
|
+
$this->content->content,
|
|
76
|
+
$this->position,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
} else {
|
|
80
|
+
return $context->format(
|
|
81
|
+
<<<'XX'
|
|
82
|
+
ob_start(fn() => ''); try {
|
|
83
|
+
%node
|
|
84
|
+
} finally {
|
|
85
|
+
$ʟ_tmp = ob_get_clean();
|
|
86
|
+
}
|
|
87
|
+
$ʟ_fi = new LR\FilterInfo(%dump);
|
|
88
|
+
echo %modifyContent($ʟ_tmp) %line;
|
|
89
|
+
XX,
|
|
90
|
+
$this->content,
|
|
91
|
+
$context->getEscaper()->export(),
|
|
92
|
+
$this->modifier,
|
|
93
|
+
$this->position,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
public function &getIterator(): \Generator
|
|
100
|
+
{
|
|
101
|
+
yield $this->content;
|
|
102
|
+
yield $this->modifier;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\AreaNode;
|
|
13
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
14
|
+
use Latte\Compiler\PrintContext;
|
|
15
|
+
use Latte\Compiler\Tag;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* {try} ... {else}
|
|
20
|
+
*/
|
|
21
|
+
class TryNode extends StatementNode
|
|
22
|
+
{
|
|
23
|
+
public AreaNode $try;
|
|
24
|
+
public ?AreaNode $else = null;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/** @return \Generator<int, ?array, array{AreaNode, ?Tag}, static> */
|
|
28
|
+
public static function create(): \Generator
|
|
29
|
+
{
|
|
30
|
+
$node = new static;
|
|
31
|
+
[$node->try, $nextTag] = yield ['else'];
|
|
32
|
+
if ($nextTag?->name === 'else') {
|
|
33
|
+
[$node->else] = yield;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return $node;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
public function print(PrintContext $context): string
|
|
41
|
+
{
|
|
42
|
+
return $context->format(
|
|
43
|
+
<<<'XX'
|
|
44
|
+
$ʟ_try[%dump] = [$ʟ_it ?? null];
|
|
45
|
+
ob_start(fn() => '');
|
|
46
|
+
try %line {
|
|
47
|
+
%node
|
|
48
|
+
} catch (Throwable $ʟ_e) {
|
|
49
|
+
ob_end_clean();
|
|
50
|
+
if (!($ʟ_e instanceof Latte\Essential\RollbackException) && isset($this->global->coreExceptionHandler)) {
|
|
51
|
+
($this->global->coreExceptionHandler)($ʟ_e, $this);
|
|
52
|
+
}
|
|
53
|
+
%node
|
|
54
|
+
ob_start();
|
|
55
|
+
} finally {
|
|
56
|
+
echo ob_get_clean();
|
|
57
|
+
$iterator = $ʟ_it = $ʟ_try[%0.dump][0];
|
|
58
|
+
}
|
|
59
|
+
XX,
|
|
60
|
+
$context->generateId(),
|
|
61
|
+
$this->position,
|
|
62
|
+
$this->try,
|
|
63
|
+
$this->else,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
public function &getIterator(): \Generator
|
|
69
|
+
{
|
|
70
|
+
yield $this->try;
|
|
71
|
+
if ($this->else) {
|
|
72
|
+
yield $this->else;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\Php\Expression\AssignNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\Expression\VariableNode;
|
|
14
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
15
|
+
use Latte\Compiler\Nodes\Php\Scalar\NullNode;
|
|
16
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
17
|
+
use Latte\Compiler\PrintContext;
|
|
18
|
+
use Latte\Compiler\Tag;
|
|
19
|
+
use Latte\Compiler\Token;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* {var [type] $var = value, ...}
|
|
24
|
+
* {default [type] $var = value, ...}
|
|
25
|
+
*/
|
|
26
|
+
class VarNode extends StatementNode
|
|
27
|
+
{
|
|
28
|
+
public bool $default;
|
|
29
|
+
|
|
30
|
+
/** @var AssignNode[] */
|
|
31
|
+
public array $assignments = [];
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
public static function create(Tag $tag): static
|
|
35
|
+
{
|
|
36
|
+
$tag->expectArguments();
|
|
37
|
+
$node = new static;
|
|
38
|
+
$node->default = $tag->name === 'default';
|
|
39
|
+
$node->assignments = self::parseAssignments($tag, $node->default);
|
|
40
|
+
return $node;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
private static function parseAssignments(Tag $tag, bool $default): array
|
|
45
|
+
{
|
|
46
|
+
$stream = $tag->parser->stream;
|
|
47
|
+
$res = [];
|
|
48
|
+
do {
|
|
49
|
+
$tag->parser->parseType();
|
|
50
|
+
|
|
51
|
+
$save = $stream->getIndex();
|
|
52
|
+
$expr = $stream->is(Token::Php_Variable) ? $tag->parser->parseExpression() : null;
|
|
53
|
+
if ($expr instanceof VariableNode) {
|
|
54
|
+
$res[] = new AssignNode($expr, new NullNode);
|
|
55
|
+
} elseif ($expr instanceof AssignNode && (!$default || $expr->var instanceof VariableNode)) {
|
|
56
|
+
$res[] = $expr;
|
|
57
|
+
} else {
|
|
58
|
+
$stream->seek($save);
|
|
59
|
+
$stream->throwUnexpectedException(addendum: ' in ' . $tag->getNotation());
|
|
60
|
+
}
|
|
61
|
+
} while ($stream->tryConsume(','));
|
|
62
|
+
|
|
63
|
+
return $res;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
public function print(PrintContext $context): string
|
|
68
|
+
{
|
|
69
|
+
$res = [];
|
|
70
|
+
if ($this->default) {
|
|
71
|
+
foreach ($this->assignments as $assign) {
|
|
72
|
+
assert($assign->var instanceof VariableNode);
|
|
73
|
+
if ($assign->var->name instanceof ExpressionNode) {
|
|
74
|
+
$var = $assign->var->name->print($context);
|
|
75
|
+
} else {
|
|
76
|
+
$var = $context->encodeString($assign->var->name);
|
|
77
|
+
}
|
|
78
|
+
$res[] = $var . ' => ' . $assign->expr->print($context);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return $context->format(
|
|
82
|
+
'extract([%raw], EXTR_SKIP) %line;',
|
|
83
|
+
implode(', ', $res),
|
|
84
|
+
$this->position,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
foreach ($this->assignments as $assign) {
|
|
89
|
+
$res[] = $assign->print($context);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return $context->format(
|
|
93
|
+
'%raw %line;',
|
|
94
|
+
implode('; ', $res),
|
|
95
|
+
$this->position,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
public function &getIterator(): \Generator
|
|
101
|
+
{
|
|
102
|
+
foreach ($this->assignments as &$assign) {
|
|
103
|
+
yield $assign;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
use Latte\Compiler\Tag;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* {varPrint [all]}
|
|
19
|
+
*/
|
|
20
|
+
class VarPrintNode extends StatementNode
|
|
21
|
+
{
|
|
22
|
+
public bool $all;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
public static function create(Tag $tag): static
|
|
26
|
+
{
|
|
27
|
+
$stream = $tag->parser->stream;
|
|
28
|
+
$node = new static;
|
|
29
|
+
$node->all = $stream->consume()->text === 'all';
|
|
30
|
+
return $node;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
public function print(PrintContext $context): string
|
|
35
|
+
{
|
|
36
|
+
$vars = $this->all ? 'get_defined_vars()'
|
|
37
|
+
: 'array_diff_key(get_defined_vars(), $this->getParameters())';
|
|
38
|
+
return "(new Latte\\Essential\\Blueprint)->printVars($vars); exit;";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
13
|
+
use Latte\Compiler\PrintContext;
|
|
14
|
+
use Latte\Compiler\Tag;
|
|
15
|
+
use Latte\Compiler\Token;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* {varType type $var}
|
|
20
|
+
*/
|
|
21
|
+
class VarTypeNode extends StatementNode
|
|
22
|
+
{
|
|
23
|
+
public static function create(Tag $tag): static
|
|
24
|
+
{
|
|
25
|
+
$tag->expectArguments();
|
|
26
|
+
$tag->parser->parseType();
|
|
27
|
+
$tag->parser->stream->consume(Token::Php_Variable);
|
|
28
|
+
return new static;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
public function print(PrintContext $context): string
|
|
33
|
+
{
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare(strict_types=1);
|
|
9
|
+
|
|
10
|
+
namespace Latte\Essential\Nodes;
|
|
11
|
+
|
|
12
|
+
use Latte\Compiler\Nodes\AreaNode;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\ExpressionNode;
|
|
14
|
+
use Latte\Compiler\Nodes\StatementNode;
|
|
15
|
+
use Latte\Compiler\PrintContext;
|
|
16
|
+
use Latte\Compiler\Tag;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* {while $cond}
|
|
21
|
+
*/
|
|
22
|
+
class WhileNode extends StatementNode
|
|
23
|
+
{
|
|
24
|
+
public ExpressionNode $condition;
|
|
25
|
+
public AreaNode $content;
|
|
26
|
+
public bool $postTest;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/** @return \Generator<int, ?array, array{AreaNode, ?Tag}, static> */
|
|
30
|
+
public static function create(Tag $tag): \Generator
|
|
31
|
+
{
|
|
32
|
+
$node = new static;
|
|
33
|
+
$node->postTest = $tag->parser->isEnd();
|
|
34
|
+
if (!$node->postTest) {
|
|
35
|
+
$node->condition = $tag->parser->parseExpression();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[$node->content, $nextTag] = yield;
|
|
39
|
+
if ($node->postTest) {
|
|
40
|
+
$nextTag->expectArguments();
|
|
41
|
+
$node->condition = $nextTag->parser->parseExpression();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return $node;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
public function print(PrintContext $context): string
|
|
49
|
+
{
|
|
50
|
+
return $this->postTest
|
|
51
|
+
? $context->format(
|
|
52
|
+
<<<'XX'
|
|
53
|
+
do %line {
|
|
54
|
+
%node
|
|
55
|
+
} while (%node);
|
|
56
|
+
|
|
57
|
+
XX,
|
|
58
|
+
$this->position,
|
|
59
|
+
$this->content,
|
|
60
|
+
$this->condition,
|
|
61
|
+
)
|
|
62
|
+
: $context->format(
|
|
63
|
+
<<<'XX'
|
|
64
|
+
while (%node) %line {
|
|
65
|
+
%node
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
XX,
|
|
69
|
+
$this->condition,
|
|
70
|
+
$this->position,
|
|
71
|
+
$this->content,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
public function &getIterator(): \Generator
|
|
77
|
+
{
|
|
78
|
+
yield $this->condition;
|
|
79
|
+
yield $this->content;
|
|
80
|
+
}
|
|
81
|
+
}
|