- First commit of first draft
This commit is contained in:
commit
66c7b349d1
36 files changed
+820
No files matched your search
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Picea\ControlStructure;
|
||||
|
||||
class OrToken implements ControlStructure {
|
||||
|
||||
public string $token = "or";
|
||||
|
||||
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments) {
|
||||
if ( empty($context->iterationStack) ) {
|
||||
throw new \LogicException("Token `or` was used outside of iterator. Make sure your `for` or `foreach` declaration are properly made.");
|
||||
}
|
||||
|
||||
$key = count( $context->iterationStack ) - 1;
|
||||
$context->iterationStack[$key]['or'] = true;
|
||||
return "<?php {$context->iterationStack[$key]['token']}; if(false === {$context->iterationStack[$key]['uid']} ?? false): ?>";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user