@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,259 @@
|
|
|
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\Compiler;
|
|
11
|
+
|
|
12
|
+
use Latte;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
final class Token
|
|
16
|
+
{
|
|
17
|
+
use Latte\Strict;
|
|
18
|
+
|
|
19
|
+
public const
|
|
20
|
+
End = 0,
|
|
21
|
+
Text = 10000,
|
|
22
|
+
Whitespace = 10002,
|
|
23
|
+
Newline = 10003,
|
|
24
|
+
Indentation = 10004,
|
|
25
|
+
Slash = 10005,
|
|
26
|
+
Equals = 10006,
|
|
27
|
+
Quote = 10007; // single or double quote
|
|
28
|
+
|
|
29
|
+
public const
|
|
30
|
+
Latte_TagOpen = 10010,
|
|
31
|
+
Latte_TagClose = 10011,
|
|
32
|
+
Latte_Name = 10012,
|
|
33
|
+
Latte_CommentOpen = 10014,
|
|
34
|
+
Latte_CommentClose = 10015;
|
|
35
|
+
|
|
36
|
+
public const
|
|
37
|
+
Html_TagOpen = 10020,
|
|
38
|
+
Html_TagClose = 10021,
|
|
39
|
+
Html_CommentOpen = 10022,
|
|
40
|
+
Html_CommentClose = 10023,
|
|
41
|
+
Html_BogusOpen = 10024,
|
|
42
|
+
Html_Name = 10025;
|
|
43
|
+
|
|
44
|
+
public const
|
|
45
|
+
Php_LogicalOr = 257,
|
|
46
|
+
Php_LogicalXor = 258,
|
|
47
|
+
Php_LogicalAnd = 259,
|
|
48
|
+
Php_DoubleArrow = 260,
|
|
49
|
+
Php_PlusEqual = 261,
|
|
50
|
+
Php_MinusEqual = 262,
|
|
51
|
+
Php_MulEqual = 263,
|
|
52
|
+
Php_DivEqual = 264,
|
|
53
|
+
Php_ConcatEqual = 265,
|
|
54
|
+
Php_ModEqual = 266,
|
|
55
|
+
Php_AndEqual = 267,
|
|
56
|
+
Php_OrEqual = 268,
|
|
57
|
+
Php_XorEqual = 269,
|
|
58
|
+
Php_SlEqual = 270,
|
|
59
|
+
Php_SrEqual = 271,
|
|
60
|
+
Php_PowEqual = 272,
|
|
61
|
+
Php_CoalesceEqual = 273,
|
|
62
|
+
Php_Coalesce = 274,
|
|
63
|
+
Php_BooleanOr = 275,
|
|
64
|
+
Php_BooleanAnd = 276,
|
|
65
|
+
Php_AmpersandNotFollowed = 277,
|
|
66
|
+
Php_AmpersandFollowed = 278,
|
|
67
|
+
Php_IsEqual = 279,
|
|
68
|
+
Php_IsNotEqual = 280,
|
|
69
|
+
Php_IsIdentical = 281,
|
|
70
|
+
Php_IsNotIdentical = 282,
|
|
71
|
+
Php_Spaceship = 283,
|
|
72
|
+
Php_IsSmallerOrEqual = 284,
|
|
73
|
+
Php_IsGreaterOrEqual = 285,
|
|
74
|
+
Php_Sl = 286,
|
|
75
|
+
Php_Sr = 287,
|
|
76
|
+
Php_In = 288,
|
|
77
|
+
Php_Instanceof = 289,
|
|
78
|
+
Php_Inc = 290,
|
|
79
|
+
Php_Dec = 291,
|
|
80
|
+
Php_IntCast = 292,
|
|
81
|
+
Php_FloatCast = 293,
|
|
82
|
+
Php_StringCast = 294,
|
|
83
|
+
Php_ArrayCast = 295,
|
|
84
|
+
Php_ObjectCast = 296,
|
|
85
|
+
Php_BoolCast = 297,
|
|
86
|
+
Php_Pow = 298,
|
|
87
|
+
Php_New = 299,
|
|
88
|
+
Php_Clone = 300,
|
|
89
|
+
Php_Integer = 301,
|
|
90
|
+
Php_Float = 302,
|
|
91
|
+
Php_Identifier = 303,
|
|
92
|
+
Php_StringVarname = 304,
|
|
93
|
+
Php_Constant = 305,
|
|
94
|
+
Php_Variable = 306,
|
|
95
|
+
Php_NumString = 307,
|
|
96
|
+
Php_EncapsedAndWhitespace = 308,
|
|
97
|
+
Php_ConstantEncapsedString = 309,
|
|
98
|
+
Php_Match = 310,
|
|
99
|
+
Php_Default = 311,
|
|
100
|
+
Php_Function = 312,
|
|
101
|
+
Php_Fn = 313,
|
|
102
|
+
Php_Return = 314,
|
|
103
|
+
Php_Use = 315,
|
|
104
|
+
Php_Isset = 316,
|
|
105
|
+
Php_Empty = 317,
|
|
106
|
+
Php_ObjectOperator = 318,
|
|
107
|
+
Php_NullsafeObjectOperator = 319,
|
|
108
|
+
Php_UndefinedsafeObjectOperator = 320,
|
|
109
|
+
Php_List = 321,
|
|
110
|
+
Php_Array = 322,
|
|
111
|
+
Php_StartHeredoc = 323,
|
|
112
|
+
Php_EndHeredoc = 324,
|
|
113
|
+
Php_DollarOpenCurlyBraces = 325,
|
|
114
|
+
Php_CurlyOpen = 326,
|
|
115
|
+
Php_PaamayimNekudotayim = 327,
|
|
116
|
+
Php_NsSeparator = 328,
|
|
117
|
+
Php_Ellipsis = 329,
|
|
118
|
+
Php_ExpandCast = 330,
|
|
119
|
+
Php_NameFullyQualified = 331,
|
|
120
|
+
Php_NameQualified = 332,
|
|
121
|
+
Php_Whitespace = 333,
|
|
122
|
+
Php_Comment = 334,
|
|
123
|
+
Php_Null = 335,
|
|
124
|
+
Php_True = 336,
|
|
125
|
+
Php_False = 337;
|
|
126
|
+
|
|
127
|
+
public const NAMES = [
|
|
128
|
+
self::End => '[EOF]',
|
|
129
|
+
self::Text => 'text',
|
|
130
|
+
self::Whitespace => 'whitespace',
|
|
131
|
+
self::Newline => 'newline',
|
|
132
|
+
self::Indentation => 'indentation',
|
|
133
|
+
self::Slash => "'/'",
|
|
134
|
+
self::Equals => "'='",
|
|
135
|
+
self::Quote => 'quote',
|
|
136
|
+
|
|
137
|
+
self::Latte_TagOpen => "'{'",
|
|
138
|
+
self::Latte_TagClose => "'}'",
|
|
139
|
+
self::Latte_Name => 'tag name',
|
|
140
|
+
self::Latte_CommentOpen => "'{*'",
|
|
141
|
+
self::Latte_CommentClose => "'*}'",
|
|
142
|
+
|
|
143
|
+
self::Html_TagOpen => 'HTML tag',
|
|
144
|
+
self::Html_TagClose => 'end of HTML tag',
|
|
145
|
+
self::Html_CommentOpen => 'HTML comment',
|
|
146
|
+
self::Html_CommentClose => 'end of HTML comment',
|
|
147
|
+
self::Html_BogusOpen => 'HTML bogus tag',
|
|
148
|
+
self::Html_Name => 'HTML name',
|
|
149
|
+
|
|
150
|
+
self::Php_LogicalOr => "'or'",
|
|
151
|
+
self::Php_LogicalXor => "'xor'",
|
|
152
|
+
self::Php_LogicalAnd => "'and'",
|
|
153
|
+
self::Php_DoubleArrow => "'=>'",
|
|
154
|
+
self::Php_PlusEqual => "'+='",
|
|
155
|
+
self::Php_MinusEqual => "'-='",
|
|
156
|
+
self::Php_MulEqual => "'*='",
|
|
157
|
+
self::Php_DivEqual => "'/='",
|
|
158
|
+
self::Php_ConcatEqual => "'.='",
|
|
159
|
+
self::Php_ModEqual => "'%='",
|
|
160
|
+
self::Php_AndEqual => "'&='",
|
|
161
|
+
self::Php_OrEqual => "'|='",
|
|
162
|
+
self::Php_XorEqual => "'^='",
|
|
163
|
+
self::Php_SlEqual => "'<<='",
|
|
164
|
+
self::Php_SrEqual => "'>>='",
|
|
165
|
+
self::Php_PowEqual => "'**='",
|
|
166
|
+
self::Php_CoalesceEqual => "'??='",
|
|
167
|
+
self::Php_Coalesce => "'??'",
|
|
168
|
+
self::Php_BooleanOr => "'||'",
|
|
169
|
+
self::Php_BooleanAnd => "'&&'",
|
|
170
|
+
self::Php_AmpersandNotFollowed => "'&'",
|
|
171
|
+
self::Php_AmpersandFollowed => "'&'",
|
|
172
|
+
self::Php_IsEqual => "'=='",
|
|
173
|
+
self::Php_IsNotEqual => "'!='",
|
|
174
|
+
self::Php_IsIdentical => "'==='",
|
|
175
|
+
self::Php_IsNotIdentical => "'!=='",
|
|
176
|
+
self::Php_Spaceship => "'<=>'",
|
|
177
|
+
self::Php_IsSmallerOrEqual => "'<='",
|
|
178
|
+
self::Php_IsGreaterOrEqual => "'>='",
|
|
179
|
+
self::Php_Sl => "'<<'",
|
|
180
|
+
self::Php_Sr => "'>>'",
|
|
181
|
+
self::Php_In => "'in'",
|
|
182
|
+
self::Php_Instanceof => "'instanceof'",
|
|
183
|
+
self::Php_Inc => "'++'",
|
|
184
|
+
self::Php_Dec => "'--'",
|
|
185
|
+
self::Php_IntCast => "'(int)'",
|
|
186
|
+
self::Php_FloatCast => "'(float)'",
|
|
187
|
+
self::Php_StringCast => "'(string)'",
|
|
188
|
+
self::Php_ArrayCast => "'(array)'",
|
|
189
|
+
self::Php_ObjectCast => "'(object)'",
|
|
190
|
+
self::Php_BoolCast => "'(bool)'",
|
|
191
|
+
self::Php_Pow => "'**'",
|
|
192
|
+
self::Php_New => "'new'",
|
|
193
|
+
self::Php_Clone => "'clone'",
|
|
194
|
+
self::Php_Integer => 'integer',
|
|
195
|
+
self::Php_Float => 'floating-point number',
|
|
196
|
+
self::Php_Identifier => 'identifier',
|
|
197
|
+
self::Php_StringVarname => 'variable name',
|
|
198
|
+
self::Php_Constant => 'constant',
|
|
199
|
+
self::Php_Variable => 'variable',
|
|
200
|
+
self::Php_NumString => 'number',
|
|
201
|
+
self::Php_EncapsedAndWhitespace => 'string content',
|
|
202
|
+
self::Php_ConstantEncapsedString => 'quoted string',
|
|
203
|
+
self::Php_Match => "'match'",
|
|
204
|
+
self::Php_Default => "'default'",
|
|
205
|
+
self::Php_Function => "'function'",
|
|
206
|
+
self::Php_Fn => "'fn'",
|
|
207
|
+
self::Php_Return => "'return'",
|
|
208
|
+
self::Php_Use => "'use'",
|
|
209
|
+
self::Php_Isset => "'isset'",
|
|
210
|
+
self::Php_Empty => "'empty'",
|
|
211
|
+
self::Php_ObjectOperator => "'->'",
|
|
212
|
+
self::Php_NullsafeObjectOperator => "'?->'",
|
|
213
|
+
self::Php_UndefinedsafeObjectOperator => "'??->'",
|
|
214
|
+
self::Php_List => "'list'",
|
|
215
|
+
self::Php_Array => "'array'",
|
|
216
|
+
self::Php_StartHeredoc => 'heredoc start',
|
|
217
|
+
self::Php_EndHeredoc => 'heredoc end',
|
|
218
|
+
self::Php_DollarOpenCurlyBraces => "'\${'",
|
|
219
|
+
self::Php_CurlyOpen => "'{\$'",
|
|
220
|
+
self::Php_PaamayimNekudotayim => "'::'",
|
|
221
|
+
self::Php_NsSeparator => "'\\'",
|
|
222
|
+
self::Php_Ellipsis => "'...'",
|
|
223
|
+
self::Php_ExpandCast => "'(expand)'",
|
|
224
|
+
self::Php_NameFullyQualified => 'fully qualified name',
|
|
225
|
+
self::Php_NameQualified => 'namespaced name',
|
|
226
|
+
self::Php_Whitespace => 'whitespace',
|
|
227
|
+
self::Php_Comment => 'comment',
|
|
228
|
+
self::Php_Null => "'null'",
|
|
229
|
+
self::Php_True => "'true'",
|
|
230
|
+
self::Php_False => "'false'",
|
|
231
|
+
];
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
public function __construct(
|
|
235
|
+
public /*readonly*/ int $type,
|
|
236
|
+
public /*readonly*/ string $text,
|
|
237
|
+
public /*readonly*/ ?Position $position = null,
|
|
238
|
+
) {
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
public function is(int|string ...$kind): bool
|
|
243
|
+
{
|
|
244
|
+
return in_array($this->type, $kind, true)
|
|
245
|
+
|| in_array($this->text, $kind, true);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
public function isEnd(): bool
|
|
250
|
+
{
|
|
251
|
+
return $this->type === self::End;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
public function isPhpKind(): bool
|
|
256
|
+
{
|
|
257
|
+
return $this->type > 0 && $this->type < 10000;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
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\Compiler;
|
|
11
|
+
|
|
12
|
+
use Latte;
|
|
13
|
+
use Latte\CompileException;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* TokenStream loads tokens from $source iterator on-demand, and places them in a buffer to provide access
|
|
18
|
+
* to any previous token by index.
|
|
19
|
+
*/
|
|
20
|
+
final class TokenStream
|
|
21
|
+
{
|
|
22
|
+
use Latte\Strict;
|
|
23
|
+
|
|
24
|
+
/** @var Token[] */
|
|
25
|
+
private array $tokens = [];
|
|
26
|
+
private \Iterator /*readonly*/ $source;
|
|
27
|
+
private int $index = 0;
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
public function __construct(\Iterator $source)
|
|
31
|
+
{
|
|
32
|
+
$this->source = $source;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Tells whether the token at current position is of given kind.
|
|
38
|
+
*/
|
|
39
|
+
public function is(int|string ...$kind): bool
|
|
40
|
+
{
|
|
41
|
+
return $this->peek()->is(...$kind);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Gets the token at $offset from the current position.
|
|
47
|
+
*/
|
|
48
|
+
public function peek(int $offset = 0): ?Token
|
|
49
|
+
{
|
|
50
|
+
$pos = $this->index + $offset;
|
|
51
|
+
while ($pos >= 0 && !isset($this->tokens[$pos]) && $this->source->valid()) {
|
|
52
|
+
if ($this->tokens) {
|
|
53
|
+
$this->source->next();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if ($this->source->valid()) {
|
|
57
|
+
$this->tokens[] = $this->source->current();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return $this->tokens[$pos] ?? null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Consumes the current token (if is of given kind) or throws exception on end.
|
|
67
|
+
* @throws CompileException
|
|
68
|
+
*/
|
|
69
|
+
public function consume(int|string ...$kind): Token
|
|
70
|
+
{
|
|
71
|
+
$token = $this->peek();
|
|
72
|
+
if ($kind && !$token->is(...$kind)) {
|
|
73
|
+
$kind = array_map(fn($item) => is_string($item) ? "'$item'" : Token::NAMES[$item], $kind);
|
|
74
|
+
$this->throwUnexpectedException($kind);
|
|
75
|
+
} elseif (!$token->isEnd()) {
|
|
76
|
+
$this->index++;
|
|
77
|
+
}
|
|
78
|
+
return $token;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Consumes the current token of given kind or returns null.
|
|
84
|
+
*/
|
|
85
|
+
public function tryConsume(int|string ...$kind): ?Token
|
|
86
|
+
{
|
|
87
|
+
$token = $this->peek();
|
|
88
|
+
if (!$token->is(...$kind)) {
|
|
89
|
+
return null;
|
|
90
|
+
} elseif (!$token->isEnd()) {
|
|
91
|
+
$this->index++;
|
|
92
|
+
}
|
|
93
|
+
return $token;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Sets the input cursor to the position.
|
|
99
|
+
*/
|
|
100
|
+
public function seek(int $index): void
|
|
101
|
+
{
|
|
102
|
+
if ($index >= count($this->tokens) || $index < 0) {
|
|
103
|
+
throw new \InvalidArgumentException('The position is out of range.');
|
|
104
|
+
}
|
|
105
|
+
$this->index = $index;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Returns the cursor position.
|
|
111
|
+
*/
|
|
112
|
+
public function getIndex(): int
|
|
113
|
+
{
|
|
114
|
+
return $this->index;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @throws CompileException
|
|
120
|
+
* @return never
|
|
121
|
+
*/
|
|
122
|
+
public function throwUnexpectedException(array $expected = [], string $addendum = ''): void
|
|
123
|
+
{
|
|
124
|
+
$s = null;
|
|
125
|
+
$i = 0;
|
|
126
|
+
do {
|
|
127
|
+
$token = $this->peek($i++);
|
|
128
|
+
if ($token->isEnd()) {
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
$s .= $token->text;
|
|
132
|
+
if (strlen($s) > 5) {
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
} while (true);
|
|
136
|
+
|
|
137
|
+
$expected = array_map(fn($item) => is_int($item) ? Token::NAMES[$item] : $item, $expected);
|
|
138
|
+
|
|
139
|
+
throw new CompileException(
|
|
140
|
+
'Unexpected '
|
|
141
|
+
. ($s === null
|
|
142
|
+
? 'end'
|
|
143
|
+
: "'" . trim($s, "\n") . "'")
|
|
144
|
+
. ($expected && count($expected) < 5
|
|
145
|
+
? ', expecting ' . implode(', ', $expected)
|
|
146
|
+
: '')
|
|
147
|
+
. $addendum,
|
|
148
|
+
$this->peek()->position,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/*enum*/ final class ContentType
|
|
14
|
+
{
|
|
15
|
+
public const
|
|
16
|
+
Text = 'text',
|
|
17
|
+
Html = 'html',
|
|
18
|
+
Xml = 'xml',
|
|
19
|
+
JavaScript = 'js',
|
|
20
|
+
Css = 'css',
|
|
21
|
+
ICal = 'ical';
|
|
22
|
+
}
|