guard-mthaml 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +34 -0
- data/lib/guard/mthaml.rb +140 -0
- data/lib/guard/mthaml/compiler/MtHaml.php +255 -0
- data/lib/guard/mthaml/templates/Guardfile +12 -0
- data/lib/guard/mthaml/version.rb +5 -0
- data/vendor/autoload.php +7 -0
- data/vendor/coffeescript/coffeescript/LICENSE +22 -0
- data/vendor/coffeescript/coffeescript/README.md +96 -0
- data/vendor/coffeescript/coffeescript/composer.json +23 -0
- data/vendor/coffeescript/coffeescript/grammar.y +309 -0
- data/vendor/coffeescript/coffeescript/make.php +115 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Compiler.php +76 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Error.php +15 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Helpers.php +116 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Init.php +96 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Lexer.php +1356 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Nodes.php +105 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Parser.php +3326 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Rewriter.php +552 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Scope.php +196 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/SyntaxError.php +9 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Value.php +20 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Access.php +31 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Arr.php +69 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Assign.php +353 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Base.php +288 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Block.php +294 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Call.php +283 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Class.php +282 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Closure.php +49 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Code.php +203 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Comment.php +39 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Existence.php +42 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Extends.php +26 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/For.php +250 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/If.php +161 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/In.php +99 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Index.php +27 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Literal.php +96 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Obj.php +126 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Op.php +292 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Param.php +119 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Parens.php +45 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Range.php +225 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Return.php +56 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Slice.php +47 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Splat.php +100 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Switch.php +121 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Throw.php +37 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Try.php +79 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Value.php +210 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/While.php +112 -0
- data/vendor/coffeescript/coffeescript/tests/cases/arrays.coffee +77 -0
- data/vendor/coffeescript/coffeescript/tests/cases/assignment.coffee +352 -0
- data/vendor/coffeescript/coffeescript/tests/cases/booleans.coffee +21 -0
- data/vendor/coffeescript/coffeescript/tests/cases/classes.coffee +681 -0
- data/vendor/coffeescript/coffeescript/tests/cases/comments.coffee +207 -0
- data/vendor/coffeescript/coffeescript/tests/cases/compilation.coffee +72 -0
- data/vendor/coffeescript/coffeescript/tests/cases/comprehensions.coffee +501 -0
- data/vendor/coffeescript/coffeescript/tests/cases/control_flow.coffee +430 -0
- data/vendor/coffeescript/coffeescript/tests/cases/eval.coffee +29 -0
- data/vendor/coffeescript/coffeescript/tests/cases/exception_handling.coffee +102 -0
- data/vendor/coffeescript/coffeescript/tests/cases/formatting.coffee +146 -0
- data/vendor/coffeescript/coffeescript/tests/cases/function_invocation.coffee +552 -0
- data/vendor/coffeescript/coffeescript/tests/cases/functions.coffee +188 -0
- data/vendor/coffeescript/coffeescript/tests/cases/helpers.coffee +96 -0
- data/vendor/coffeescript/coffeescript/tests/cases/importing.coffee +18 -0
- data/vendor/coffeescript/coffeescript/tests/cases/interpolation.coffee +138 -0
- data/vendor/coffeescript/coffeescript/tests/cases/javascript_literals.coffee +10 -0
- data/vendor/coffeescript/coffeescript/tests/cases/numbers.coffee +76 -0
- data/vendor/coffeescript/coffeescript/tests/cases/objects.coffee +271 -0
- data/vendor/coffeescript/coffeescript/tests/cases/operators.coffee +277 -0
- data/vendor/coffeescript/coffeescript/tests/cases/option_parser.coffee +43 -0
- data/vendor/coffeescript/coffeescript/tests/cases/ranges.coffee +88 -0
- data/vendor/coffeescript/coffeescript/tests/cases/regexps.coffee +63 -0
- data/vendor/coffeescript/coffeescript/tests/cases/scope.coffee +43 -0
- data/vendor/coffeescript/coffeescript/tests/cases/slicing_and_splicing.coffee +143 -0
- data/vendor/coffeescript/coffeescript/tests/cases/soaks.coffee +134 -0
- data/vendor/coffeescript/coffeescript/tests/cases/strict.coffee +155 -0
- data/vendor/coffeescript/coffeescript/tests/cases/strings.coffee +107 -0
- data/vendor/coffeescript/coffeescript/tests/css/style.css +43 -0
- data/vendor/coffeescript/coffeescript/tests/index.php +119 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.1.1.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.2.0.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.0.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.1.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/diff.js +276 -0
- data/vendor/coffeescript/coffeescript/tests/js/main.js +123 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/LICENSE.txt +10 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/Lempar.php +948 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Action.php +257 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/ActionTable.php +299 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Config.php +574 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Data.php +1857 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Parser.php +851 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/PropagationLink.php +126 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Rule.php +144 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/State.php +283 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Symbol.php +288 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/cli.php +5 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/ParserGenerator.php +811 -0
- data/vendor/composer/ClassLoader.php +383 -0
- data/vendor/composer/autoload_classmap.php +9 -0
- data/vendor/composer/autoload_namespaces.php +12 -0
- data/vendor/composer/autoload_psr4.php +10 -0
- data/vendor/composer/autoload_real.php +50 -0
- data/vendor/composer/installed.json +166 -0
- data/vendor/michelf/php-markdown/License.md +36 -0
- data/vendor/michelf/php-markdown/Michelf/Markdown.inc.php +10 -0
- data/vendor/michelf/php-markdown/Michelf/Markdown.php +3117 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.inc.php +11 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php +38 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.inc.php +9 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php +37 -0
- data/vendor/michelf/php-markdown/Readme.md +305 -0
- data/vendor/michelf/php-markdown/Readme.php +31 -0
- data/vendor/michelf/php-markdown/composer.json +31 -0
- data/vendor/mthaml/mthaml/CHANGELOG +48 -0
- data/vendor/mthaml/mthaml/LICENSE +44 -0
- data/vendor/mthaml/mthaml/README.markdown +262 -0
- data/vendor/mthaml/mthaml/composer.json +45 -0
- data/vendor/mthaml/mthaml/docs/Makefile +153 -0
- data/vendor/mthaml/mthaml/docs/_static/mthaml.css +30 -0
- data/vendor/mthaml/mthaml/docs/_theme/mthaml/theme.conf +4 -0
- data/vendor/mthaml/mthaml/docs/conf.py +242 -0
- data/vendor/mthaml/mthaml/docs/index.rst +18 -0
- data/vendor/mthaml/mthaml/docs/twig-syntax.rst +274 -0
- data/vendor/mthaml/mthaml/examples/README.md +5 -0
- data/vendor/mthaml/mthaml/examples/autoload.php +8 -0
- data/vendor/mthaml/mthaml/examples/example-php.haml +5 -0
- data/vendor/mthaml/mthaml/examples/example-php.php +37 -0
- data/vendor/mthaml/mthaml/examples/example-twig-noext.twig +11 -0
- data/vendor/mthaml/mthaml/examples/example-twig.haml +9 -0
- data/vendor/mthaml/mthaml/examples/example-twig.php +60 -0
- data/vendor/mthaml/mthaml/examples/example.twig.haml +8 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Autoloader.php +22 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Environment.php +178 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Escaping.php +33 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Exception.php +9 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Exception/SyntaxErrorException.php +9 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/AbstractFilter.php +43 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Cdata.php +16 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/CoffeeScript.php +33 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Css.php +26 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Escaped.php +22 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/FilterInterface.php +15 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Javascript.php +26 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less.php +27 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/LeafoLess.php +20 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/OyejorgeLess.php +23 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown.php +58 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/CebeMarkdown.php +22 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Ciconia.php +21 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/MichelfMarkdown.php +21 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Parsedown.php +21 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Plain.php +24 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Preserve.php +19 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Scss.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Twig.php +47 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Indentation.php +96 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationException.php +9 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationInterface.php +50 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Undefined.php +41 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Comment.php +71 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Doctype.php +96 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/EscapableAbstract.php +19 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Filter.php +51 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Insert.php +42 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php +73 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestAbstract.php +117 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestInterface.php +10 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/NodeAbstract.php +77 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefClass.php +42 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefId.php +42 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Root.php +35 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Run.php +71 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Statement.php +45 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Tag.php +90 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttribute.php +62 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeInterpolation.php +24 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeList.php +24 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Text.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Autoclose.php +25 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Escaping.php +105 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/MergeAttrs.php +110 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Midblock.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorAbstract.php +226 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorInterface.php +97 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/PhpRenderer.php +288 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Printer.php +265 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/RendererAbstract.php +581 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/TwigRenderer.php +252 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Parser.php +862 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Parser/Buffer.php +147 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Runtime.php +218 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeInterpolation.php +16 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeList.php +16 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Php/Executor.php +157 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Extension.php +47 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Lexer.php +48 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Loader.php +81 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/Php.php +23 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetAbstract.php +87 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetInterface.php +12 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/Twig.php +23 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilder.php +100 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilderException.php +9 -0
- data/vendor/mthaml/mthaml/phpunit.xml +25 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php +59 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/HamlSpecTest.php +83 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/IndentationTest.php +140 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/DoctypeTest.php +51 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/NodeTest.php +110 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/PhpRendererTest.php +113 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/TwigRendererTest.php +68 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitorsTest.php +44 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Parser/BufferTest.php +77 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php +47 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/RuntimeTest.php +356 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Php/ExecutorTest.php +83 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Twig/LoaderTest.php +65 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCase.php +49 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCaseTest.php +50 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/Support/Php/Executor.001.haml +1 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_php.test +20 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_twig.test +12 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_php.test +16 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_twig.test +16 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_php.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_twig.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug42.test +13 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug8_twig.test +10 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/coffeescript_filter.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/comments.test +26 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/cond_cmt.test +25 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_html4.test +20 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid.test +12 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid_xhtml.test +12 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_php.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_xhtml.test +30 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/filters.test +51 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_php.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_twig.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_php.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_twig.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_leafo.test +33 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_oyejorge.test +49 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_cebemarkdown.test +35 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_ciconia.test +36 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_michelf.test +34 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_parsedown.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_optimization_filter_michelf.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/mergeattrs.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_inner_whitespace.test +77 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_outer_whitespace.test +122 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_php.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_twig.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php.test +109 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping_once.test +25 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_blocks.test +29 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_filters.test +42 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/scss_filter.test +32 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/strip_inline_comments_php.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/test.test +24 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/trailing_semicolon_php.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/try_catch_php.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig.test +112 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_blocks.test +29 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_filters.test +37 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_whitespace.test +32 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/whitespace.test +63 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/autoclose.test +30 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping.test +52 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_attr_once.test +52 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_html_false.test +52 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/mergeattrs.test +26 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock.test +54 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock_002.test +32 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attr_list.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs.test +42 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_002.test +35 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_003.test +30 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_html_linebreak.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks.test +27 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks_002.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/boolean_attr.test +19 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug28.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug8.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/cond_cmt.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/doctype.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/double_equal.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/empty_line_after_multiline.test +10 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_001.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_002.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_003.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_004.test +6 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_005.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_006.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_007.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_008.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_009.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_010.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_013.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_016.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_017.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_018.test +6 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_019.test +6 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_020.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters.test +20 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_002.test +19 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_003.test +13 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_004.test +21 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_005.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_006.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/insertflags.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation.test +36 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation_in_html_attrs.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline_code.test +59 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiple_attr_kinds.test +47 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/non_rendered_comment.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ns.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error1.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error2.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/quotes_in_haml.test +10 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby19_attrs.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_001.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_002.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_003.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/standard.test +114 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/tagflags.test +39 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/php_filters.test +28 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/twig_filters.test +31 -0
- data/vendor/mthaml/mthaml/test/bootstrap.php +3 -0
- metadata +398 -0
@@ -0,0 +1,552 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace CoffeeScript;
|
4
|
+
|
5
|
+
Init::init();
|
6
|
+
|
7
|
+
class Rewriter
|
8
|
+
{
|
9
|
+
static $BALANCED_PAIRS = array(
|
10
|
+
array('(', ')'),
|
11
|
+
array('[', ']'),
|
12
|
+
array('{', '}'),
|
13
|
+
array('INDENT', 'OUTDENT'),
|
14
|
+
array('CALL_START', 'CALL_END'),
|
15
|
+
array('PARAM_START', 'PARAM_END'),
|
16
|
+
array('INDEX_START', 'INDEX_END'),
|
17
|
+
);
|
18
|
+
|
19
|
+
static $INVERSES = array();
|
20
|
+
|
21
|
+
static $EXPRESSION_START = array();
|
22
|
+
static $EXPRESSION_END = array();
|
23
|
+
|
24
|
+
static $EXPRESSION_CLOSE = array('CATCH', 'WHEN', 'ELSE', 'FINALLY');
|
25
|
+
|
26
|
+
static $IMPLICIT_FUNC = array('IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS');
|
27
|
+
|
28
|
+
static $IMPLICIT_CALL = array(
|
29
|
+
'IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS',
|
30
|
+
'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'UNARY', 'SUPER',
|
31
|
+
'@', '->', '=>', '[', '(', '{', '--', '++'
|
32
|
+
);
|
33
|
+
|
34
|
+
static $IMPLICIT_UNSPACED_CALL = array('+', '-');
|
35
|
+
|
36
|
+
static $IMPLICIT_BLOCK = array('->', '=>', '{', '[', ',');
|
37
|
+
|
38
|
+
static $IMPLICIT_END = array('POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR');
|
39
|
+
|
40
|
+
static $SINGLE_LINERS = array('ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN');
|
41
|
+
static $SINGLE_CLOSERS = array('TERMINATOR', 'CATCH', 'FINALLY', 'ELSE', 'OUTDENT', 'LEADING_WHEN');
|
42
|
+
|
43
|
+
static $LINEBREAKS = array('TERMINATOR', 'INDENT', 'OUTDENT');
|
44
|
+
|
45
|
+
static $initialized = FALSE;
|
46
|
+
|
47
|
+
static function init()
|
48
|
+
{
|
49
|
+
if (self::$initialized) return;
|
50
|
+
|
51
|
+
self::$initialized = TRUE;
|
52
|
+
|
53
|
+
foreach (self::$BALANCED_PAIRS as $pair)
|
54
|
+
{
|
55
|
+
list($left, $rite) = $pair;
|
56
|
+
|
57
|
+
self::$EXPRESSION_START[] = self::$INVERSES[$rite] = $left;
|
58
|
+
self::$EXPRESSION_END[] = self::$INVERSES[$left] = $rite;
|
59
|
+
}
|
60
|
+
|
61
|
+
self::$EXPRESSION_CLOSE = array_merge(self::$EXPRESSION_CLOSE, self::$EXPRESSION_END);
|
62
|
+
}
|
63
|
+
|
64
|
+
function __construct($tokens)
|
65
|
+
{
|
66
|
+
self::init();
|
67
|
+
|
68
|
+
$this->tokens = $tokens;
|
69
|
+
}
|
70
|
+
|
71
|
+
function add_implicit_braces()
|
72
|
+
{
|
73
|
+
$stack = array();
|
74
|
+
$start = NULL;
|
75
|
+
$starts_line = NULL;
|
76
|
+
$same_line = TRUE;
|
77
|
+
$start_indent = 0;
|
78
|
+
|
79
|
+
$self = $this;
|
80
|
+
|
81
|
+
$condition = function( & $token, $i) use ( & $self, & $same_line, & $starts_line)
|
82
|
+
{
|
83
|
+
$list = array();
|
84
|
+
|
85
|
+
for ($j = 0; $j < 3; $j++)
|
86
|
+
{
|
87
|
+
$k = ($i + 1) + $j;
|
88
|
+
$list[$j] = isset($self->tokens[$k]) ? $self->tokens[$k] : array(NULL, NULL);
|
89
|
+
}
|
90
|
+
|
91
|
+
list($one, $two, $three) = $list;
|
92
|
+
|
93
|
+
if ($one[0] === t('HERECOMMENT'))
|
94
|
+
{
|
95
|
+
return FALSE;
|
96
|
+
}
|
97
|
+
|
98
|
+
$tag = $token[0];
|
99
|
+
|
100
|
+
if (in_array($tag, t(Rewriter::$LINEBREAKS)))
|
101
|
+
{
|
102
|
+
$same_line = FALSE;
|
103
|
+
}
|
104
|
+
|
105
|
+
return
|
106
|
+
( (in_array($tag, t('TERMINATOR', 'OUTDENT')) || (in_array($tag, t(Rewriter::$IMPLICIT_END)) && $same_line)) &&
|
107
|
+
( ( ! $starts_line && $self->tag($i - 1) !== t(',')) ||
|
108
|
+
! ($two[0] === t(':') || $one[0] === t('@') && $three[0] === t(':'))) ) ||
|
109
|
+
($tag === t(',') &&
|
110
|
+
! in_array($one[0], t('IDENTIFIER', 'NUMBER', 'STRING', '@', 'TERMINATOR', 'OUTDENT')) );
|
111
|
+
};
|
112
|
+
|
113
|
+
$action = function( & $token, $i) use ( & $self)
|
114
|
+
{
|
115
|
+
$tok = $self->generate(t('}'), '}', $token[2]);
|
116
|
+
array_splice($self->tokens, $i, 0, array($tok));
|
117
|
+
};
|
118
|
+
|
119
|
+
$this->scan_tokens(function( & $token, $i, & $tokens) use (& $self, & $stack, & $start, & $start_indent, & $condition, & $action, & $starts_line, & $same_line)
|
120
|
+
{
|
121
|
+
if (in_array(($tag = $token[0]), t(Rewriter::$EXPRESSION_START)))
|
122
|
+
{
|
123
|
+
$stack[] = array( ($tag === t('INDENT') && $self->tag($i - 1) === t('{')) ? t('{') : $tag, $i );
|
124
|
+
return 1;
|
125
|
+
}
|
126
|
+
|
127
|
+
if (in_array($tag, t(Rewriter::$EXPRESSION_END)))
|
128
|
+
{
|
129
|
+
$start = array_pop($stack);
|
130
|
+
return 1;
|
131
|
+
}
|
132
|
+
|
133
|
+
$len = count($stack) - 1;
|
134
|
+
|
135
|
+
if ( ! ($tag === t(':') && (($ago = $self->tag($i - 2)) === t(':') || ( ! isset($stack[$len]) || $stack[$len][0] !== t('{'))) ))
|
136
|
+
{
|
137
|
+
return 1;
|
138
|
+
}
|
139
|
+
|
140
|
+
$same_line = TRUE;
|
141
|
+
|
142
|
+
$stack[] = array(t('{'));
|
143
|
+
$idx = (isset($ago) && $ago === t('@')) ? $i - 2 : $i - 1;
|
144
|
+
|
145
|
+
while ($self->tag($idx - 2) === t('HERECOMMENT'))
|
146
|
+
{
|
147
|
+
$idx -= 2;
|
148
|
+
}
|
149
|
+
|
150
|
+
$prev_tag = $self->tag($idx - 1);
|
151
|
+
|
152
|
+
$starts_line = ! $prev_tag || in_array($prev_tag, t(Rewriter::$LINEBREAKS));
|
153
|
+
|
154
|
+
$value = wrap('{');
|
155
|
+
$value->generated = TRUE;
|
156
|
+
|
157
|
+
$tok = $self->generate(t('{'), $value, $token[2]);
|
158
|
+
|
159
|
+
array_splice($tokens, $idx, 0, array($tok));
|
160
|
+
|
161
|
+
$self->detect_end($i + 2, $condition, $action);
|
162
|
+
|
163
|
+
return 2;
|
164
|
+
});
|
165
|
+
}
|
166
|
+
|
167
|
+
function add_implicit_indentation()
|
168
|
+
{
|
169
|
+
$self = $this;
|
170
|
+
|
171
|
+
$starter = $indent = $outdent = NULL;
|
172
|
+
|
173
|
+
$condition = function($token, $i) use ( & $starter)
|
174
|
+
{
|
175
|
+
return $token[1] !== ';' && in_array($token[0], t(Rewriter::$SINGLE_CLOSERS)) && ! ($token[0] === t('ELSE') && ! in_array($starter, t('IF', 'THEN')));
|
176
|
+
};
|
177
|
+
|
178
|
+
$action = function($token, $i) use ( & $self, & $outdent)
|
179
|
+
{
|
180
|
+
if ($outdent !== NULL)
|
181
|
+
{
|
182
|
+
array_splice($self->tokens, $self->tag($i - 1) === t(',') ? $i - 1 : $i, 0, array($outdent));
|
183
|
+
}
|
184
|
+
};
|
185
|
+
|
186
|
+
$this->scan_tokens(function( & $token, $i, & $tokens) use ( & $action, & $condition, & $self, & $indent, & $outdent, & $starter)
|
187
|
+
{
|
188
|
+
$tag = $token[0];
|
189
|
+
|
190
|
+
if ($tag === t('TERMINATOR') && $self->tag($i + 1) === t('THEN'))
|
191
|
+
{
|
192
|
+
array_splice($tokens, $i, 1);
|
193
|
+
return 0;
|
194
|
+
}
|
195
|
+
|
196
|
+
if ($tag === t('ELSE') && $self->tag($i - 1) !== t('OUTDENT'))
|
197
|
+
{
|
198
|
+
array_splice($tokens, $i, 0, $self->indentation($token));
|
199
|
+
return 2;
|
200
|
+
}
|
201
|
+
|
202
|
+
if ($tag === t('CATCH') && in_array($self->tag($i + 2), t('OUTDENT', 'TERMINATOR', 'FINALLY')))
|
203
|
+
{
|
204
|
+
array_splice($tokens, $i + 2, 0, $self->indentation($token));
|
205
|
+
return 4;
|
206
|
+
}
|
207
|
+
|
208
|
+
if (in_array($tag, t(Rewriter::$SINGLE_LINERS)) && $self->tag($i + 1) !== t('INDENT') &&
|
209
|
+
! ($tag === t('ELSE') && $self->tag($i + 1) === t('IF')))
|
210
|
+
{
|
211
|
+
$starter = $tag;
|
212
|
+
list($indent, $outdent) = $self->indentation($token, TRUE);
|
213
|
+
|
214
|
+
if ($starter === t('THEN'))
|
215
|
+
{
|
216
|
+
$indent['fromThen'] = TRUE;
|
217
|
+
}
|
218
|
+
|
219
|
+
array_splice($tokens, $i + 1, 0, array($indent));
|
220
|
+
|
221
|
+
$self->detect_end($i + 2, $condition, $action);
|
222
|
+
|
223
|
+
if ($tag === t('THEN'))
|
224
|
+
{
|
225
|
+
array_splice($tokens, $i, 1);
|
226
|
+
}
|
227
|
+
|
228
|
+
return 1;
|
229
|
+
}
|
230
|
+
|
231
|
+
return 1;
|
232
|
+
});
|
233
|
+
}
|
234
|
+
|
235
|
+
function add_implicit_parentheses()
|
236
|
+
{
|
237
|
+
$no_call = $seen_single = $seen_control = FALSE;
|
238
|
+
$self = $this;
|
239
|
+
|
240
|
+
$condition = function( & $token, $i) use ( & $self, & $seen_single, & $seen_control, & $no_call)
|
241
|
+
{
|
242
|
+
$tag = $token[0];
|
243
|
+
|
244
|
+
if ( ! $seen_single && (isset($token['fromThen']) && $token['fromThen']))
|
245
|
+
{
|
246
|
+
return TRUE;
|
247
|
+
}
|
248
|
+
|
249
|
+
if (in_array($tag, t('IF', 'ELSE', 'CATCH', '->', '=>', 'CLASS')))
|
250
|
+
{
|
251
|
+
$seen_single = TRUE;
|
252
|
+
}
|
253
|
+
|
254
|
+
if (in_array($tag, t('IF', 'ELSE', 'SWITCH', 'TRY', '=')))
|
255
|
+
{
|
256
|
+
$seen_control = TRUE;
|
257
|
+
}
|
258
|
+
|
259
|
+
if (in_array($tag, t('.', '?.', '::')) && $self->tag($i - 1) === t('OUTDENT'))
|
260
|
+
{
|
261
|
+
return TRUE;
|
262
|
+
}
|
263
|
+
|
264
|
+
return ! (isset($token['generated']) && $token['generated']) && $self->tag($i - 1) !== t(',') &&
|
265
|
+
(in_array($tag, t(Rewriter::$IMPLICIT_END)) || ($tag === t('INDENT') && ! $seen_control)) &&
|
266
|
+
($tag !== t('INDENT') ||
|
267
|
+
( ! in_array($self->tag($i - 2), t('CLASS', 'EXTENDS')) && ! in_array($self->tag($i - 1), t(Rewriter::$IMPLICIT_BLOCK)) &&
|
268
|
+
! (($post = isset($self->tokens[$i + 1]) ? $self->tokens[$i + 1] : NULL) && (isset($post['generated']) && $post['generated']) && $post[0] === t('{'))));
|
269
|
+
};
|
270
|
+
|
271
|
+
$action = function( & $token, $i) use ( & $self)
|
272
|
+
{
|
273
|
+
array_splice($self->tokens, $i, 0, array($self->generate(t('CALL_END'), ')', isset($token[2]) ? $token[2] : NULL)));
|
274
|
+
};
|
275
|
+
|
276
|
+
$this->scan_tokens(function( & $token, $i, & $tokens) use ( & $condition, & $action, & $no_call, & $self, & $seen_control, & $seen_single )
|
277
|
+
{
|
278
|
+
$tag = $token[0];
|
279
|
+
|
280
|
+
if (in_array($tag, t('CLASS', 'IF', 'FOR', 'WHILE')))
|
281
|
+
{
|
282
|
+
$no_call = TRUE;
|
283
|
+
}
|
284
|
+
|
285
|
+
$prev = NULL;
|
286
|
+
|
287
|
+
if (isset($tokens[$i - 1]))
|
288
|
+
{
|
289
|
+
$prev = & $tokens[$i - 1];
|
290
|
+
}
|
291
|
+
|
292
|
+
$current = $tokens[$i];
|
293
|
+
$next = isset($tokens[$i + 1]) ? $tokens[$i + 1] : NULL;
|
294
|
+
|
295
|
+
$call_object = ! $no_call && $tag === t('INDENT') &&
|
296
|
+
$next && (isset($next['generated']) && $next['generated']) && $next[0] === t('{') &&
|
297
|
+
$prev && in_array($prev[0], t(Rewriter::$IMPLICIT_FUNC));
|
298
|
+
|
299
|
+
$seen_single = FALSE;
|
300
|
+
$seen_control = FALSE;
|
301
|
+
|
302
|
+
if (in_array($tag, t(Rewriter::$LINEBREAKS)))
|
303
|
+
{
|
304
|
+
$no_call = FALSE;
|
305
|
+
}
|
306
|
+
|
307
|
+
if ($prev && ! (isset($prev['spaced']) && $prev['spaced']) && $tag === t('?'))
|
308
|
+
{
|
309
|
+
$token['call'] = TRUE;
|
310
|
+
}
|
311
|
+
|
312
|
+
if (isset($token['fromThen']) && $token['fromThen'])
|
313
|
+
{
|
314
|
+
return 1;
|
315
|
+
}
|
316
|
+
|
317
|
+
if ( ! ($call_object || ($prev && (isset($prev['spaced']) && $prev['spaced'])) &&
|
318
|
+
( (isset($prev['call']) && $prev['call']) || in_array($prev[0], t(Rewriter::$IMPLICIT_FUNC)) ) &&
|
319
|
+
( in_array($tag, t(Rewriter::$IMPLICIT_CALL)) || ! ( (isset($token['spaced']) && $token['spaced']) ||
|
320
|
+
(isset($token['newLine']) && $token['newLine']) ) &&
|
321
|
+
in_array($tag, t(Rewriter::$IMPLICIT_UNSPACED_CALL)) )
|
322
|
+
))
|
323
|
+
{
|
324
|
+
return 1;
|
325
|
+
}
|
326
|
+
|
327
|
+
array_splice($tokens, $i, 0, array($self->generate(t('CALL_START'), '(', $token[2])));
|
328
|
+
|
329
|
+
$self->detect_end($i + 1, $condition, $action);
|
330
|
+
|
331
|
+
if ($prev[0] === t('?'))
|
332
|
+
{
|
333
|
+
$prev[0] = t('FUNC_EXIST');
|
334
|
+
}
|
335
|
+
|
336
|
+
return 2;
|
337
|
+
});
|
338
|
+
}
|
339
|
+
|
340
|
+
function close_open_calls()
|
341
|
+
{
|
342
|
+
$self = $this;
|
343
|
+
|
344
|
+
$condition = function($token, $i) use ( & $self)
|
345
|
+
{
|
346
|
+
return in_array($token[0], t(')', 'CALL_END')) || $token[0] === t('OUTDENT') &&
|
347
|
+
$self->tag($i - 1) === t(')');
|
348
|
+
};
|
349
|
+
|
350
|
+
$action = function($token, $i) use ( & $self)
|
351
|
+
{
|
352
|
+
$self->tokens[($token[0] === t('OUTDENT') ? $i - 1 : $i)][0] = t('CALL_END');
|
353
|
+
};
|
354
|
+
|
355
|
+
$this->scan_tokens(function($token, $i) use ( & $self, $condition, $action)
|
356
|
+
{
|
357
|
+
if ($token[0] === t('CALL_START'))
|
358
|
+
{
|
359
|
+
$self->detect_end($i + 1, $condition, $action);
|
360
|
+
}
|
361
|
+
|
362
|
+
return 1;
|
363
|
+
});
|
364
|
+
}
|
365
|
+
|
366
|
+
function close_open_indexes()
|
367
|
+
{
|
368
|
+
$condition = function($token, $i)
|
369
|
+
{
|
370
|
+
return in_array($token[0], t(']', 'INDEX_END'));
|
371
|
+
};
|
372
|
+
|
373
|
+
$action = function( & $token, $i)
|
374
|
+
{
|
375
|
+
$token[0] = t('INDEX_END');
|
376
|
+
};
|
377
|
+
|
378
|
+
$self = $this;
|
379
|
+
|
380
|
+
$this->scan_tokens(function($token, $i) use ( & $self, $condition, $action)
|
381
|
+
{
|
382
|
+
if ($token[0] === t('INDEX_START'))
|
383
|
+
{
|
384
|
+
$self->detect_end($i + 1, $condition, $action);
|
385
|
+
}
|
386
|
+
|
387
|
+
return 1;
|
388
|
+
});
|
389
|
+
}
|
390
|
+
|
391
|
+
function detect_end($i, $condition, $action)
|
392
|
+
{
|
393
|
+
$tokens = & $this->tokens;
|
394
|
+
$levels = 0;
|
395
|
+
|
396
|
+
while (isset($tokens[$i]))
|
397
|
+
{
|
398
|
+
$token = & $tokens[$i];
|
399
|
+
|
400
|
+
if ($levels === 0 && $condition($token, $i))
|
401
|
+
{
|
402
|
+
return $action($token, $i);
|
403
|
+
}
|
404
|
+
|
405
|
+
if ( ! $token || $levels < 0)
|
406
|
+
{
|
407
|
+
return $action($token, $i - 1);
|
408
|
+
}
|
409
|
+
|
410
|
+
if (in_array($token[0], t(Rewriter::$EXPRESSION_START)))
|
411
|
+
{
|
412
|
+
$levels++;
|
413
|
+
}
|
414
|
+
else if (in_array($token[0], t(Rewriter::$EXPRESSION_END)))
|
415
|
+
{
|
416
|
+
$levels--;
|
417
|
+
}
|
418
|
+
|
419
|
+
$i++;
|
420
|
+
}
|
421
|
+
|
422
|
+
return $i - 1;
|
423
|
+
}
|
424
|
+
|
425
|
+
function generate($tag, $value, $line)
|
426
|
+
{
|
427
|
+
return array($tag, $value, $line, 'generated' => TRUE);
|
428
|
+
}
|
429
|
+
|
430
|
+
function indentation($token, $implicit = FALSE)
|
431
|
+
{
|
432
|
+
$indent = array(t('INDENT'), 2, $token[2]);
|
433
|
+
$outdent = array(t('OUTDENT'), 2, $token[2]);
|
434
|
+
|
435
|
+
if ($implicit)
|
436
|
+
{
|
437
|
+
$indent['generated'] = $outdent['generated'] = TRUE;
|
438
|
+
}
|
439
|
+
|
440
|
+
return array($indent, $outdent);
|
441
|
+
}
|
442
|
+
|
443
|
+
function remove_leading_newlines()
|
444
|
+
{
|
445
|
+
$key = 0;
|
446
|
+
|
447
|
+
foreach ($this->tokens as $k => $token)
|
448
|
+
{
|
449
|
+
$key = $k;
|
450
|
+
$tag = $token[0];
|
451
|
+
|
452
|
+
if ($tag !== t('TERMINATOR'))
|
453
|
+
{
|
454
|
+
break;
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
if ($key)
|
459
|
+
{
|
460
|
+
array_splice($this->tokens, 0, $key);
|
461
|
+
}
|
462
|
+
}
|
463
|
+
|
464
|
+
function remove_mid_expression_newlines()
|
465
|
+
{
|
466
|
+
$self = $this;
|
467
|
+
|
468
|
+
$this->scan_tokens(function( & $token, $i, & $tokens) use ( & $self)
|
469
|
+
{
|
470
|
+
if ( ! ($token[0] === t('TERMINATOR') && in_array($self->tag($i + 1), t(Rewriter::$EXPRESSION_CLOSE))))
|
471
|
+
{
|
472
|
+
return 1;
|
473
|
+
}
|
474
|
+
|
475
|
+
array_splice($tokens, $i, 1);
|
476
|
+
return 0;
|
477
|
+
});
|
478
|
+
}
|
479
|
+
|
480
|
+
function rewrite()
|
481
|
+
{
|
482
|
+
$this->remove_leading_newlines();
|
483
|
+
$this->remove_mid_expression_newlines();
|
484
|
+
$this->close_open_calls();
|
485
|
+
$this->close_open_indexes();
|
486
|
+
$this->add_implicit_indentation();
|
487
|
+
$this->tag_postfix_conditionals();
|
488
|
+
$this->add_implicit_braces();
|
489
|
+
$this->add_implicit_parentheses();
|
490
|
+
|
491
|
+
return $this->tokens;
|
492
|
+
}
|
493
|
+
|
494
|
+
function scan_tokens($block)
|
495
|
+
{
|
496
|
+
$i = 0;
|
497
|
+
|
498
|
+
while (isset($this->tokens[$i]))
|
499
|
+
{
|
500
|
+
$i += $block($this->tokens[$i], $i, $this->tokens);
|
501
|
+
}
|
502
|
+
|
503
|
+
return TRUE;
|
504
|
+
}
|
505
|
+
|
506
|
+
function tag($i)
|
507
|
+
{
|
508
|
+
return isset($this->tokens[$i]) ? $this->tokens[$i][0] : NULL;
|
509
|
+
}
|
510
|
+
|
511
|
+
function tag_postfix_conditionals()
|
512
|
+
{
|
513
|
+
$original = NULL;
|
514
|
+
|
515
|
+
$self = $this;
|
516
|
+
|
517
|
+
$condition = function($token, $i)
|
518
|
+
{
|
519
|
+
return in_array($token[0], t('TERMINATOR', 'INDENT'));
|
520
|
+
};
|
521
|
+
|
522
|
+
$action = function($token, $i) use ( & $original, & $self)
|
523
|
+
{
|
524
|
+
if ($token[0] !== t('INDENT') || ((isset($token['generated']) && $token['generated']) && ! (isset($token['fromThen']) && $token['fromThen'])))
|
525
|
+
{
|
526
|
+
$self->tokens[$original][0] = t('POST_'.t_canonical($self->tokens[$original][0]));
|
527
|
+
|
528
|
+
// $original[0] = t('POST_'.t_canonical($original[0]));
|
529
|
+
}
|
530
|
+
};
|
531
|
+
|
532
|
+
$self = $this;
|
533
|
+
|
534
|
+
$this->scan_tokens(function( & $token, $i) use ( & $original, & $condition, & $action, & $self)
|
535
|
+
{
|
536
|
+
if ( ! ($token[0] === t('IF')))
|
537
|
+
{
|
538
|
+
return 1;
|
539
|
+
}
|
540
|
+
|
541
|
+
$original = $i;
|
542
|
+
|
543
|
+
// $original = & $token;
|
544
|
+
|
545
|
+
$self->detect_end($i + 1, $condition, $action);
|
546
|
+
|
547
|
+
return 1;
|
548
|
+
});
|
549
|
+
}
|
550
|
+
}
|
551
|
+
|
552
|
+
?>
|