aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpabs@pablotron.org <pabs@pablotron.org>2014-12-18 23:09:02 -0500
committerpabs@pablotron.org <pabs@pablotron.org>2014-12-18 23:09:02 -0500
commita4b6ba7ccc60e543d090acfd8d48d83febdcf912 (patch)
tree41a37d94f29dc01399f1ae2ec93f9a6c6756d57e
parent29cc0a7cf0bc8614f8182e753d9bfa30341066c3 (diff)
downloadluigi-template-a4b6ba7ccc60e543d090acfd8d48d83febdcf912.tar.bz2
luigi-template-a4b6ba7ccc60e543d090acfd8d48d83febdcf912.zip
remove legacy parser
-rw-r--r--php/luigi-template.php98
1 files changed, 0 insertions, 98 deletions
diff --git a/php/luigi-template.php b/php/luigi-template.php
index cec1ff6..9cd2975 100644
--- a/php/luigi-template.php
+++ b/php/luigi-template.php
@@ -88,104 +88,6 @@ final class Filters {
}
};
-final class LegacyParser {
- private static $RES = array(
- 'action' => '/
- # match opening brace
- %\{\s*
-
- # match key
- ([\w_-]+)
-
- # match filter(s)
- ((\s*\|\s*\w+\s*(\([\w\s,-]+\))?)*)
-
- # match closing brace
- \}
-
- # or match up all non-% chars or a single % char
- | ([^%]* | %)
- /mx',
-
- 'filter' => '/
- # match filter name
- ([\w_-]+)
-
- # optional trailing whitespace
- \s*
-
- # optional filter arguments
- (\(([\w\s_,-]+)\))?
- /mx',
- );
-
- public static function parse_template($template) {
- # build list of matches
- $matches = array();
- $num_matches = preg_match_all(
- self::$RES['action'],
- $template,
- $matches,
- PREG_SET_ORDER
- );
-
- # check for error
- if ($num_matches === false)
- throw new Error('error matching template');
-
- # walk over matches and build list of actions
- $r = array_map(function($m) {
- if ($m[1] !== '') {
- # key and filters
- return array(
- 'type' => 'action',
- 'key' => $m[1],
- 'filters' => self::parse_filters($m[2]),
- );
- } else {
- # literal text
- return array(
- 'type' => 'text',
- 'text' => $m[5],
- );
- }
- }, $matches);
-
- # return result
- return $r;
- }
-
- public static function parse_filters($filters) {
- # split into individual filters
- $r = array();
- foreach (preg_split('/\s*\|\s*/', $filters) as $f) {
- # skip empty filters
- if (!$f)
- continue;
-
- # match filter
- $md = array();
- if (!preg_match(self::$RES['filter'], $f, $md))
- throw new Error("invalid filter: $f");
-
- # add filter to results
- $r[] = array(
- # filter name
- 'name' => $md[1],
-
- # filter arguments
- 'args' => (count($md) > 2) ? preg_split(
- '/\s*,\s*/',
- trim($md[3])
- ) : array(),
- );
- }
-
- # return results
- return $r;
- }
-};
-
final class Parser {
private static $RES = array(
'action' => '/