From fa815a506e1e009ce3c92e7dbfaba61825464bce Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Tue, 29 Oct 2024 13:40:17 +0000 Subject: [PATCH] - Added a Try/Catch token to the language (and DefaultRegistration also registers it automatically --- src/ControlStructure/TryCatchToken.php | 25 +++++++++++++++++++++++++ src/Language/DefaultRegistrations.php | 1 + 2 files changed, 26 insertions(+) create mode 100644 src/ControlStructure/TryCatchToken.php diff --git a/src/ControlStructure/TryCatchToken.php b/src/ControlStructure/TryCatchToken.php new file mode 100644 index 0000000..501eec1 --- /dev/null +++ b/src/ControlStructure/TryCatchToken.php @@ -0,0 +1,25 @@ +"; + + case "catch": + return ""; + + case "finally": + return ""; + + case "endtry": + return ""; + } + } +} diff --git a/src/Language/DefaultRegistrations.php b/src/Language/DefaultRegistrations.php index d694e29..971ab68 100644 --- a/src/Language/DefaultRegistrations.php +++ b/src/Language/DefaultRegistrations.php @@ -32,6 +32,7 @@ class DefaultRegistrations implements LanguageRegistration public function registerControlStructure(Compiler $compiler) : void { + $compiler->registerControlStructure(new \Picea\ControlStructure\TryCatchToken()); $compiler->registerControlStructure(new \Picea\ControlStructure\NamespaceToken()); $compiler->registerControlStructure(new \Picea\ControlStructure\UseToken()); $compiler->registerControlStructure(new \Picea\ControlStructure\IfToken());