- WIP on RAW token
- WIP on caching interface - Work done on easing template rendering for the controller
This commit is contained in:
1 parent
f8e3dbd60f
commit
bcd49884fc
37 files changed
+381
-107
No files matched your search
+25
-9
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Picea;
|
||||
|
||||
use Picea\Language\LanguageRegistration;
|
||||
|
||||
class Compiler
|
||||
{
|
||||
protected string $sourceCode = "";
|
||||
@@ -16,8 +18,16 @@ class Compiler
|
||||
|
||||
protected array $extensionList = [];
|
||||
|
||||
protected ? LanguageRegistration $languageRegistration;
|
||||
|
||||
public function __construct(?LanguageRegistration $languageRegistration = null)
|
||||
{
|
||||
$this->languageRegistration = $languageRegistration;
|
||||
}
|
||||
|
||||
public function compile(Compiler\Context $context) : string
|
||||
{
|
||||
$this->languageRegistration->registerAll($this);
|
||||
$context->compiler = $this;
|
||||
|
||||
/**
|
||||
@@ -39,7 +49,7 @@ class Compiler
|
||||
|
||||
# @TODO Refractor this parts to allows registration to the tag's name
|
||||
if ( $this->tagList[$token] ?? false ) {
|
||||
return $this->tagList[$token]->parse($context, $arguments);
|
||||
return $this->tagList[$token]->parse($context, $arguments, $token);
|
||||
}
|
||||
elseif ( $this->extensionList[$token] ?? false ) {
|
||||
return $this->extensionList[$token]->parse($context, $arguments, $token);
|
||||
@@ -59,12 +69,6 @@ class Compiler
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function registerExtension(Extension\Extension $extension) : self
|
||||
{
|
||||
$this->extensionList[$extension->token] = $extension;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function registerCaching(CachingStrategy $cachingStrategy) : self
|
||||
{
|
||||
return $this;
|
||||
@@ -72,13 +76,25 @@ class Compiler
|
||||
|
||||
public function registerSyntax(Syntax\Syntax $syntaxObject) : self
|
||||
{
|
||||
$this->syntaxObjectList[] = $syntaxObject;
|
||||
$this->syntaxObjectList[get_class($syntaxObject)] = $syntaxObject;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function registerControlStructure(ControlStructure\ControlStructure $controlStructureObject) : self
|
||||
{
|
||||
$this->tagList[$controlStructureObject->token] = $controlStructureObject;
|
||||
foreach($controlStructureObject->tokens ?? (array) $controlStructureObject->token as $token) {
|
||||
$this->tagList[$token] = $controlStructureObject;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function registerExtension(Extension\Extension $extension) : self
|
||||
{
|
||||
foreach($extension->tokens ?? (array) $extension->token as $token) {
|
||||
$this->extensionList[$token] = $extension;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user