- Small refractoring of code, merge tokens

- Completed block token
This commit is contained in:
Dave Mc Nicoll committed 2020-05-04 22:50:02 -04:00
1 parent bf3816c3db
commit ce4ef6351a
21 files changed
+370 -194

No files matched your search

+23 -8
View File
@@ -4,17 +4,32 @@ namespace Picea\ControlStructure;
class ForToken implements ControlStructure {
public string $token = "for";
public array $token = [ "for", "endfor" ];
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) {
$uid = "$".uniqid("for_");
switch($token) {
case "for":
$uid = "$".uniqid("for_");
$context->iterationStack[] = [
'or' => false,
'uid' => $uid,
'token' => 'endfor',
];
$context->iterationStack[] = [
'or' => false,
'uid' => $uid,
'token' => 'endfor',
];
return "<?php for ($arguments): {$uid} = 1; ?>";
return "<?php for ($arguments): {$uid} = 1; ?>";
case "endfor":
if ( end($context->iterationStack)['or'] === false ) {
$output = "<?php endfor; ?>";
}
else {
$output = "<?php endif; ?>";
}
array_pop($context->iterationStack);
return $output;
}
}
}