@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.
Files changed (201) hide show
  1. package/README.md +39 -0
  2. package/handler.js +9 -0
  3. package/index.js +138 -0
  4. package/index.php +173 -0
  5. package/latte/AssetFilter.php +11 -0
  6. package/latte/FetchFunction.php +28 -0
  7. package/latte/IconFilter.php +14 -0
  8. package/latte/JsonTag.php +64 -0
  9. package/latte/PlaceholderFunction.php +11 -0
  10. package/latte/RandomColorFunction.php +14 -0
  11. package/latte/TelFilter.php +22 -0
  12. package/package.json +35 -0
  13. package/vendor/autoload.php +7 -0
  14. package/vendor/bin/latte-lint +107 -0
  15. package/vendor/composer/ClassLoader.php +572 -0
  16. package/vendor/composer/InstalledVersions.php +350 -0
  17. package/vendor/composer/LICENSE +21 -0
  18. package/vendor/composer/autoload_classmap.php +183 -0
  19. package/vendor/composer/autoload_namespaces.php +9 -0
  20. package/vendor/composer/autoload_psr4.php +9 -0
  21. package/vendor/composer/autoload_real.php +57 -0
  22. package/vendor/composer/autoload_static.php +193 -0
  23. package/vendor/composer/installed.json +93 -0
  24. package/vendor/composer/installed.php +32 -0
  25. package/vendor/composer/platform_check.php +26 -0
  26. package/vendor/latte/latte/bin/latte-lint +29 -0
  27. package/vendor/latte/latte/composer.json +53 -0
  28. package/vendor/latte/latte/license.md +60 -0
  29. package/vendor/latte/latte/ncs.php +14 -0
  30. package/vendor/latte/latte/ncs.xml +9 -0
  31. package/vendor/latte/latte/readme.md +21 -0
  32. package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +114 -0
  33. package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +99 -0
  34. package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.panel.phtml +98 -0
  35. package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.tab.phtml +15 -0
  36. package/vendor/latte/latte/src/Latte/Compiler/Block.php +44 -0
  37. package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +244 -0
  38. package/vendor/latte/latte/src/Latte/Compiler/ExpressionBuilder.php +128 -0
  39. package/vendor/latte/latte/src/Latte/Compiler/Node.php +28 -0
  40. package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +132 -0
  41. package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +77 -0
  42. package/vendor/latte/latte/src/Latte/Compiler/Nodes/AreaNode.php +17 -0
  43. package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +27 -0
  44. package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +59 -0
  45. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +48 -0
  46. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/BogusTagNode.php +46 -0
  47. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/CommentNode.php +39 -0
  48. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +129 -0
  49. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/QuotedValue.php +53 -0
  50. package/vendor/latte/latte/src/Latte/Compiler/Nodes/NopNode.php +21 -0
  51. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +45 -0
  52. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ComplexTypeNode.php +17 -0
  53. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayAccessNode.php +41 -0
  54. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayItemNode.php +52 -0
  55. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +94 -0
  56. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +39 -0
  57. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +45 -0
  58. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/BinaryOpNode.php +65 -0
  59. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CastNode.php +43 -0
  60. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +42 -0
  61. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CloneNode.php +36 -0
  62. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +73 -0
  63. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureUseNode.php +37 -0
  64. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +37 -0
  65. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/EmptyNode.php +36 -0
  66. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ErrorSuppressNode.php +36 -0
  67. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FilterCallNode.php +39 -0
  68. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallNode.php +45 -0
  69. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallableNode.php +39 -0
  70. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InRangeNode.php +42 -0
  71. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InstanceofNode.php +40 -0
  72. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +40 -0
  73. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MatchNode.php +49 -0
  74. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallNode.php +50 -0
  75. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallableNode.php +42 -0
  76. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NewNode.php +45 -0
  77. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NotNode.php +36 -0
  78. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +43 -0
  79. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +43 -0
  80. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PropertyFetchNode.php +42 -0
  81. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticCallNode.php +55 -0
  82. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticCallableNode.php +47 -0
  83. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticPropertyFetchNode.php +42 -0
  84. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TernaryNode.php +50 -0
  85. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php +45 -0
  86. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/VariableNode.php +40 -0
  87. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +17 -0
  88. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/FilterNode.php +67 -0
  89. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IdentifierNode.php +36 -0
  90. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IntersectionTypeNode.php +39 -0
  91. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/MatchArmNode.php +45 -0
  92. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +107 -0
  93. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NameNode.php +89 -0
  94. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NullableTypeNode.php +35 -0
  95. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ParameterNode.php +54 -0
  96. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/BooleanNode.php +30 -0
  97. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/EncapsedStringNode.php +80 -0
  98. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/EncapsedStringPartNode.php +30 -0
  99. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/FloatNode.php +63 -0
  100. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/IntegerNode.php +70 -0
  101. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/NullNode.php +29 -0
  102. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/StringNode.php +40 -0
  103. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ScalarNode.php +15 -0
  104. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/SuperiorTypeNode.php +29 -0
  105. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/UnionTypeNode.php +39 -0
  106. package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VarLikeIdentifierNode.php +21 -0
  107. package/vendor/latte/latte/src/Latte/Compiler/Nodes/StatementNode.php +15 -0
  108. package/vendor/latte/latte/src/Latte/Compiler/Nodes/TemplateNode.php +34 -0
  109. package/vendor/latte/latte/src/Latte/Compiler/Nodes/TextNode.php +37 -0
  110. package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +227 -0
  111. package/vendor/latte/latte/src/Latte/Compiler/Position.php +43 -0
  112. package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +334 -0
  113. package/vendor/latte/latte/src/Latte/Compiler/Tag.php +117 -0
  114. package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +399 -0
  115. package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +388 -0
  116. package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +580 -0
  117. package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +206 -0
  118. package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +391 -0
  119. package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +448 -0
  120. package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +506 -0
  121. package/vendor/latte/latte/src/Latte/Compiler/Token.php +259 -0
  122. package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +151 -0
  123. package/vendor/latte/latte/src/Latte/ContentType.php +22 -0
  124. package/vendor/latte/latte/src/Latte/Engine.php +591 -0
  125. package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +160 -0
  126. package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +232 -0
  127. package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +232 -0
  128. package/vendor/latte/latte/src/Latte/Essential/Filters.php +591 -0
  129. package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +161 -0
  130. package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +98 -0
  131. package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +74 -0
  132. package/vendor/latte/latte/src/Latte/Essential/Nodes/DebugbreakNode.php +53 -0
  133. package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +134 -0
  134. package/vendor/latte/latte/src/Latte/Essential/Nodes/DoNode.php +49 -0
  135. package/vendor/latte/latte/src/Latte/Essential/Nodes/DumpNode.php +58 -0
  136. package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +125 -0
  137. package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +60 -0
  138. package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +81 -0
  139. package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +91 -0
  140. package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +155 -0
  141. package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +141 -0
  142. package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +82 -0
  143. package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +180 -0
  144. package/vendor/latte/latte/src/Latte/Essential/Nodes/ImportNode.php +49 -0
  145. package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +140 -0
  146. package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeFileNode.php +81 -0
  147. package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +94 -0
  148. package/vendor/latte/latte/src/Latte/Essential/Nodes/NAttrNode.php +105 -0
  149. package/vendor/latte/latte/src/Latte/Essential/Nodes/NClassNode.php +54 -0
  150. package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +79 -0
  151. package/vendor/latte/latte/src/Latte/Essential/Nodes/ParametersNode.php +84 -0
  152. package/vendor/latte/latte/src/Latte/Essential/Nodes/PrintNode.php +70 -0
  153. package/vendor/latte/latte/src/Latte/Essential/Nodes/RawPhpNode.php +46 -0
  154. package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +37 -0
  155. package/vendor/latte/latte/src/Latte/Essential/Nodes/SkipNode.php +71 -0
  156. package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +62 -0
  157. package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +118 -0
  158. package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplatePrintNode.php +39 -0
  159. package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplateTypeNode.php +38 -0
  160. package/vendor/latte/latte/src/Latte/Essential/Nodes/TraceNode.php +35 -0
  161. package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +104 -0
  162. package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +75 -0
  163. package/vendor/latte/latte/src/Latte/Essential/Nodes/VarNode.php +106 -0
  164. package/vendor/latte/latte/src/Latte/Essential/Nodes/VarPrintNode.php +40 -0
  165. package/vendor/latte/latte/src/Latte/Essential/Nodes/VarTypeNode.php +36 -0
  166. package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +81 -0
  167. package/vendor/latte/latte/src/Latte/Essential/Passes.php +115 -0
  168. package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +28 -0
  169. package/vendor/latte/latte/src/Latte/Essential/RollbackException.php +16 -0
  170. package/vendor/latte/latte/src/Latte/Essential/Tracer.php +117 -0
  171. package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +101 -0
  172. package/vendor/latte/latte/src/Latte/Extension.php +97 -0
  173. package/vendor/latte/latte/src/Latte/Helpers.php +96 -0
  174. package/vendor/latte/latte/src/Latte/Loader.php +37 -0
  175. package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +95 -0
  176. package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +76 -0
  177. package/vendor/latte/latte/src/Latte/Policy.php +24 -0
  178. package/vendor/latte/latte/src/Latte/PositionAwareException.php +50 -0
  179. package/vendor/latte/latte/src/Latte/Runtime/Block.php +24 -0
  180. package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +151 -0
  181. package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +39 -0
  182. package/vendor/latte/latte/src/Latte/Runtime/Filters.php +234 -0
  183. package/vendor/latte/latte/src/Latte/Runtime/Html.php +35 -0
  184. package/vendor/latte/latte/src/Latte/Runtime/HtmlStringable.php +17 -0
  185. package/vendor/latte/latte/src/Latte/Runtime/Template.php +381 -0
  186. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +30 -0
  187. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallableNode.php +29 -0
  188. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +32 -0
  189. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallableNode.php +30 -0
  190. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/PropertyFetchNode.php +32 -0
  191. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +73 -0
  192. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticCallNode.php +31 -0
  193. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticCallableNode.php +30 -0
  194. package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticPropertyFetchNode.php +32 -0
  195. package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +116 -0
  196. package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +132 -0
  197. package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +185 -0
  198. package/vendor/latte/latte/src/Latte/Strict.php +101 -0
  199. package/vendor/latte/latte/src/Latte/attributes.php +24 -0
  200. package/vendor/latte/latte/src/Latte/exceptions.php +69 -0
  201. 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
+ }