summaryrefslogtreecommitdiff
path: root/stupid_template_engine.php
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-10-21 12:47:41 +0200
committerKevin Chabowski <kevin@kch42.de>2013-10-21 12:47:41 +0200
commit04ee002e30b5451d505ee5abd9c6b97c40da2df0 (patch)
tree1c0cde4f1d55ab6a5a03544cf9ae98d3077dd759 /stupid_template_engine.php
parentb2c464d6e3b4fa91eca3a80985150ee100713b9f (diff)
downloadste-04ee002e30b5451d505ee5abd9c6b97c40da2df0.tar.gz
ste-04ee002e30b5451d505ee5abd9c6b97c40da2df0.tar.bz2
ste-04ee002e30b5451d505ee5abd9c6b97c40da2df0.zip
Removed old parse function and added some documentation.
Diffstat (limited to 'stupid_template_engine.php')
-rw-r--r--stupid_template_engine.php38
1 files changed, 21 insertions, 17 deletions
diff --git a/stupid_template_engine.php b/stupid_template_engine.php
index 386f760..78a3eec 100644
--- a/stupid_template_engine.php
+++ b/stupid_template_engine.php
@@ -106,6 +106,11 @@ class RuntimeError extends \Exception {}
*/
class FatalRuntimeError extends \Exception {}
+/*
+ * Class: Parser
+ * The class, where the parser lives in. Can not be constructed manually.
+ * Use the static method parse.
+ */
class Parser {
private $text;
private $name;
@@ -205,6 +210,22 @@ class Parser {
return $name;
}
+ /*
+ * Function: parse
+ * Parses the input into an AST.
+ *
+ * You only need this function, if you want to manually trnascompile a template.
+ *
+ * Parameters:
+ * $text - The input code.
+ * $name - The name of the template.
+ *
+ * Returns:
+ * An array of <ASTNode> objects.
+ *
+ * Throws:
+ * <ParseCompileError>
+ */
public static function parse($text, $name) {
$obj = new self($text, $name);
$res = $obj->parse_text(
@@ -525,23 +546,6 @@ class Parser {
}
}
-/*
- * Function: parse
- * Parsing a STE T/PL template.
- * You only need this function, if you want to manually transcompile a template.
- *
- * Parameters:
- * $code - The STE T/PL code.
- * $tpl - The name of the template.
- *
- * Returns:
- * An abstract syntax tree, which can be used with <transcompile>.
- */
-function parse($code, $tpl)
-{
- return mk_ast($code, $tpl, 0);
-}
-
function indent_code($code)
{
return implode(