picea/src/Language/DefaultRegistrations.php

58 lines
3.1 KiB
PHP
Raw Normal View History

<?php declare(strict_types=1);
namespace Picea\Language;
use Picea\Compiler;
class DefaultRegistrations implements LanguageRegistration
{
public function registerAll(Compiler $compiler) : void
{
$this->registerSyntax($compiler);
$this->registerControlStructure($compiler);
$this->registerExtension($compiler);
}
public function registerSyntax(Compiler $compiler) : void
{
$compiler->registerSyntax(new \Picea\Syntax\PhpTagToken());
$compiler->registerSyntax(new \Picea\Syntax\CommentToken());
$compiler->registerSyntax(new \Picea\Syntax\EchoRawToken());
$compiler->registerSyntax(new \Picea\Syntax\EchoSafeToken());
}
public function registerControlStructure(Compiler $compiler) : void
{
# @TODO -- a rewrite on the compiler has to be done to accept this kind of functionnality
# $compiler->registerControlStructure(new \Picea\ControlStructure\RawToken());
# $compiler->registerControlStructure(new \Picea\ControlStructure\EndRawToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\NamespaceToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\UseToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\IfToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\ElseToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\ElseIfToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\EndIfToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\ForeachToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\ForToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\OrToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\EndforeachToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\EndforToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\SwitchToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\CaseToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\DefaultToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\BreakToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\EndCaseToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\EndSwitchToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\ExtendsToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\SectionToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\EndSectionToken());
$compiler->registerControlStructure(new \Picea\ControlStructure\ViewToken());
}
public function registerExtension(Compiler $compiler) : void
{
$compiler->registerExtension(new \Picea\Extension\JsonExtension());
$compiler->registerExtension(new \Picea\Extension\AssetExtension());
}
}