Skip to content

Commit fe45b69

Browse files
committed
Removed unneeded MySQL, also finished the variable parser.
Now, we have construct() to focus on!!!!
1 parent 3552e59 commit fe45b69

File tree

143 files changed

+94
-255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+94
-255
lines changed

Concept-Table varproc.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Table variable processing
2+
3+
Inputs:
4+
$position = Where the tag begins
5+
$tPosition = Where the tEnTableK is relative to position
6+
$size = The full size of the tag
7+
$tStart = Where the line processing ends for the first half of the tag
8+
$start = Where the line processing ends for the second half of the tag
9+
10+
Implications:
11+
$size-$tPosition = The size of the second half of the tag
12+
$tPosition+1 = The size of the first half of the tag
13+
$position+$tPosition = Where the tEnTableK tag is. (Impossible to prove in sanitized tests.)
14+
$start-1 = Where the next chain tag is. (Impossible to prove in sanitized tests.)
15+
($size-$tPosition)-($start-($position+$tPosition)) = The length from the start to the end tag. (Impossible to prove in sanitized tests.)
16+
17+
Proof of Implications:
18+
[*table.html:@tableInput]
19+
$position : 566
20+
$tPosition : 11
21+
$size : 23
22+
$tStart : 566
23+
$start : 578
24+
Expected size of second half: 12 (@tableInput)
25+
23-11 = 12 (Checks out)
26+
Expected size of first half: 12 (*table.html)
27+
11+1 = 12 (Checks out)
28+
29+
30+
[*!thisLike:@!@thisLike]
31+
$position : 616
32+
$tPosition : 10
33+
$size : 22
34+
$tStart : 617
35+
$start : 630
36+
Expected size of second half: 12 (@!@thisLike)
37+
22-10 = 12 (Checks out)
38+
Expected size of first half: 11 (*!thisLike)
39+
10+1 = 11 (Checks out)
40+
41+
42+
What we need to do:
43+
Process the first half of the tag for any unresolved piping.
44+
Process the second half of the tag for any unresolved piping,
45+
and ensure it ends with a variable or constant.
46+
47+
First half:
48+
Fairly easy. if $position != $tStart, then get the first half of the tag
49+
($position, $tPosition-1), run it through the ringer.
50+
51+
Second half:
52+
First, check if $position+$tPosition+1 is @ or !. If not, just give up, because it's
53+
self evidently not a const or variable.
54+
Second step, if ($tStart+$tPosition+1) != $start, we know that the second half
55+
is not lining up with what's unpiped, so we begin the pipe ringer.
56+
57+
Finally, we throw onto the respective stacks what we want to do.

Engine/tEconsts.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,4 @@
1313
const tEnTableB = "*"; // Table tags (first is a file tag, second denotes a variable binding, third is replaced by the values)
1414
const tEnTableK = ":";
1515
const tEnTableV = "^";
16-
17-
// Please don't mess with these, these AREN'T settings.
18-
const tEnMajor = 1;
19-
const tEnMinor = 0;
20-
const tEnPatch = 0;
21-
const tEnCodename = "Exemplar";
2216
?>

Engine/tEngine.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php
2+
// This is the file you need to include whenever you wanted to run the Exemplar engine.
3+
// Please don't mess with these, these AREN'T settings. Check consts for settings!
4+
const tEnMajor = 1;
5+
const tEnMinor = 0;
6+
const tEnPatch = 0;
7+
const tEnCodename = "Exemplar";
8+
29
require "tEconsts.php";
310
require "tEobject.php";
411
?>

Engine/tEobject.php

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function varFile($file, $fileDepth) {
8888
else
8989
$finalValue = true;
9090

91-
if ($subStr == tEnTableK && $primaryIn == tEnTableB) { // When we find a table's K value, then we unlock finalValue and change the tPosition.
91+
if ($subStr == tEnTableK && $primaryIn == tEnTableB && $tPosition == null) { // When we find a table's K value, then we unlock finalValue and change the tPosition.
9292
$tPosition = $size;
9393
$tStart = $start;
9494
$finalValue = false;
@@ -132,66 +132,47 @@ function varFile($file, $fileDepth) {
132132
}
133133

134134
} else { // Tables are treated through special logic due to their crazy two-part complexity. Gotta love it!
135-
$rSize = $size-$tPosition; // Reduced mediary size.
136-
// The first half of this is resolving the table filename. In most cases, we don't actually need to do this. That said, who knows what horrors the user has subjected this input to.
137-
if ($tStart != $position) { // Okay, so we know that this half of the table is actually a chain. Let's resolve it!
138-
$testingVariable = substr($fileString, $tStart+1, $tPosition-2);
139-
while (true) {
140-
$toTest = substr($fileString, $tStart, 1);
141-
$resolutionTest = $this->resolveValue($testingVariable, $toTest);
142-
if ($resolutionTest == null) // If we've encountered an unsolvable test, abandon the plan.
143-
break;
144-
$testingVariable = $resolutionTest;
145-
$tStart--;
146-
if (substr($fileString, $start-1, 1) == tEnFile) // If the second to next tag would've been the start tag, then we've reached the end of what we needed to do.
147-
break;
135+
// First, we check if this is even worth it. It may not be!
136+
$finalValue = substr($fileString, $position+$tPosition+1, 1);
137+
if ($finalValue == tEnConst || $finalValue == tEnVar) {
138+
// Now that it checks out, let's deal with the halves.
139+
$inProcess = substr($fileString, $position+$tPosition+1, $size-$tPosition-1);
140+
if ($tStart+$tPosition+1 != $start) { // Oh, there's a chain here!
141+
$testingVariable = substr($fileString, $start, ($size-$tPosition)-($start-($position+$tPosition)));
142+
while (true) {
143+
$toTest = substr($fileString, $start-1, 1);
144+
$resolutionTest = $this->resolveValue($testingVariable, $toTest);
145+
if ($resolutionTest == null)
146+
break;
147+
$testingVariable = $resolutionTest;
148+
$start--;
149+
if ($start-1 == ($position+$tPosition+1)) // If the second to next tag would've been the start tag, then we've reached the end of what we needed to do.
150+
break;
151+
}
152+
$inProcess = substr($fileString, $start-1, 1) . $testingVariable;
148153
}
149-
// At this point, we just need to throw what's left onto the stack to resolve later, if it even needs to be.
150154
switch (substr($inProcess, 0, 1)) {
151155
case tEnConst:
152-
array_push($this->toFill[0], $testingVariable);
156+
array_push($this->toFill[0], substr($inProcess, 1));
153157
break;
154158
case tEnVar:
155-
array_push($this->toFill[1], $testingVariable);
159+
array_push($this->toFill[1], substr($inProcess, 1));
156160
break;
157161
default:
158162
break;
159-
}
160163
}
161-
162-
// Now that the first half has been resolved, let's get to business on the second half.
163-
$inProcess = substr($fileString, $start, $rSize-1);
164-
if ($start != ($tPosition+$position+1)) {
165-
$testingVariable = substr($fileString, $start+1, $rSize-($start-$position-$tPosition)-1);
166-
while (true) {
167-
$toTest = substr($fileString, $start, 1);
168-
$resolutionTest = $this->resolveValue($testingVariable, $toTest);
169-
if ($resolutionTest == null) // If we've encountered an unsolvable test, abandon the plan.
170-
break;
171-
$testingVariable = $resolutionTest;
172-
$start--;
173-
if (substr($fileString, $start-1, 1) == tEnTableK) // If the second to next tag would've been the start tag, then we've reached the end of what we needed to do.
174-
break;
175-
}
176-
$inProcess = substr($testingVariable, $start, 1) . $testingVariable;
177164
}
178-
179-
var_dump($inProcess);
180165
}
181166

182167
$position += $size;
183-
184168
}
185169
}
186170
$position++; // Position incrementer.
187171
}
188172
}
189173

190-
function addValue($array, $value) {
191-
echo $value;
192-
}
193174
// If, for whatever reason, you're looking to clear out old variables that cannot be "resolved", then this function will go through and do so.
194-
// Please note that unless safe insertion is disabled, you probably won't be able to readd what you want to.
175+
// Please note that unless safe insertion is disabled, you probably won't be able to re-add any complex piping without running refreshRequests().
195176
public function garbage() {
196177

197178
}
@@ -201,7 +182,7 @@ function preen() {
201182

202183
}
203184

204-
//
185+
// Internal function to try to resolve pipes.
205186
function resolveValue($checkFor, $valueType) {
206187
switch ($valueType) {
207188
case tEnConst:

HTML/index.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
<?php
22
include "tEngine.php";
3+
$templateFile = new tEngine("test/test.html");
34
$tableInput = array(array(tEnMajor, tEnMinor, tEnPatch, tEnCodename),
5+
46
array(tEnMaxFiles, tEnMaxDepth, tEnTagQ, tEnTagS),
57
array(tEnTagE, tEnTableB, tEnTableV, tEnTableK),
6-
array(tEnVar, tEnFile, tEnSafeInsert, "Left blank."));
8+
array(tEnVar, tEnFile, tEnSafeInsert, $templateFile->setVariable("safeInsertTest", "Safe insert is definitely disabled!")));
79

810
const likeThis = "<b>like this</b>";
911
const thisLike = "likeThis";
1012

1113
$likeThis = "<i>like this</i>";
12-
$templateFile = new tEngine("test/test.html");
1314

1415
$templateFile->setVariable("tableInput", $tableInput);
1516
$templateFile->setVariable("likeThis", $likeThis);
1617

18+
echo $templateFile->construct();
1719

18-
/* var_dump($templateFile->returnConsts());
20+
var_dump($templateFile->returnConsts());
1921
echo "<br>";
2022
var_dump($templateFile->returnVars());
2123
echo "<br>";
2224
var_dump($templateFile->returnSets());
23-
echo "<hr>"; */
24-
25-
echo $templateFile->construct();
25+
echo "<hr>";
2626
?>

HTML/test/test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1>Exemplar Template Engine : [!tEnMajor].[!tEnMinor].[!tEnPatch] - [!tEnCodena
1313
[*table.html:@tableInput]
1414
</table>
1515
<table>
16-
[*!thisLike:@!thisLike]
16+
[*!thisLike:!thisLike]
1717
</table>
1818
<p>As you can see, tables are a <i>very</i> powerful feature which open up many different possibilities.</p>
1919
<p>Another little interesting factoid is that file tags are first tested relative to the template, then relative to the script, and finally absolute. This means that you can place your templates folder anywhere you damn well please, and have it work just fine. Some examples include [#relativeFile.html], [#test2/relativeFile.html], and [#test3/relativeFile.html].</p>

MySQL/aria_log.00000001

-24 KB
Binary file not shown.

MySQL/aria_log_control

-52 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)