- Small refractoring of code, merge tokens
- Completed block token
This commit is contained in:
1 parent
bf3816c3db
commit
ce4ef6351a
21 files changed
+370
-194
No files matched your search
@@ -4,10 +4,31 @@ namespace Picea\ControlStructure;
|
||||
|
||||
class SwitchToken implements ControlStructure {
|
||||
|
||||
public string $token = "switch";
|
||||
public array $token = [ "switch", "case", "endswitch" ];
|
||||
|
||||
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) {
|
||||
$context->switchStack[] = true;
|
||||
return "<?php switch($arguments):";
|
||||
switch($token) {
|
||||
case "switch":
|
||||
$context->switchStack[] = true;
|
||||
return "<?php switch($arguments):";
|
||||
|
||||
case "case":
|
||||
$output = "";
|
||||
|
||||
if ( $context->switchStack ) {
|
||||
array_pop($context->switchStack);
|
||||
}
|
||||
else {
|
||||
$output = "<?php ";
|
||||
}
|
||||
|
||||
return ( $output ?? "" ) . "case $arguments: ?>";
|
||||
|
||||
case "endcase":
|
||||
return "<?php break; ?>";
|
||||
|
||||
case "endswitch":
|
||||
return "<?php endswitch; ?>";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user