From 0f9ef4d8b3c0c6c77f95d6035ee1ab2f2473abb3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 18 Mar 2005 08:17:25 +0000 Subject: [PATCH] Base tokenizing parser in place --- template.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/template.php b/template.php index 8328331..f9baf46 100644 --- a/template.php +++ b/template.php @@ -396,11 +396,57 @@ class DB_Template $location_end = -1; // Tag data - $tag_start = '>>>>> " . $end . " >>>>>> "; + //echo $template[ $end - 2 ] . $template[ $end - 1 ] . $template[ $end ] . $template[ $end + 1 ] . $template[ $end + 2 ] . " (" . $template[ $end ] . ") "; + $end += strlen($tag_start_end); + //echo " { " . $template[ $end - 1 ] . " } "; + + // extract the condition + $condition = substr($template, $i, $end); + + // echo $condition . "||||||"; + + // complete the open + array_push($stack, /*array('pos' => $i, 'expr' => $condition)*/ $i); + } + // do we have an end? + // make sure that it's the whole tag + else if (substr($template, $i, strlen($tag_end)) == $tag_end) + { + // calculate the end of the tag + $end = $i + strlen($tag_end); + + // find the most recently opened condition + $last = array_pop($stack); + + // get the full condition + $fullspread = substr($template, $last, $end - $last); + echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $fullspread >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; + } + } + } + exit; + while (1) { // Finds the start tag: starts looking through the haystack one position -- 2.43.5