guard-mthaml 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (341) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +34 -0
  3. data/lib/guard/mthaml.rb +140 -0
  4. data/lib/guard/mthaml/compiler/MtHaml.php +255 -0
  5. data/lib/guard/mthaml/templates/Guardfile +12 -0
  6. data/lib/guard/mthaml/version.rb +5 -0
  7. data/vendor/autoload.php +7 -0
  8. data/vendor/coffeescript/coffeescript/LICENSE +22 -0
  9. data/vendor/coffeescript/coffeescript/README.md +96 -0
  10. data/vendor/coffeescript/coffeescript/composer.json +23 -0
  11. data/vendor/coffeescript/coffeescript/grammar.y +309 -0
  12. data/vendor/coffeescript/coffeescript/make.php +115 -0
  13. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Compiler.php +76 -0
  14. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Error.php +15 -0
  15. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Helpers.php +116 -0
  16. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Init.php +96 -0
  17. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Lexer.php +1356 -0
  18. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Nodes.php +105 -0
  19. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Parser.php +3326 -0
  20. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Rewriter.php +552 -0
  21. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Scope.php +196 -0
  22. data/vendor/coffeescript/coffeescript/src/CoffeeScript/SyntaxError.php +9 -0
  23. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Value.php +20 -0
  24. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Access.php +31 -0
  25. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Arr.php +69 -0
  26. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Assign.php +353 -0
  27. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Base.php +288 -0
  28. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Block.php +294 -0
  29. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Call.php +283 -0
  30. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Class.php +282 -0
  31. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Closure.php +49 -0
  32. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Code.php +203 -0
  33. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Comment.php +39 -0
  34. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Existence.php +42 -0
  35. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Extends.php +26 -0
  36. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/For.php +250 -0
  37. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/If.php +161 -0
  38. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/In.php +99 -0
  39. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Index.php +27 -0
  40. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Literal.php +96 -0
  41. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Obj.php +126 -0
  42. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Op.php +292 -0
  43. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Param.php +119 -0
  44. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Parens.php +45 -0
  45. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Range.php +225 -0
  46. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Return.php +56 -0
  47. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Slice.php +47 -0
  48. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Splat.php +100 -0
  49. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Switch.php +121 -0
  50. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Throw.php +37 -0
  51. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Try.php +79 -0
  52. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Value.php +210 -0
  53. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/While.php +112 -0
  54. data/vendor/coffeescript/coffeescript/tests/cases/arrays.coffee +77 -0
  55. data/vendor/coffeescript/coffeescript/tests/cases/assignment.coffee +352 -0
  56. data/vendor/coffeescript/coffeescript/tests/cases/booleans.coffee +21 -0
  57. data/vendor/coffeescript/coffeescript/tests/cases/classes.coffee +681 -0
  58. data/vendor/coffeescript/coffeescript/tests/cases/comments.coffee +207 -0
  59. data/vendor/coffeescript/coffeescript/tests/cases/compilation.coffee +72 -0
  60. data/vendor/coffeescript/coffeescript/tests/cases/comprehensions.coffee +501 -0
  61. data/vendor/coffeescript/coffeescript/tests/cases/control_flow.coffee +430 -0
  62. data/vendor/coffeescript/coffeescript/tests/cases/eval.coffee +29 -0
  63. data/vendor/coffeescript/coffeescript/tests/cases/exception_handling.coffee +102 -0
  64. data/vendor/coffeescript/coffeescript/tests/cases/formatting.coffee +146 -0
  65. data/vendor/coffeescript/coffeescript/tests/cases/function_invocation.coffee +552 -0
  66. data/vendor/coffeescript/coffeescript/tests/cases/functions.coffee +188 -0
  67. data/vendor/coffeescript/coffeescript/tests/cases/helpers.coffee +96 -0
  68. data/vendor/coffeescript/coffeescript/tests/cases/importing.coffee +18 -0
  69. data/vendor/coffeescript/coffeescript/tests/cases/interpolation.coffee +138 -0
  70. data/vendor/coffeescript/coffeescript/tests/cases/javascript_literals.coffee +10 -0
  71. data/vendor/coffeescript/coffeescript/tests/cases/numbers.coffee +76 -0
  72. data/vendor/coffeescript/coffeescript/tests/cases/objects.coffee +271 -0
  73. data/vendor/coffeescript/coffeescript/tests/cases/operators.coffee +277 -0
  74. data/vendor/coffeescript/coffeescript/tests/cases/option_parser.coffee +43 -0
  75. data/vendor/coffeescript/coffeescript/tests/cases/ranges.coffee +88 -0
  76. data/vendor/coffeescript/coffeescript/tests/cases/regexps.coffee +63 -0
  77. data/vendor/coffeescript/coffeescript/tests/cases/scope.coffee +43 -0
  78. data/vendor/coffeescript/coffeescript/tests/cases/slicing_and_splicing.coffee +143 -0
  79. data/vendor/coffeescript/coffeescript/tests/cases/soaks.coffee +134 -0
  80. data/vendor/coffeescript/coffeescript/tests/cases/strict.coffee +155 -0
  81. data/vendor/coffeescript/coffeescript/tests/cases/strings.coffee +107 -0
  82. data/vendor/coffeescript/coffeescript/tests/css/style.css +43 -0
  83. data/vendor/coffeescript/coffeescript/tests/index.php +119 -0
  84. data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.1.1.js +8 -0
  85. data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.2.0.js +8 -0
  86. data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.0.js +8 -0
  87. data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.1.js +8 -0
  88. data/vendor/coffeescript/coffeescript/tests/js/lib/diff.js +276 -0
  89. data/vendor/coffeescript/coffeescript/tests/js/main.js +123 -0
  90. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/LICENSE.txt +10 -0
  91. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/Lempar.php +948 -0
  92. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Action.php +257 -0
  93. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/ActionTable.php +299 -0
  94. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Config.php +574 -0
  95. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Data.php +1857 -0
  96. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Parser.php +851 -0
  97. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/PropagationLink.php +126 -0
  98. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Rule.php +144 -0
  99. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/State.php +283 -0
  100. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Symbol.php +288 -0
  101. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/cli.php +5 -0
  102. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/ParserGenerator.php +811 -0
  103. data/vendor/composer/ClassLoader.php +383 -0
  104. data/vendor/composer/autoload_classmap.php +9 -0
  105. data/vendor/composer/autoload_namespaces.php +12 -0
  106. data/vendor/composer/autoload_psr4.php +10 -0
  107. data/vendor/composer/autoload_real.php +50 -0
  108. data/vendor/composer/installed.json +166 -0
  109. data/vendor/michelf/php-markdown/License.md +36 -0
  110. data/vendor/michelf/php-markdown/Michelf/Markdown.inc.php +10 -0
  111. data/vendor/michelf/php-markdown/Michelf/Markdown.php +3117 -0
  112. data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.inc.php +11 -0
  113. data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php +38 -0
  114. data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.inc.php +9 -0
  115. data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php +37 -0
  116. data/vendor/michelf/php-markdown/Readme.md +305 -0
  117. data/vendor/michelf/php-markdown/Readme.php +31 -0
  118. data/vendor/michelf/php-markdown/composer.json +31 -0
  119. data/vendor/mthaml/mthaml/CHANGELOG +48 -0
  120. data/vendor/mthaml/mthaml/LICENSE +44 -0
  121. data/vendor/mthaml/mthaml/README.markdown +262 -0
  122. data/vendor/mthaml/mthaml/composer.json +45 -0
  123. data/vendor/mthaml/mthaml/docs/Makefile +153 -0
  124. data/vendor/mthaml/mthaml/docs/_static/mthaml.css +30 -0
  125. data/vendor/mthaml/mthaml/docs/_theme/mthaml/theme.conf +4 -0
  126. data/vendor/mthaml/mthaml/docs/conf.py +242 -0
  127. data/vendor/mthaml/mthaml/docs/index.rst +18 -0
  128. data/vendor/mthaml/mthaml/docs/twig-syntax.rst +274 -0
  129. data/vendor/mthaml/mthaml/examples/README.md +5 -0
  130. data/vendor/mthaml/mthaml/examples/autoload.php +8 -0
  131. data/vendor/mthaml/mthaml/examples/example-php.haml +5 -0
  132. data/vendor/mthaml/mthaml/examples/example-php.php +37 -0
  133. data/vendor/mthaml/mthaml/examples/example-twig-noext.twig +11 -0
  134. data/vendor/mthaml/mthaml/examples/example-twig.haml +9 -0
  135. data/vendor/mthaml/mthaml/examples/example-twig.php +60 -0
  136. data/vendor/mthaml/mthaml/examples/example.twig.haml +8 -0
  137. data/vendor/mthaml/mthaml/lib/MtHaml/Autoloader.php +22 -0
  138. data/vendor/mthaml/mthaml/lib/MtHaml/Environment.php +178 -0
  139. data/vendor/mthaml/mthaml/lib/MtHaml/Escaping.php +33 -0
  140. data/vendor/mthaml/mthaml/lib/MtHaml/Exception.php +9 -0
  141. data/vendor/mthaml/mthaml/lib/MtHaml/Exception/SyntaxErrorException.php +9 -0
  142. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/AbstractFilter.php +43 -0
  143. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Cdata.php +16 -0
  144. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/CoffeeScript.php +33 -0
  145. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Css.php +26 -0
  146. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Escaped.php +22 -0
  147. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/FilterInterface.php +15 -0
  148. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Javascript.php +26 -0
  149. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less.php +27 -0
  150. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/LeafoLess.php +20 -0
  151. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/OyejorgeLess.php +23 -0
  152. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown.php +58 -0
  153. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/CebeMarkdown.php +22 -0
  154. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Ciconia.php +21 -0
  155. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/MichelfMarkdown.php +21 -0
  156. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Parsedown.php +21 -0
  157. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php +37 -0
  158. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Plain.php +24 -0
  159. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Preserve.php +19 -0
  160. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Scss.php +37 -0
  161. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Twig.php +47 -0
  162. data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Indentation.php +96 -0
  163. data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationException.php +9 -0
  164. data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationInterface.php +50 -0
  165. data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Undefined.php +41 -0
  166. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Comment.php +71 -0
  167. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Doctype.php +96 -0
  168. data/vendor/mthaml/mthaml/lib/MtHaml/Node/EscapableAbstract.php +19 -0
  169. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Filter.php +51 -0
  170. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Insert.php +42 -0
  171. data/vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php +73 -0
  172. data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestAbstract.php +117 -0
  173. data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestInterface.php +10 -0
  174. data/vendor/mthaml/mthaml/lib/MtHaml/Node/NodeAbstract.php +77 -0
  175. data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefClass.php +42 -0
  176. data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefId.php +42 -0
  177. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Root.php +35 -0
  178. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Run.php +71 -0
  179. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Statement.php +45 -0
  180. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Tag.php +90 -0
  181. data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttribute.php +62 -0
  182. data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeInterpolation.php +24 -0
  183. data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeList.php +24 -0
  184. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Text.php +37 -0
  185. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Autoclose.php +25 -0
  186. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Escaping.php +105 -0
  187. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/MergeAttrs.php +110 -0
  188. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Midblock.php +37 -0
  189. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorAbstract.php +226 -0
  190. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorInterface.php +97 -0
  191. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/PhpRenderer.php +288 -0
  192. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Printer.php +265 -0
  193. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/RendererAbstract.php +581 -0
  194. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/TwigRenderer.php +252 -0
  195. data/vendor/mthaml/mthaml/lib/MtHaml/Parser.php +862 -0
  196. data/vendor/mthaml/mthaml/lib/MtHaml/Parser/Buffer.php +147 -0
  197. data/vendor/mthaml/mthaml/lib/MtHaml/Runtime.php +218 -0
  198. data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeInterpolation.php +16 -0
  199. data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeList.php +16 -0
  200. data/vendor/mthaml/mthaml/lib/MtHaml/Support/Php/Executor.php +157 -0
  201. data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Extension.php +47 -0
  202. data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Lexer.php +48 -0
  203. data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Loader.php +81 -0
  204. data/vendor/mthaml/mthaml/lib/MtHaml/Target/Php.php +23 -0
  205. data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetAbstract.php +87 -0
  206. data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetInterface.php +12 -0
  207. data/vendor/mthaml/mthaml/lib/MtHaml/Target/Twig.php +23 -0
  208. data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilder.php +100 -0
  209. data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilderException.php +9 -0
  210. data/vendor/mthaml/mthaml/phpunit.xml +25 -0
  211. data/vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php +59 -0
  212. data/vendor/mthaml/mthaml/test/MtHaml/Tests/HamlSpecTest.php +83 -0
  213. data/vendor/mthaml/mthaml/test/MtHaml/Tests/IndentationTest.php +140 -0
  214. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/DoctypeTest.php +51 -0
  215. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/NodeTest.php +110 -0
  216. data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/PhpRendererTest.php +113 -0
  217. data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/TwigRendererTest.php +68 -0
  218. data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitorsTest.php +44 -0
  219. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Parser/BufferTest.php +77 -0
  220. data/vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php +47 -0
  221. data/vendor/mthaml/mthaml/test/MtHaml/Tests/RuntimeTest.php +356 -0
  222. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Php/ExecutorTest.php +83 -0
  223. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Twig/LoaderTest.php +65 -0
  224. data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCase.php +49 -0
  225. data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCaseTest.php +50 -0
  226. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/Support/Php/Executor.001.haml +1 -0
  227. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_php.test +20 -0
  228. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_twig.test +12 -0
  229. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_php.test +16 -0
  230. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_twig.test +16 -0
  231. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_php.test +15 -0
  232. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_twig.test +15 -0
  233. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug42.test +13 -0
  234. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug8_twig.test +10 -0
  235. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/coffeescript_filter.test +31 -0
  236. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/comments.test +26 -0
  237. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/cond_cmt.test +25 -0
  238. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype.test +18 -0
  239. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_html4.test +20 -0
  240. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid.test +12 -0
  241. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid_xhtml.test +12 -0
  242. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_php.test +18 -0
  243. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_xhtml.test +30 -0
  244. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/filters.test +51 -0
  245. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_php.test +11 -0
  246. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_twig.test +11 -0
  247. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_php.test +31 -0
  248. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_twig.test +31 -0
  249. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_leafo.test +33 -0
  250. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_oyejorge.test +49 -0
  251. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_cebemarkdown.test +35 -0
  252. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_ciconia.test +36 -0
  253. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_michelf.test +34 -0
  254. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_parsedown.test +31 -0
  255. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_optimization_filter_michelf.test +23 -0
  256. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/mergeattrs.test +18 -0
  257. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_inner_whitespace.test +77 -0
  258. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_outer_whitespace.test +122 -0
  259. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_php.test +14 -0
  260. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_twig.test +14 -0
  261. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php.test +109 -0
  262. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping.test +22 -0
  263. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping_once.test +25 -0
  264. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_blocks.test +29 -0
  265. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_filters.test +42 -0
  266. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/scss_filter.test +32 -0
  267. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/strip_inline_comments_php.test +22 -0
  268. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/test.test +24 -0
  269. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/trailing_semicolon_php.test +14 -0
  270. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/try_catch_php.test +17 -0
  271. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig.test +112 -0
  272. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_blocks.test +29 -0
  273. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_filters.test +37 -0
  274. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_whitespace.test +32 -0
  275. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/whitespace.test +63 -0
  276. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/autoclose.test +30 -0
  277. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping.test +52 -0
  278. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_attr_once.test +52 -0
  279. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_html_false.test +52 -0
  280. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/mergeattrs.test +26 -0
  281. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock.test +54 -0
  282. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock_002.test +32 -0
  283. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attr_list.test +14 -0
  284. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs.test +42 -0
  285. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_002.test +35 -0
  286. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_003.test +30 -0
  287. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_html_linebreak.test +17 -0
  288. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks.test +27 -0
  289. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks_002.test +15 -0
  290. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/boolean_attr.test +19 -0
  291. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug28.test +15 -0
  292. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug8.test +11 -0
  293. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/cond_cmt.test +23 -0
  294. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/doctype.test +11 -0
  295. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/double_equal.test +7 -0
  296. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/empty_line_after_multiline.test +10 -0
  297. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_001.test +8 -0
  298. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_002.test +8 -0
  299. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_003.test +8 -0
  300. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_004.test +6 -0
  301. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_005.test +5 -0
  302. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_006.test +7 -0
  303. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_007.test +7 -0
  304. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_008.test +7 -0
  305. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_009.test +5 -0
  306. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_010.test +5 -0
  307. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_013.test +5 -0
  308. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_016.test +7 -0
  309. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_017.test +8 -0
  310. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_018.test +6 -0
  311. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_019.test +6 -0
  312. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_020.test +5 -0
  313. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters.test +20 -0
  314. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_002.test +19 -0
  315. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_003.test +13 -0
  316. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_004.test +21 -0
  317. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_005.test +22 -0
  318. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_006.test +23 -0
  319. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/insertflags.test +17 -0
  320. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation.test +36 -0
  321. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation_in_html_attrs.test +17 -0
  322. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline.test +18 -0
  323. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline_code.test +59 -0
  324. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiple_attr_kinds.test +47 -0
  325. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/non_rendered_comment.test +31 -0
  326. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ns.test +11 -0
  327. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref.test +22 -0
  328. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error1.test +5 -0
  329. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error2.test +5 -0
  330. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/quotes_in_haml.test +10 -0
  331. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby19_attrs.test +11 -0
  332. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma.test +23 -0
  333. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_001.test +5 -0
  334. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_002.test +5 -0
  335. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_003.test +5 -0
  336. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/standard.test +114 -0
  337. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/tagflags.test +39 -0
  338. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/php_filters.test +28 -0
  339. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/twig_filters.test +31 -0
  340. data/vendor/mthaml/mthaml/test/bootstrap.php +3 -0
  341. metadata +398 -0
@@ -0,0 +1,851 @@
1
+ <?php
2
+ /**
3
+ * PHP_ParserGenerator, a php 5 parser generator.
4
+ *
5
+ * This is a direct port of the Lemon parser generator, found at
6
+ * {@link http://www.hwaci.com/sw/lemon/}
7
+ *
8
+ * PHP version 5
9
+ *
10
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
11
+ * that is available through the world-wide-web at the following URI:
12
+ * http://www.php.net/license/3_01.txt. If you did not receive a copy of
13
+ * the PHP License and are unable to obtain it through the web, please
14
+ * send a note to license@php.net so we can mail you a copy immediately.
15
+ *
16
+ * @category PHP
17
+ * @package PHP_ParserGenerator
18
+ * @author Gregory Beaver <cellog@php.net>
19
+ * @copyright 2006 Gregory Beaver
20
+ * @license http://www.php.net/license/3_01.txt PHP License 3.01
21
+ * @version CVS: $Id: Parser.php 302382 2010-08-17 06:08:09Z jespino $
22
+ * @link http://pear.php.net/package/PHP_ParserGenerator
23
+ * @since File available since Release 0.1.0
24
+ */
25
+ /**
26
+ * The grammar parser for lemon grammar files.
27
+ *
28
+ * @category PHP
29
+ * @package PHP_ParserGenerator
30
+ * @author Gregory Beaver <cellog@php.net>
31
+ * @copyright 2006 Gregory Beaver
32
+ * @license http://www.php.net/license/3_01.txt PHP License 3.01
33
+ * @link http://pear.php.net/package/PHP_ParserGenerator
34
+ * @since Class available since Release 0.1.0
35
+ */
36
+ class PHP_ParserGenerator_Parser
37
+ {
38
+ const INITIALIZE = 1;
39
+ const WAITING_FOR_DECL_OR_RULE = 2;
40
+ const WAITING_FOR_DECL_KEYWORD = 3;
41
+ const WAITING_FOR_DECL_ARG = 4;
42
+ const WAITING_FOR_PRECEDENCE_SYMBOL = 5;
43
+ const WAITING_FOR_ARROW = 6;
44
+ const IN_RHS = 7;
45
+ const LHS_ALIAS_1 = 8;
46
+ const LHS_ALIAS_2 = 9;
47
+ const LHS_ALIAS_3 = 10;
48
+ const RHS_ALIAS_1 = 11;
49
+ const RHS_ALIAS_2 = 12;
50
+ const PRECEDENCE_MARK_1 = 13;
51
+ const PRECEDENCE_MARK_2 = 14;
52
+ const RESYNC_AFTER_RULE_ERROR = 15;
53
+ const RESYNC_AFTER_DECL_ERROR = 16;
54
+ const WAITING_FOR_DESTRUCTOR_SYMBOL = 17;
55
+ const WAITING_FOR_DATATYPE_SYMBOL = 18;
56
+ const WAITING_FOR_FALLBACK_ID = 19;
57
+
58
+ /**
59
+ * Name of the input file
60
+ *
61
+ * @var string
62
+ */
63
+ public $filename;
64
+ /**
65
+ * Linenumber at which current token starts
66
+ * @var int
67
+ */
68
+ public $tokenlineno;
69
+ /**
70
+ * Number of parsing errors so far
71
+ * @var int
72
+ */
73
+ public $errorcnt;
74
+ /**
75
+ * Index of current token within the input string
76
+ * @var int
77
+ */
78
+ public $tokenstart;
79
+ /**
80
+ * Global state vector
81
+ * @var PHP_ParserGenerator_Data
82
+ */
83
+ public $gp;
84
+ /**
85
+ * Parser state (one of the class constants for this class)
86
+ *
87
+ * - PHP_ParserGenerator_Parser::INITIALIZE,
88
+ * - PHP_ParserGenerator_Parser::WAITING_FOR_DECL_OR_RULE,
89
+ * - PHP_ParserGenerator_Parser::WAITING_FOR_DECL_KEYWORD,
90
+ * - PHP_ParserGenerator_Parser::WAITING_FOR_DECL_ARG,
91
+ * - PHP_ParserGenerator_Parser::WAITING_FOR_PRECEDENCE_SYMBOL,
92
+ * - PHP_ParserGenerator_Parser::WAITING_FOR_ARROW,
93
+ * - PHP_ParserGenerator_Parser::IN_RHS,
94
+ * - PHP_ParserGenerator_Parser::LHS_ALIAS_1,
95
+ * - PHP_ParserGenerator_Parser::LHS_ALIAS_2,
96
+ * - PHP_ParserGenerator_Parser::LHS_ALIAS_3,
97
+ * - PHP_ParserGenerator_Parser::RHS_ALIAS_1,
98
+ * - PHP_ParserGenerator_Parser::RHS_ALIAS_2,
99
+ * - PHP_ParserGenerator_Parser::PRECEDENCE_MARK_1,
100
+ * - PHP_ParserGenerator_Parser::PRECEDENCE_MARK_2,
101
+ * - PHP_ParserGenerator_Parser::RESYNC_AFTER_RULE_ERROR,
102
+ * - PHP_ParserGenerator_Parser::RESYNC_AFTER_DECL_ERROR,
103
+ * - PHP_ParserGenerator_Parser::WAITING_FOR_DESTRUCTOR_SYMBOL,
104
+ * - PHP_ParserGenerator_Parser::WAITING_FOR_DATATYPE_SYMBOL,
105
+ * - PHP_ParserGenerator_Parser::WAITING_FOR_FALLBACK_ID
106
+ * @var int
107
+ */
108
+ public $state;
109
+ /**
110
+ * The fallback token
111
+ * @var PHP_ParserGenerator_Symbol
112
+ */
113
+ public $fallback;
114
+ /**
115
+ * Left-hand side of the current rule
116
+ * @var PHP_ParserGenerator_Symbol
117
+ */
118
+ public $lhs;
119
+ /**
120
+ * Alias for the LHS
121
+ * @var string
122
+ */
123
+ public $lhsalias;
124
+ /**
125
+ * Number of right-hand side symbols seen
126
+ * @var int
127
+ */
128
+ public $nrhs;
129
+ /**
130
+ * Right-hand side symbols
131
+ * @var array array of {@link PHP_ParserGenerator_Symbol} objects
132
+ */
133
+ public $rhs = array();
134
+ /**
135
+ * Aliases for each RHS symbol name (or NULL)
136
+ * @var array array of strings
137
+ */
138
+ public $alias = array();
139
+ /**
140
+ * Previous rule parsed
141
+ * @var PHP_ParserGenerator_Rule
142
+ */
143
+ public $prevrule;
144
+ /**
145
+ * Keyword of a declaration
146
+ *
147
+ * This is one of the %keyword keywords in the grammar file
148
+ * @var string
149
+ */
150
+ public $declkeyword;
151
+ /**
152
+ * Where the declaration argument should be put
153
+ *
154
+ * This is assigned as a reference to an internal variable
155
+ * @var mixed
156
+ */
157
+ public $declargslot = array();
158
+ /**
159
+ * Where the declaration linenumber is put
160
+ *
161
+ * This is assigned as a reference to an internal variable
162
+ * @var mixed
163
+ */
164
+ public $decllnslot;
165
+ /*enum e_assoc*/
166
+ public $declassoc; /* Assign this association to decl arguments */
167
+ public $preccounter; /* Assign this precedence to decl arguments */
168
+ /**
169
+ * @var PHP_ParserGenerator_Rule
170
+ */
171
+ public $firstrule; /* Pointer to first rule in the grammar */
172
+ /**
173
+ * @var PHP_ParserGenerator_Rule
174
+ */
175
+ public $lastrule; /* Pointer to the most recently parsed rule */
176
+
177
+ /**
178
+ * @var PHP_ParserGenerator
179
+ */
180
+ private $lemon;
181
+
182
+ function __construct(PHP_ParserGenerator $lem)
183
+ {
184
+ $this->lemon = $lem;
185
+ }
186
+
187
+ /**
188
+ * Run the preprocessor over the input file text. The Lemon variable
189
+ * $azDefine contains the names of all defined
190
+ * macros. This routine looks for "%ifdef" and "%ifndef" and "%endif" and
191
+ * comments them out. Text in between is also commented out as appropriate.
192
+ * @param string
193
+ */
194
+ private function preprocess_input(&$z)
195
+ {
196
+ $lineno = $exclude = 0;
197
+ for ($i=0; $i < strlen($z); $i++) {
198
+ if ($z[$i] == "\n") {
199
+ $lineno++;
200
+ }
201
+ if ($z[$i] != '%' || ($i > 0 && $z[$i-1] != "\n")) {
202
+ continue;
203
+ }
204
+ if (substr($z, $i, 6) === "%endif" && trim($z[$i+6]) === '') {
205
+ if ($exclude) {
206
+ $exclude--;
207
+ if ($exclude === 0) {
208
+ for ($j = $start; $j < $i; $j++) {
209
+ if ($z[$j] != "\n") $z[$j] = ' ';
210
+ }
211
+ }
212
+ }
213
+ for ($j = $i; $j < strlen($z) && $z[$j] != "\n"; $j++) {
214
+ $z[$j] = ' ';
215
+ }
216
+ } elseif (substr($z, $i, 6) === "%ifdef" && trim($z[$i+6]) === '' ||
217
+ substr($z, $i, 7) === "%ifndef" && trim($z[$i+7]) === '') {
218
+ if ($exclude) {
219
+ $exclude++;
220
+ } else {
221
+ $j = $i;
222
+ $n = strtok(substr($z, $j), " \t");
223
+ $exclude = 1;
224
+ if (isset($this->lemon->azDefine[$n])) {
225
+ $exclude = 0;
226
+ }
227
+ if ($z[$i + 3]=='n') {
228
+ // this is a rather obtuse way of checking whether this is %ifndef
229
+ $exclude = !$exclude;
230
+ }
231
+ if ($exclude) {
232
+ $start = $i;
233
+ $start_lineno = $lineno;
234
+ }
235
+ }
236
+ //for ($j = $i; $j < strlen($z) && $z[$j] != "\n"; $j++) $z[$j] = ' ';
237
+ $j = strpos(substr($z, $i), "\n");
238
+ if ($j === false) {
239
+ $z = substr($z, 0, $i); // remove instead of adding ' '
240
+ } else {
241
+ $z = substr($z, 0, $i) . substr($z, $i + $j); // remove instead of adding ' '
242
+ }
243
+ }
244
+ }
245
+ if ($exclude) {
246
+ throw new Exception("unterminated %ifdef starting on line $start_lineno\n");
247
+ }
248
+ }
249
+
250
+ /**
251
+ * In spite of its name, this function is really a scanner.
252
+ *
253
+ * It reads in the entire input file (all at once) then tokenizes it.
254
+ * Each token is passed to the function "parseonetoken" which builds all
255
+ * the appropriate data structures in the global state vector "gp".
256
+ * @param PHP_ParserGenerator_Data
257
+ */
258
+ function Parse(PHP_ParserGenerator_Data $gp)
259
+ {
260
+ $startline = 0;
261
+
262
+ $this->gp = $gp;
263
+ $this->filename = $gp->filename;
264
+ $this->errorcnt = 0;
265
+ $this->state = self::INITIALIZE;
266
+
267
+ /* Begin by reading the input file */
268
+ $filebuf = file_get_contents($this->filename);
269
+ if (!$filebuf) {
270
+ PHP_ParserGenerator::ErrorMsg($this->filename, 0, "Can't open this file for reading.");
271
+ $gp->errorcnt++;
272
+ return;
273
+ }
274
+ if (filesize($this->filename) != strlen($filebuf)) {
275
+ ErrorMsg($this->filename, 0, "Can't read in all %d bytes of this file.",
276
+ filesize($this->filename));
277
+ $gp->errorcnt++;
278
+ return;
279
+ }
280
+
281
+ /* Make an initial pass through the file to handle %ifdef and %ifndef */
282
+ $this->preprocess_input($filebuf);
283
+
284
+ /* Now scan the text of the input file */
285
+ $lineno = 1;
286
+ for ($cp = 0, $c = $filebuf[0]; $cp < strlen($filebuf); $cp++) {
287
+ $c = $filebuf[$cp];
288
+ if ($c == "\n") $lineno++; /* Keep track of the line number */
289
+ if (trim($c) === '') {
290
+ continue;
291
+ } /* Skip all white space */
292
+ if ($filebuf[$cp] == '/' && ($cp + 1 < strlen($filebuf)) && $filebuf[$cp + 1] == '/') {
293
+ /* Skip C++ style comments */
294
+ $cp += 2;
295
+ $z = strpos(substr($filebuf, $cp), "\n");
296
+ if ($z === false) {
297
+ $cp = strlen($filebuf);
298
+ break;
299
+ }
300
+ $lineno++;
301
+ $cp += $z;
302
+ continue;
303
+ }
304
+ if ($filebuf[$cp] == '/' && ($cp + 1 < strlen($filebuf)) && $filebuf[$cp + 1] == '*') {
305
+ /* Skip C style comments */
306
+ $cp += 2;
307
+ $z = strpos(substr($filebuf, $cp), '*/');
308
+ if ($z !== false) {
309
+ $lineno += count(explode("\n", substr($filebuf, $cp, $z))) - 1;
310
+ }
311
+ $cp += $z + 1;
312
+ continue;
313
+ }
314
+ $this->tokenstart = $cp; /* Mark the beginning of the token */
315
+ $this->tokenlineno = $lineno; /* Linenumber on which token begins */
316
+ if ($filebuf[$cp] == '"') { /* String literals */
317
+ $cp++;
318
+ $oldcp = $cp;
319
+ $test = strpos(substr($filebuf, $cp), '"');
320
+ if ($test === false) {
321
+ PHP_ParserGenerator::ErrorMsg($this->filename, $startline,
322
+ "String starting on this line is not terminated before the end of the file.");
323
+ $this->errorcnt++;
324
+ $nextcp = $cp = strlen($filebuf);
325
+ } else {
326
+ $cp += $test;
327
+ $nextcp = $cp + 1;
328
+ }
329
+ $lineno += count(explode("\n", substr($filebuf, $oldcp, $cp - $oldcp))) - 1;
330
+ } elseif ($filebuf[$cp] == '{') { /* A block of C code */
331
+ $cp++;
332
+ if ($filebuf[$cp]=="}") {
333
+ $filebuf = substr($filebuf, 0, $cp)." ".substr($filebuf, $cp);
334
+ }
335
+
336
+ for ($level = 1; $cp < strlen($filebuf) && ($level > 1 || $filebuf[$cp] != '}'); $cp++) {
337
+ if ($filebuf[$cp] == "\n") {
338
+ $lineno++;
339
+ } elseif ($filebuf[$cp] == '{') {
340
+ $level++;
341
+ } elseif ($filebuf[$cp] == '}') {
342
+ $level--;
343
+ } elseif ($filebuf[$cp] == '/' && $filebuf[$cp + 1] == '*') {
344
+ /* Skip comments */
345
+ $cp += 2;
346
+ $z = strpos(substr($filebuf, $cp), '*/');
347
+ if ($z !== false) {
348
+ $lineno += count(explode("\n", substr($filebuf, $cp, $z))) - 1;
349
+ }
350
+ $cp += $z + 2;
351
+ } elseif ($filebuf[$cp] == '/' && $filebuf[$cp + 1] == '/') {
352
+ /* Skip C++ style comments too */
353
+ $cp += 2;
354
+ $z = strpos(substr($filebuf, $cp), "\n");
355
+ if ($z === false) {
356
+ $cp = strlen($filebuf);
357
+ break;
358
+ } else {
359
+ $lineno++;
360
+ }
361
+ $cp += $z;
362
+ } elseif ($filebuf[$cp] == "'" || $filebuf[$cp] == '"') {
363
+ /* String a character literals */
364
+ $startchar = $filebuf[$cp];
365
+ $prevc = 0;
366
+ for ($cp++; $cp < strlen($filebuf) && ($filebuf[$cp] != $startchar || $prevc === '\\'); $cp++) {
367
+ if ($filebuf[$cp] == "\n") {
368
+ $lineno++;
369
+ }
370
+ if ($prevc === '\\') {
371
+ $prevc = 0;
372
+ } else {
373
+ $prevc = $filebuf[$cp];
374
+ }
375
+ }
376
+ }
377
+ }
378
+ if ($cp >= strlen($filebuf)) {
379
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
380
+ "PHP code starting on this line is not terminated before the end of the file.");
381
+ $this->errorcnt++;
382
+ $nextcp = $cp;
383
+ } else {
384
+ $nextcp = $cp + 1;
385
+ }
386
+ } elseif (preg_match('/[a-zA-Z0-9]/', $filebuf[$cp])) {
387
+ /* Identifiers */
388
+ preg_match('/[a-zA-Z0-9_]+/', substr($filebuf, $cp), $preg_results);
389
+ $cp += strlen($preg_results[0]);
390
+ $nextcp = $cp;
391
+ } elseif ($filebuf[$cp] == ':' && $filebuf[$cp + 1] == ':' &&
392
+ $filebuf[$cp + 2] == '=') {
393
+ /* The operator "::=" */
394
+ $cp += 3;
395
+ $nextcp = $cp;
396
+ } elseif (($filebuf[$cp] == '/' || $filebuf[$cp] == '|') &&
397
+ preg_match('/[a-zA-Z]/', $filebuf[$cp + 1])) {
398
+ $cp += 2;
399
+ preg_match('/[a-zA-Z0-9_]+/', substr($filebuf, $cp), $preg_results);
400
+ $cp += strlen($preg_results[0]);
401
+ $nextcp = $cp;
402
+ } else {
403
+ /* All other (one character) operators */
404
+ $cp ++;
405
+ $nextcp = $cp;
406
+ }
407
+ $this->parseonetoken(substr($filebuf, $this->tokenstart,
408
+ $cp - $this->tokenstart)); /* Parse the token */
409
+ $cp = $nextcp - 1;
410
+ }
411
+ $gp->rule = $this->firstrule;
412
+ $gp->errorcnt = $this->errorcnt;
413
+ }
414
+
415
+ /**
416
+ * Parse a single token
417
+ * @param string token
418
+ */
419
+ function parseonetoken($token)
420
+ {
421
+ $x = $token;
422
+ $this->a = 0; // for referencing in WAITING_FOR_DECL_KEYWORD
423
+ if (PHP_ParserGenerator::DEBUG) {
424
+ printf("%s:%d: Token=[%s] state=%d\n",
425
+ $this->filename, $this->tokenlineno, $token, $this->state);
426
+ }
427
+ switch ($this->state) {
428
+ case self::INITIALIZE:
429
+ $this->prevrule = 0;
430
+ $this->preccounter = 0;
431
+ $this->firstrule = $this->lastrule = 0;
432
+ $this->gp->nrule = 0;
433
+ /* Fall thru to next case */
434
+ case self::WAITING_FOR_DECL_OR_RULE:
435
+ if ($x[0] == '%') {
436
+ $this->state = self::WAITING_FOR_DECL_KEYWORD;
437
+ } elseif (preg_match('/[a-z]/', $x[0])) {
438
+ $this->lhs = PHP_ParserGenerator_Symbol::Symbol_new($x);
439
+ $this->nrhs = 0;
440
+ $this->lhsalias = 0;
441
+ $this->state = self::WAITING_FOR_ARROW;
442
+ } elseif ($x[0] == '{') {
443
+ if ($this->prevrule === 0) {
444
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
445
+ "There is no prior rule opon which to attach the code
446
+ fragment which begins on this line.");
447
+ $this->errorcnt++;
448
+ } elseif ($this->prevrule->code != 0) {
449
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
450
+ "Code fragment beginning on this line is not the first \
451
+ to follow the previous rule.");
452
+ $this->errorcnt++;
453
+ } else {
454
+ $this->prevrule->line = $this->tokenlineno;
455
+ $this->prevrule->code = substr($x, 1);
456
+ }
457
+ } elseif ($x[0] == '[') {
458
+ $this->state = self::PRECEDENCE_MARK_1;
459
+ } else {
460
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
461
+ "Token \"%s\" should be either \"%%\" or a nonterminal name.",
462
+ $x);
463
+ $this->errorcnt++;
464
+ }
465
+ break;
466
+ case self::PRECEDENCE_MARK_1:
467
+ if (!preg_match('/[A-Z]/', $x[0])) {
468
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
469
+ "The precedence symbol must be a terminal.");
470
+ $this->errorcnt++;
471
+ } elseif ($this->prevrule === 0) {
472
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
473
+ "There is no prior rule to assign precedence \"[%s]\".", $x);
474
+ $this->errorcnt++;
475
+ } elseif ($this->prevrule->precsym != 0) {
476
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
477
+ "Precedence mark on this line is not the first to follow the previous rule.");
478
+ $this->errorcnt++;
479
+ } else {
480
+ $this->prevrule->precsym = PHP_ParserGenerator_Symbol::Symbol_new($x);
481
+ }
482
+ $this->state = self::PRECEDENCE_MARK_2;
483
+ break;
484
+ case self::PRECEDENCE_MARK_2:
485
+ if ($x[0] != ']') {
486
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
487
+ "Missing \"]\" on precedence mark.");
488
+ $this->errorcnt++;
489
+ }
490
+ $this->state = self::WAITING_FOR_DECL_OR_RULE;
491
+ break;
492
+ case self::WAITING_FOR_ARROW:
493
+ if ($x[0] == ':' && $x[1] == ':' && $x[2] == '=') {
494
+ $this->state = self::IN_RHS;
495
+ } elseif ($x[0] == '(') {
496
+ $this->state = self::LHS_ALIAS_1;
497
+ } else {
498
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
499
+ "Expected to see a \":\" following the LHS symbol \"%s\".",
500
+ $this->lhs->name);
501
+ $this->errorcnt++;
502
+ $this->state = self::RESYNC_AFTER_RULE_ERROR;
503
+ }
504
+ break;
505
+ case self::LHS_ALIAS_1:
506
+ if (preg_match('/[A-Za-z]/', $x[0])) {
507
+ $this->lhsalias = $x;
508
+ $this->state = self::LHS_ALIAS_2;
509
+ } else {
510
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
511
+ "\"%s\" is not a valid alias for the LHS \"%s\"\n",
512
+ $x, $this->lhs->name);
513
+ $this->errorcnt++;
514
+ $this->state = self::RESYNC_AFTER_RULE_ERROR;
515
+ }
516
+ break;
517
+ case self::LHS_ALIAS_2:
518
+ if ($x[0] == ')') {
519
+ $this->state = self::LHS_ALIAS_3;
520
+ } else {
521
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
522
+ "Missing \")\" following LHS alias name \"%s\".",$this->lhsalias);
523
+ $this->errorcnt++;
524
+ $this->state = self::RESYNC_AFTER_RULE_ERROR;
525
+ }
526
+ break;
527
+ case self::LHS_ALIAS_3:
528
+ if ($x == '::=') {
529
+ $this->state = self::IN_RHS;
530
+ } else {
531
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
532
+ "Missing \"->\" following: \"%s(%s)\".",
533
+ $this->lhs->name, $this->lhsalias);
534
+ $this->errorcnt++;
535
+ $this->state = self::RESYNC_AFTER_RULE_ERROR;
536
+ }
537
+ break;
538
+ case self::IN_RHS:
539
+ if ($x[0] == '.') {
540
+ $rp = new PHP_ParserGenerator_Rule;
541
+ $rp->ruleline = $this->tokenlineno;
542
+ for ($i = 0; $i < $this->nrhs; $i++) {
543
+ $rp->rhs[$i] = $this->rhs[$i];
544
+ $rp->rhsalias[$i] = $this->alias[$i];
545
+ }
546
+ if (count(array_unique($rp->rhsalias)) != count($rp->rhsalias)) {
547
+ $used = array();
548
+ foreach ($rp->rhsalias as $i => $symbol) {
549
+ if (!is_string($symbol)) {
550
+ continue;
551
+ }
552
+ if (isset($used[$symbol])) {
553
+ PHP_ParserGenerator::ErrorMsg($this->filename,
554
+ $this->tokenlineno,
555
+ "RHS symbol \"%s\" used multiple times.",
556
+ $symbol);
557
+ $this->errorcnt++;
558
+ } else {
559
+ $used[$symbol] = $i;
560
+ }
561
+ }
562
+ }
563
+ $rp->lhs = $this->lhs;
564
+ $rp->lhsalias = $this->lhsalias;
565
+ $rp->nrhs = $this->nrhs;
566
+ $rp->code = 0;
567
+ $rp->precsym = 0;
568
+ $rp->index = $this->gp->nrule++;
569
+ $rp->nextlhs = $rp->lhs->rule;
570
+ $rp->lhs->rule = $rp;
571
+ $rp->next = 0;
572
+ if ($this->firstrule === 0) {
573
+ $this->firstrule = $this->lastrule = $rp;
574
+ } else {
575
+ $this->lastrule->next = $rp;
576
+ $this->lastrule = $rp;
577
+ }
578
+ $this->prevrule = $rp;
579
+ $this->state = self::WAITING_FOR_DECL_OR_RULE;
580
+ } elseif (preg_match('/[a-zA-Z]/', $x[0])) {
581
+ if ($this->nrhs >= PHP_ParserGenerator::MAXRHS) {
582
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
583
+ "Too many symbols on RHS or rule beginning at \"%s\".",
584
+ $x);
585
+ $this->errorcnt++;
586
+ $this->state = self::RESYNC_AFTER_RULE_ERROR;
587
+ } else {
588
+ if (isset($this->rhs[$this->nrhs - 1])) {
589
+ $msp = $this->rhs[$this->nrhs - 1];
590
+ if ($msp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
591
+ $inf = array_reduce($msp->subsym,
592
+ array($this, '_printmulti'), '');
593
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
594
+ 'WARNING: symbol ' . $x . ' will not' .
595
+ ' be part of previous multiterminal %s',
596
+ substr($inf, 0, strlen($inf) - 1)
597
+ );
598
+ }
599
+ }
600
+ $this->rhs[$this->nrhs] = PHP_ParserGenerator_Symbol::Symbol_new($x);
601
+ $this->alias[$this->nrhs] = 0;
602
+ $this->nrhs++;
603
+ }
604
+ } elseif (($x[0] == '|' || $x[0] == '/') && $this->nrhs > 0) {
605
+ $msp = $this->rhs[$this->nrhs - 1];
606
+ if ($msp->type != PHP_ParserGenerator_Symbol::MULTITERMINAL) {
607
+ $origsp = $msp;
608
+ $msp = new PHP_ParserGenerator_Symbol;
609
+ $msp->type = PHP_ParserGenerator_Symbol::MULTITERMINAL;
610
+ $msp->nsubsym = 1;
611
+ $msp->subsym = array($origsp);
612
+ $msp->name = $origsp->name;
613
+ $this->rhs[$this->nrhs - 1] = $msp;
614
+ }
615
+ $msp->nsubsym++;
616
+ $msp->subsym[$msp->nsubsym - 1] = PHP_ParserGenerator_Symbol::Symbol_new(substr($x, 1));
617
+ if (preg_match('/[a-z]/', $x[1]) ||
618
+ preg_match('/[a-z]/', $msp->subsym[0]->name[0])) {
619
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
620
+ "Cannot form a compound containing a non-terminal");
621
+ $this->errorcnt++;
622
+ }
623
+ } elseif ($x[0] == '(' && $this->nrhs > 0) {
624
+ $this->state = self::RHS_ALIAS_1;
625
+ } else {
626
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
627
+ "Illegal character on RHS of rule: \"%s\".", $x);
628
+ $this->errorcnt++;
629
+ $this->state = self::RESYNC_AFTER_RULE_ERROR;
630
+ }
631
+ break;
632
+ case self::RHS_ALIAS_1:
633
+ if (preg_match('/[A-Za-z]/', $x[0])) {
634
+ $this->alias[$this->nrhs - 1] = $x;
635
+ $this->state = self::RHS_ALIAS_2;
636
+ } else {
637
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
638
+ "\"%s\" is not a valid alias for the RHS symbol \"%s\"\n",
639
+ $x, $this->rhs[$this->nrhs - 1]->name);
640
+ $this->errorcnt++;
641
+ $this->state = self::RESYNC_AFTER_RULE_ERROR;
642
+ }
643
+ break;
644
+ case self::RHS_ALIAS_2:
645
+ if ($x[0] == ')') {
646
+ $this->state = self::IN_RHS;
647
+ } else {
648
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
649
+ "Missing \")\" following LHS alias name \"%s\".", $this->lhsalias);
650
+ $this->errorcnt++;
651
+ $this->state = self::RESYNC_AFTER_RULE_ERROR;
652
+ }
653
+ break;
654
+ case self::WAITING_FOR_DECL_KEYWORD:
655
+ if(preg_match('/[A-Za-z]/', $x[0])) {
656
+ $this->declkeyword = $x;
657
+ $this->declargslot = &$this->a;
658
+ $this->decllnslot = &$this->a;
659
+ $this->state = self::WAITING_FOR_DECL_ARG;
660
+ if ('name' == $x) {
661
+ $this->declargslot = &$this->gp->name;
662
+ } elseif ('include' == $x) {
663
+ $this->declargslot = &$this->gp->include_code;
664
+ $this->decllnslot = &$this->gp->includeln;
665
+ } elseif ('include_class' == $x) {
666
+ $this->declargslot = &$this->gp->include_classcode;
667
+ $this->decllnslot = &$this->gp->include_classln;
668
+ } elseif ('declare_class' == $x) {
669
+ $this->declargslot = &$this->gp->declare_classcode;
670
+ $this->decllnslot = &$this->gp->declare_classln;
671
+ } elseif ('code' == $x) {
672
+ $this->declargslot = &$this->gp->extracode;
673
+ $this->decllnslot = &$this->gp->extracodeln;
674
+ } elseif ('token_destructor' == $x) {
675
+ $this->declargslot = &$this->gp->tokendest;
676
+ $this->decllnslot = &$this->gp->tokendestln;
677
+ } elseif ('default_destructor' == $x) {
678
+ $this->declargslot = &$this->gp->vardest;
679
+ $this->decllnslot = &$this->gp->vardestln;
680
+ } elseif ('token_prefix' == $x) {
681
+ $this->declargslot = &$this->gp->tokenprefix;
682
+ } elseif ('syntax_error' == $x) {
683
+ $this->declargslot = &$this->gp->error;
684
+ $this->decllnslot = &$this->gp->errorln;
685
+ } elseif ('parse_accept' == $x) {
686
+ $this->declargslot = &$this->gp->accept;
687
+ $this->decllnslot = &$this->gp->acceptln;
688
+ } elseif ('parse_failure' == $x) {
689
+ $this->declargslot = &$this->gp->failure;
690
+ $this->decllnslot = &$this->gp->failureln;
691
+ } elseif ('stack_overflow' == $x) {
692
+ $this->declargslot = &$this->gp->overflow;
693
+ $this->decllnslot = &$this->gp->overflowln;
694
+ } elseif ('token_type' == $x) {
695
+ $this->declargslot = &$this->gp->tokentype;
696
+ } elseif ('default_type' == $x) {
697
+ $this->declargslot = &$this->gp->vartype;
698
+ } elseif ('stack_size' == $x) {
699
+ $this->declargslot = &$this->gp->stacksize;
700
+ } elseif ('start_symbol' == $x) {
701
+ $this->declargslot = &$this->gp->start;
702
+ } elseif ('left' == $x) {
703
+ $this->preccounter++;
704
+ $this->declassoc = PHP_ParserGenerator_Symbol::LEFT;
705
+ $this->state = self::WAITING_FOR_PRECEDENCE_SYMBOL;
706
+ } elseif ('right' == $x) {
707
+ $this->preccounter++;
708
+ $this->declassoc = PHP_ParserGenerator_Symbol::RIGHT;
709
+ $this->state = self::WAITING_FOR_PRECEDENCE_SYMBOL;
710
+ } elseif ('nonassoc' == $x) {
711
+ $this->preccounter++;
712
+ $this->declassoc = PHP_ParserGenerator_Symbol::NONE;
713
+ $this->state = self::WAITING_FOR_PRECEDENCE_SYMBOL;
714
+ } elseif ('destructor' == $x) {
715
+ $this->state = self::WAITING_FOR_DESTRUCTOR_SYMBOL;
716
+ } elseif ('type' == $x) {
717
+ $this->state = self::WAITING_FOR_DATATYPE_SYMBOL;
718
+ } elseif ('fallback' == $x) {
719
+ $this->fallback = 0;
720
+ $this->state = self::WAITING_FOR_FALLBACK_ID;
721
+ } else {
722
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
723
+ "Unknown declaration keyword: \"%%%s\".", $x);
724
+ $this->errorcnt++;
725
+ $this->state = self::RESYNC_AFTER_DECL_ERROR;
726
+ }
727
+ } else {
728
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
729
+ "Illegal declaration keyword: \"%s\".", $x);
730
+ $this->errorcnt++;
731
+ $this->state = self::RESYNC_AFTER_DECL_ERROR;
732
+ }
733
+ break;
734
+ case self::WAITING_FOR_DESTRUCTOR_SYMBOL:
735
+ if (!preg_match('/[A-Za-z]/', $x[0])) {
736
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
737
+ "Symbol name missing after %destructor keyword");
738
+ $this->errorcnt++;
739
+ $this->state = self::RESYNC_AFTER_DECL_ERROR;
740
+ } else {
741
+ $sp = PHP_ParserGenerator_Symbol::Symbol_new($x);
742
+ $this->declargslot = &$sp->destructor;
743
+ $this->decllnslot = &$sp->destructorln;
744
+ $this->state = self::WAITING_FOR_DECL_ARG;
745
+ }
746
+ break;
747
+ case self::WAITING_FOR_DATATYPE_SYMBOL:
748
+ if (!preg_match('/[A-Za-z]/', $x[0])) {
749
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
750
+ "Symbol name missing after %destructor keyword");
751
+ $this->errorcnt++;
752
+ $this->state = self::RESYNC_AFTER_DECL_ERROR;
753
+ } else {
754
+ $sp = PHP_ParserGenerator_Symbol::Symbol_new($x);
755
+ $this->declargslot = &$sp->datatype;
756
+ $this->state = self::WAITING_FOR_DECL_ARG;
757
+ }
758
+ break;
759
+ case self::WAITING_FOR_PRECEDENCE_SYMBOL:
760
+ if ($x[0] == '.') {
761
+ $this->state = self::WAITING_FOR_DECL_OR_RULE;
762
+ } elseif (preg_match('/[A-Z]/', $x[0])) {
763
+ $sp = PHP_ParserGenerator_Symbol::Symbol_new($x);
764
+ if ($sp->prec >= 0) {
765
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
766
+ "Symbol \"%s\" has already been given a precedence.", $x);
767
+ $this->errorcnt++;
768
+ } else {
769
+ $sp->prec = $this->preccounter;
770
+ $sp->assoc = $this->declassoc;
771
+ }
772
+ } else {
773
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
774
+ "Can't assign a precedence to \"%s\".", $x);
775
+ $this->errorcnt++;
776
+ }
777
+ break;
778
+ case self::WAITING_FOR_DECL_ARG:
779
+ if (preg_match('/[A-Za-z0-9{"]/', $x[0])) {
780
+ if ($this->declargslot != 0) {
781
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
782
+ "The argument \"%s\" to declaration \"%%%s\" is not the first.",
783
+ $x[0] == '"' ? substr($x, 1) : $x, $this->declkeyword);
784
+ $this->errorcnt++;
785
+ $this->state = self::RESYNC_AFTER_DECL_ERROR;
786
+ } else {
787
+ $this->declargslot = ($x[0] == '"' || $x[0] == '{') ? substr($x, 1) : $x;
788
+ $this->a = 1;
789
+ if (!$this->decllnslot) {
790
+ $this->decllnslot = $this->tokenlineno;
791
+ }
792
+ $this->state = self::WAITING_FOR_DECL_OR_RULE;
793
+ }
794
+ } else {
795
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
796
+ "Illegal argument to %%%s: %s",$this->declkeyword, $x);
797
+ $this->errorcnt++;
798
+ $this->state = self::RESYNC_AFTER_DECL_ERROR;
799
+ }
800
+ break;
801
+ case self::WAITING_FOR_FALLBACK_ID:
802
+ if ($x[0] == '.') {
803
+ $this->state = self::WAITING_FOR_DECL_OR_RULE;
804
+ } elseif (!preg_match('/[A-Z]/', $x[0])) {
805
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
806
+ "%%fallback argument \"%s\" should be a token", $x);
807
+ $this->errorcnt++;
808
+ } else {
809
+ $sp = PHP_ParserGenerator_Symbol::Symbol_new($x);
810
+ if ($this->fallback === 0) {
811
+ $this->fallback = $sp;
812
+ } elseif (is_object($sp->fallback)) {
813
+ PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
814
+ "More than one fallback assigned to token %s", $x);
815
+ $this->errorcnt++;
816
+ } else {
817
+ $sp->fallback = $this->fallback;
818
+ $this->gp->has_fallback = 1;
819
+ }
820
+ }
821
+ break;
822
+ case self::RESYNC_AFTER_RULE_ERROR:
823
+ /* if ($x[0] == '.') $this->state = self::WAITING_FOR_DECL_OR_RULE;
824
+ ** break; */
825
+ case self::RESYNC_AFTER_DECL_ERROR:
826
+ if ($x[0] == '.') {
827
+ $this->state = self::WAITING_FOR_DECL_OR_RULE;
828
+ }
829
+ if ($x[0] == '%') {
830
+ $this->state = self::WAITING_FOR_DECL_KEYWORD;
831
+ }
832
+ break;
833
+ }
834
+ }
835
+
836
+ /**
837
+ * return a descriptive string for a multi-terminal token.
838
+ *
839
+ * @param string $a
840
+ * @param string $b
841
+ * @return string
842
+ */
843
+ private function _printmulti($a, $b)
844
+ {
845
+ if (!$a) {
846
+ $a = '';
847
+ }
848
+ $a .= $b->name . '|';
849
+ return $a;
850
+ }
851
+ }