From 51e36040746f0d40b3146fd8e72ac8acec065075 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 11:37:57 -0300 Subject: [PATCH 01/22] Chore --- composer.json | 3 +- src/Monkey.php | 153 ++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 123 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index bc332ec..8ebdd53 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ }, "require": { "php": "^8.4", - "ext-readline": "*" + "ext-readline": "*", + "symfony/console": "^7.2" }, "autoload": { "psr-4": { diff --git a/src/Monkey.php b/src/Monkey.php index d3a90d1..7549b01 100644 --- a/src/Monkey.php +++ b/src/Monkey.php @@ -12,12 +12,20 @@ use Monkey\Parser\Parser; use Monkey\Parser\ProgramParser; use RuntimeException; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; +use Symfony\Component\Console\Helper\Table; +use Symfony\Component\Console\Helper\TableStyle; +use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\Console\Output\OutputInterface; use Throwable; use function count; +use function in_array; +use function sprintf; + use const PHP_EOL; -use const STDERR; +use const STR_PAD_RIGHT; final class Monkey { @@ -25,11 +33,27 @@ final class Monkey private readonly Environment $environment; + private readonly OutputInterface $output; + private bool $debugMode = false; + private bool $showStats = false; + + private readonly float $startTime; + + private readonly int $startMemory; + public function __construct() { $this->environment = new Environment(); + $this->startTime = microtime(true); + $this->startMemory = memory_get_usage(); + + $this->output = new ConsoleOutput(); + $this->output->getFormatter()->setStyle('title', new OutputFormatterStyle('white', null, ['bold'])); + $this->output->getFormatter()->setStyle('memory', new OutputFormatterStyle('green')); + $this->output->getFormatter()->setStyle('peak', new OutputFormatterStyle('yellow')); + $this->output->getFormatter()->setStyle('time', new OutputFormatterStyle('blue')); } /** @@ -41,22 +65,111 @@ public function run(array $argv): int return $this->showHelp(); } + if (in_array('--debug', $argv)) { + $this->debugMode = true; + $argv = array_values(array_filter($argv, fn ($arg): bool => $arg !== '--debug')); + } + + if (in_array('--stats', $argv)) { + $this->showStats = true; + $argv = array_values(array_filter($argv, fn ($arg): bool => $arg !== '--stats')); + } + try { - return match ($argv[1]) { + // If we removed --debug and no other args remain, show help + if (count($argv) <= 1) { + return $this->showHelp(); + } + + $result = match ($argv[1]) { 'repl' => $this->startRepl(), 'run' => $this->runFile($argv[2] ?? null), '--version', '-v' => $this->showVersion(), '--help', '-h' => $this->showHelp(), - '--debug' => $this->enableDebugMode(), default => $this->showHelp(), }; + + if ($this->showStats) { + $this->printPerformanceStats(); + } + + return $result; } catch (Throwable $throwable) { $this->writeError($throwable->getMessage()); + if ($this->showStats) { + $this->printPerformanceStats(); + } + return 1; } } + private function printPerformanceStats(): void + { + $timeEnd = microtime(true); + $memEnd = memory_get_usage(); + $memUsed = $memEnd - $this->startMemory; + $peakMem = memory_get_peak_usage(true); + $timeTaken = $timeEnd - $this->startTime; + + $this->output->writeln(''); + $this->output->writeln(''); + $this->output->writeln('Performance Statistics'); + + $tableStyle = new TableStyle(); + $tableStyle + ->setHorizontalBorderChars('-') + ->setVerticalBorderChars('|') + ->setCrossingChars('+', '+', '+', '+', '+', '+', '+', '+', '+') + ->setPadType(STR_PAD_RIGHT); + + $table = new Table($this->output); + $table->setStyle($tableStyle); + + $table->setRows([ + ['Memory used', "{$this->formatBytes($memUsed)}"], + ['Peak memory', "{$this->formatBytes($peakMem)}"], + ['Time taken', ''], + ]); + + $table->render(); + + $this->output->writeln(''); + } + + private function writeOutput(MonkeyObject $result): void + { + // Skip output for NullObject unless in debug mode + if ($result instanceof NullObject && !$this->debugMode) { + return; + } + + if ($this->debugMode) { + $class = $result::class; + $this->output->write("{$class}: "); + } + + $this->output->writeln($result->inspect()); + } + + private function writeError(string $message): void + { + $this->output->writeln("Error: {$message}"); + } + + private function formatBytes(int $bytes): string + { + $units = ['B', 'KB', 'MB', 'GB']; + $bytes = max($bytes, 0); + $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); + $pow = min($pow, count($units) - 1); + + $bytes /= (1 << (10 * $pow)); + + return sprintf('%.2f %s', $bytes, $units[$pow]); + } + private function startRepl(): int { $this->showWelcomeBanner(); @@ -137,8 +250,11 @@ private function handleSpecialCommand(string $input): bool private function handleQuit(): bool { - echo 'Goodbye!' . PHP_EOL; + if ($this->showStats) { + $this->printPerformanceStats(); + } + echo 'Goodbye!' . PHP_EOL; exit(0); } @@ -160,7 +276,6 @@ private function handleHelp(): bool private function handleClear(): bool { system('clear'); - $this->showWelcomeBanner(); return true; @@ -169,7 +284,6 @@ private function handleClear(): bool private function handleDebugToggle(): bool { $this->debugMode = !$this->debugMode; - echo 'Debug mode: ' . ($this->debugMode ? 'Enabled' : 'Disabled') . PHP_EOL; return true; @@ -190,25 +304,6 @@ private function readInput(): string | false return readline("\nāžœ "); } - private function writeOutput(MonkeyObject $result): void - { - // Skip output for NullObject unless in debug mode - if ($result instanceof NullObject && !$this->debugMode) { - return; - } - - if ($this->debugMode) { - echo $result::class . ': '; - } - - echo $result->inspect() . PHP_EOL; - } - - private function writeError(string $message): void - { - fwrite(STDERR, 'Error: ' . $message . PHP_EOL); - } - private function showVersion(): int { echo 'Monkey Programming Language v' . self::VERSION . PHP_EOL; @@ -227,6 +322,7 @@ private function showHelp(): int --version, -v Show version information --help, -h Show this help message --debug Enable debug mode + --stats Show performance statistics Examples: monkey repl @@ -235,11 +331,4 @@ private function showHelp(): int return 0; } - - private function enableDebugMode(): int - { - $this->debugMode = true; - - return $this->startRepl(); - } } From d36cc463ba032b652e760b89813780e323a69c26 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 11:42:28 -0300 Subject: [PATCH 02/22] Chore --- src/Monkey.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Monkey.php b/src/Monkey.php index 7549b01..9336d71 100644 --- a/src/Monkey.php +++ b/src/Monkey.php @@ -13,10 +13,14 @@ use Monkey\Parser\ProgramParser; use RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatterStyle; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\TableStyle; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\Question; use Throwable; use function count; @@ -35,6 +39,10 @@ final class Monkey private readonly OutputInterface $output; + private readonly InputInterface $input; + + private readonly QuestionHelper $questionHelper; + private bool $debugMode = false; private bool $showStats = false; @@ -50,10 +58,14 @@ public function __construct() $this->startMemory = memory_get_usage(); $this->output = new ConsoleOutput(); + $this->input = new StringInput(''); + $this->questionHelper = new QuestionHelper(); + $this->output->getFormatter()->setStyle('title', new OutputFormatterStyle('white', null, ['bold'])); $this->output->getFormatter()->setStyle('memory', new OutputFormatterStyle('green')); $this->output->getFormatter()->setStyle('peak', new OutputFormatterStyle('yellow')); $this->output->getFormatter()->setStyle('time', new OutputFormatterStyle('blue')); + $this->output->getFormatter()->setStyle('prompt', new OutputFormatterStyle('cyan')); } /** @@ -175,10 +187,11 @@ private function startRepl(): int $this->showWelcomeBanner(); while (true) { + $this->output->writeln(''); // Add newline before prompt $input = $this->readInput(); if ($input === false) { - echo PHP_EOL . 'Goodbye!' . PHP_EOL; + $this->output->writeln(PHP_EOL . 'Goodbye!'); return 0; } @@ -301,7 +314,15 @@ private function showWelcomeBanner(): void private function readInput(): string | false { - return readline("\nāžœ "); + $question = new Question('āžœ '); + + try { + $answer = $this->questionHelper->ask($this->input, $this->output, $question); + + return $answer ?? false; + } catch (Throwable) { + return false; + } } private function showVersion(): int From fe045f54c8920138288891428da92331a88e6e4f Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 11:50:59 -0300 Subject: [PATCH 03/22] Chore --- src/Monkey.php | 67 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/src/Monkey.php b/src/Monkey.php index 9336d71..d845d9d 100644 --- a/src/Monkey.php +++ b/src/Monkey.php @@ -26,6 +26,8 @@ use function count; use function in_array; +use function is_scalar; + use function sprintf; use const PHP_EOL; @@ -47,15 +49,13 @@ final class Monkey private bool $showStats = false; - private readonly float $startTime; + private ?float $evalStartTime = null; - private readonly int $startMemory; + private ?int $evalStartMemory = null; public function __construct() { $this->environment = new Environment(); - $this->startTime = microtime(true); - $this->startMemory = memory_get_usage(); $this->output = new ConsoleOutput(); $this->input = new StringInput(''); @@ -117,13 +117,29 @@ public function run(array $argv): int } } + private function startPerfTracking(): void + { + $this->evalStartTime = microtime(true); + $this->evalStartMemory = memory_get_usage(); + } + + private function stopPerfTracking(): void + { + $this->evalStartTime = null; + $this->evalStartMemory = null; + } + private function printPerformanceStats(): void { + if ($this->evalStartTime === null || $this->evalStartMemory === null) { + return; + } + $timeEnd = microtime(true); $memEnd = memory_get_usage(); - $memUsed = $memEnd - $this->startMemory; + $memUsed = $memEnd - $this->evalStartMemory; $peakMem = memory_get_peak_usage(true); - $timeTaken = $timeEnd - $this->startTime; + $timeTaken = $timeEnd - $this->evalStartTime; $this->output->writeln(''); $this->output->writeln(''); @@ -148,6 +164,8 @@ private function printPerformanceStats(): void $table->render(); $this->output->writeln(''); + + $this->stopPerfTracking(); } private function writeOutput(MonkeyObject $result): void @@ -235,19 +253,32 @@ private function runFile(?string $filename): int private function evaluate(string $input): MonkeyObject { - $lexer = new Lexer($input); - $parser = new Parser($lexer); + try { + $this->startPerfTracking(); - $errors = $parser->errors(); + $lexer = new Lexer($input); + $parser = new Parser($lexer); - if ($errors !== []) { - throw new RuntimeException("Parser errors:\n" . implode("\n", $errors)); - } + $errors = $parser->errors(); - $program = new ProgramParser()($parser); - $evaluator = new Evaluator(); + if ($errors !== []) { + throw new RuntimeException("Parser errors:\n" . implode("\n", $errors)); + } + + $program = new ProgramParser()($parser); + $evaluator = new Evaluator(); + $result = $evaluator->eval($program, $this->environment); + + if ($this->showStats) { + $this->printPerformanceStats(); + } - return $evaluator->eval($program, $this->environment); + return $result; + } catch (Throwable $throwable) { + $this->stopPerfTracking(); + + throw $throwable; + } } private function handleSpecialCommand(string $input): bool @@ -319,7 +350,11 @@ private function readInput(): string | false try { $answer = $this->questionHelper->ask($this->input, $this->output, $question); - return $answer ?? false; + if (!is_scalar($answer)) { + return false; + } + + return (string)$answer; } catch (Throwable) { return false; } From 131afc4b16db6a2ce85beed4d48207178ad95454 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 12:34:45 -0300 Subject: [PATCH 04/22] Chore --- monkey | 43 +- src/Monkey.php | 390 ------------------ src/Monkey/Command/Command.php | 12 + src/Monkey/Command/CommandFactory.php | 44 ++ src/Monkey/Command/CommandRunner.php | 22 + src/Monkey/Command/HelpCommand.php | 37 ++ src/Monkey/Command/ReplCommand.php | 21 + src/Monkey/Command/RunFileCommand.php | 82 ++++ src/Monkey/Command/VersionCommand.php | 23 ++ src/Monkey/Config/Configuration.php | 30 ++ src/Monkey/Config/ConfigurationManager.php | 57 +++ .../Exceptions/MonkeyRuntimeException.php | 22 + src/Monkey/IO/ConsoleOutput.php | 11 + src/Monkey/IO/FileReader.php | 30 ++ src/Monkey/IO/InputReader.php | 40 ++ src/Monkey/IO/InputValidator.php | 37 ++ src/Monkey/IO/OutputFormatter.php | 115 ++++++ src/Monkey/Monkey.php | 40 ++ src/Monkey/Performance/PerformanceMetrics.php | 15 + src/Monkey/Performance/PerformanceTracker.php | 38 ++ src/Monkey/Repl/ReplManager.php | 233 +++++++++++ 21 files changed, 949 insertions(+), 393 deletions(-) delete mode 100644 src/Monkey.php create mode 100644 src/Monkey/Command/Command.php create mode 100644 src/Monkey/Command/CommandFactory.php create mode 100644 src/Monkey/Command/CommandRunner.php create mode 100644 src/Monkey/Command/HelpCommand.php create mode 100644 src/Monkey/Command/ReplCommand.php create mode 100644 src/Monkey/Command/RunFileCommand.php create mode 100644 src/Monkey/Command/VersionCommand.php create mode 100644 src/Monkey/Config/Configuration.php create mode 100644 src/Monkey/Config/ConfigurationManager.php create mode 100644 src/Monkey/Exceptions/MonkeyRuntimeException.php create mode 100644 src/Monkey/IO/ConsoleOutput.php create mode 100644 src/Monkey/IO/FileReader.php create mode 100644 src/Monkey/IO/InputReader.php create mode 100644 src/Monkey/IO/InputValidator.php create mode 100644 src/Monkey/IO/OutputFormatter.php create mode 100644 src/Monkey/Monkey.php create mode 100644 src/Monkey/Performance/PerformanceMetrics.php create mode 100644 src/Monkey/Performance/PerformanceTracker.php create mode 100644 src/Monkey/Repl/ReplManager.php diff --git a/monkey b/monkey index eb78a6d..d8e704b 100755 --- a/monkey +++ b/monkey @@ -5,7 +5,17 @@ declare(strict_types=1); require 'vendor/autoload.php'; -use Monkey\Monkey; +use Monkey\Monkey\Command\CommandFactory; +use Monkey\Monkey\Command\CommandRunner; +use Monkey\Monkey\Config\ConfigurationManager; +use Monkey\Monkey\IO\ConsoleOutput; +use Monkey\Monkey\IO\InputReader; +use Monkey\Monkey\IO\OutputFormatter; +use Monkey\Monkey\Monkey; +use Monkey\Monkey\Performance\PerformanceTracker; +use Monkey\Monkey\Repl\ReplManager; +use Symfony\Component\Console\Helper\QuestionHelper; +use Symfony\Component\Console\Input\ArgvInput; if (PHP_SAPI !== 'cli') { exit; @@ -15,5 +25,32 @@ if (!isset($GLOBALS['argv']) || !is_array($GLOBALS['argv'])) { exit(1); } -$cli = new Monkey(); -exit($cli->run($GLOBALS['argv'])); +try { + $input = new ArgvInput(); + $output = new ConsoleOutput(); + $questionHelper = new QuestionHelper(); + + $outputFormatter = new OutputFormatter($output); + $inputReader = new InputReader($input, $output, $questionHelper); + $performanceTracker = new PerformanceTracker(); + $replManager = new ReplManager( + $inputReader, + $outputFormatter, + $performanceTracker + ); + + $commandFactory = new CommandFactory( + //$inputReader, + $outputFormatter, + $performanceTracker, + $replManager + ); + $commandRunner = new CommandRunner($commandFactory); + $configManager = new ConfigurationManager(); + + $monkey = new Monkey($commandRunner, $configManager); + exit($monkey->run($GLOBALS['argv'])); +} catch (Throwable $e) { + fwrite(STDERR, "Fatal error: {$e->getMessage()}\n"); + exit(1); +} diff --git a/src/Monkey.php b/src/Monkey.php deleted file mode 100644 index d845d9d..0000000 --- a/src/Monkey.php +++ /dev/null @@ -1,390 +0,0 @@ -environment = new Environment(); - - $this->output = new ConsoleOutput(); - $this->input = new StringInput(''); - $this->questionHelper = new QuestionHelper(); - - $this->output->getFormatter()->setStyle('title', new OutputFormatterStyle('white', null, ['bold'])); - $this->output->getFormatter()->setStyle('memory', new OutputFormatterStyle('green')); - $this->output->getFormatter()->setStyle('peak', new OutputFormatterStyle('yellow')); - $this->output->getFormatter()->setStyle('time', new OutputFormatterStyle('blue')); - $this->output->getFormatter()->setStyle('prompt', new OutputFormatterStyle('cyan')); - } - - /** - * @param array $argv - */ - public function run(array $argv): int - { - if (count($argv) <= 1) { - return $this->showHelp(); - } - - if (in_array('--debug', $argv)) { - $this->debugMode = true; - $argv = array_values(array_filter($argv, fn ($arg): bool => $arg !== '--debug')); - } - - if (in_array('--stats', $argv)) { - $this->showStats = true; - $argv = array_values(array_filter($argv, fn ($arg): bool => $arg !== '--stats')); - } - - try { - // If we removed --debug and no other args remain, show help - if (count($argv) <= 1) { - return $this->showHelp(); - } - - $result = match ($argv[1]) { - 'repl' => $this->startRepl(), - 'run' => $this->runFile($argv[2] ?? null), - '--version', '-v' => $this->showVersion(), - '--help', '-h' => $this->showHelp(), - default => $this->showHelp(), - }; - - if ($this->showStats) { - $this->printPerformanceStats(); - } - - return $result; - } catch (Throwable $throwable) { - $this->writeError($throwable->getMessage()); - - if ($this->showStats) { - $this->printPerformanceStats(); - } - - return 1; - } - } - - private function startPerfTracking(): void - { - $this->evalStartTime = microtime(true); - $this->evalStartMemory = memory_get_usage(); - } - - private function stopPerfTracking(): void - { - $this->evalStartTime = null; - $this->evalStartMemory = null; - } - - private function printPerformanceStats(): void - { - if ($this->evalStartTime === null || $this->evalStartMemory === null) { - return; - } - - $timeEnd = microtime(true); - $memEnd = memory_get_usage(); - $memUsed = $memEnd - $this->evalStartMemory; - $peakMem = memory_get_peak_usage(true); - $timeTaken = $timeEnd - $this->evalStartTime; - - $this->output->writeln(''); - $this->output->writeln(''); - $this->output->writeln('Performance Statistics'); - - $tableStyle = new TableStyle(); - $tableStyle - ->setHorizontalBorderChars('-') - ->setVerticalBorderChars('|') - ->setCrossingChars('+', '+', '+', '+', '+', '+', '+', '+', '+') - ->setPadType(STR_PAD_RIGHT); - - $table = new Table($this->output); - $table->setStyle($tableStyle); - - $table->setRows([ - ['Memory used', "{$this->formatBytes($memUsed)}"], - ['Peak memory', "{$this->formatBytes($peakMem)}"], - ['Time taken', ''], - ]); - - $table->render(); - - $this->output->writeln(''); - - $this->stopPerfTracking(); - } - - private function writeOutput(MonkeyObject $result): void - { - // Skip output for NullObject unless in debug mode - if ($result instanceof NullObject && !$this->debugMode) { - return; - } - - if ($this->debugMode) { - $class = $result::class; - $this->output->write("{$class}: "); - } - - $this->output->writeln($result->inspect()); - } - - private function writeError(string $message): void - { - $this->output->writeln("Error: {$message}"); - } - - private function formatBytes(int $bytes): string - { - $units = ['B', 'KB', 'MB', 'GB']; - $bytes = max($bytes, 0); - $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); - $pow = min($pow, count($units) - 1); - - $bytes /= (1 << (10 * $pow)); - - return sprintf('%.2f %s', $bytes, $units[$pow]); - } - - private function startRepl(): int - { - $this->showWelcomeBanner(); - - while (true) { - $this->output->writeln(''); // Add newline before prompt - $input = $this->readInput(); - - if ($input === false) { - $this->output->writeln(PHP_EOL . 'Goodbye!'); - - return 0; - } - - if (trim($input) === '') { - continue; - } - - if ($this->handleSpecialCommand($input)) { - continue; - } - - try { - $this->writeOutput($this->evaluate($input)); - } catch (Throwable $e) { - $this->writeError($e->getMessage()); - } - } - } - - private function runFile(?string $filename): int - { - if ($filename === null) { - throw new RuntimeException('No input file specified'); - } - - if (!file_exists($filename)) { - throw new RuntimeException("File not found: {$filename}"); - } - - $contents = file_get_contents($filename); - - if ($contents === false) { - throw new RuntimeException("Could not read file: {$filename}"); - } - - $this->writeOutput($this->evaluate($contents)); - - return 0; - } - - private function evaluate(string $input): MonkeyObject - { - try { - $this->startPerfTracking(); - - $lexer = new Lexer($input); - $parser = new Parser($lexer); - - $errors = $parser->errors(); - - if ($errors !== []) { - throw new RuntimeException("Parser errors:\n" . implode("\n", $errors)); - } - - $program = new ProgramParser()($parser); - $evaluator = new Evaluator(); - $result = $evaluator->eval($program, $this->environment); - - if ($this->showStats) { - $this->printPerformanceStats(); - } - - return $result; - } catch (Throwable $throwable) { - $this->stopPerfTracking(); - - throw $throwable; - } - } - - private function handleSpecialCommand(string $input): bool - { - return match (trim($input)) { - ':q', ':quit', 'exit' => $this->handleQuit(), - ':h', ':help' => $this->handleHelp(), - ':c', ':clear' => $this->handleClear(), - ':d', ':debug' => $this->handleDebugToggle(), - default => false, - }; - } - - private function handleQuit(): bool - { - if ($this->showStats) { - $this->printPerformanceStats(); - } - - echo 'Goodbye!' . PHP_EOL; - exit(0); - } - - private function handleHelp(): bool - { - echo <<showWelcomeBanner(); - - return true; - } - - private function handleDebugToggle(): bool - { - $this->debugMode = !$this->debugMode; - echo 'Debug mode: ' . ($this->debugMode ? 'Enabled' : 'Disabled') . PHP_EOL; - - return true; - } - - private function showWelcomeBanner(): void - { - $version = self::VERSION; - - echo <<āžœ '); - - try { - $answer = $this->questionHelper->ask($this->input, $this->output, $question); - - if (!is_scalar($answer)) { - return false; - } - - return (string)$answer; - } catch (Throwable) { - return false; - } - } - - private function showVersion(): int - { - echo 'Monkey Programming Language v' . self::VERSION . PHP_EOL; - - return 0; - } - - private function showHelp(): int - { - echo << Execute a Monkey source file - --version, -v Show version information - --help, -h Show this help message - --debug Enable debug mode - --stats Show performance statistics - - Examples: - monkey repl - monkey run example.monkey - HELP . PHP_EOL; - - return 0; - } -} diff --git a/src/Monkey/Command/Command.php b/src/Monkey/Command/Command.php new file mode 100644 index 0000000..1d2b68a --- /dev/null +++ b/src/Monkey/Command/Command.php @@ -0,0 +1,12 @@ +registerCommands(); + } + + public function create(string $commandName): Command + { + if (!isset($this->commands[$commandName])) { + throw new RuntimeException("Unknown command: {$commandName}"); + } + + return $this->commands[$commandName]; + } + + private function registerCommands(): void + { + $this->commands = [ + 'repl' => new ReplCommand($this->replManager, $this->outputFormatter), + 'run' => new RunFileCommand($this->outputFormatter, $this->performanceTracker), + '--help' => new HelpCommand($this->outputFormatter), + '-h' => new HelpCommand($this->outputFormatter), + '--version' => new VersionCommand($this->outputFormatter), + '-v' => new VersionCommand($this->outputFormatter), + ]; + } +} diff --git a/src/Monkey/Command/CommandRunner.php b/src/Monkey/Command/CommandRunner.php new file mode 100644 index 0000000..fc5e38e --- /dev/null +++ b/src/Monkey/Command/CommandRunner.php @@ -0,0 +1,22 @@ +commandFactory->create($config->command); + + return $command->execute($config); + } +} diff --git a/src/Monkey/Command/HelpCommand.php b/src/Monkey/Command/HelpCommand.php new file mode 100644 index 0000000..47d5e38 --- /dev/null +++ b/src/Monkey/Command/HelpCommand.php @@ -0,0 +1,37 @@ +outputFormatter->write(<< Execute a Monkey source file + --version, -v Show version information + --help, -h Show this help message + --debug Enable debug mode + --stats Show performance statistics + + Examples: + monkey repl + monkey run example.monkey + HELP); + + return 0; + } +} diff --git a/src/Monkey/Command/ReplCommand.php b/src/Monkey/Command/ReplCommand.php new file mode 100644 index 0000000..7e86a80 --- /dev/null +++ b/src/Monkey/Command/ReplCommand.php @@ -0,0 +1,21 @@ +replManager->start($config); + } +} diff --git a/src/Monkey/Command/RunFileCommand.php b/src/Monkey/Command/RunFileCommand.php new file mode 100644 index 0000000..2cbda0c --- /dev/null +++ b/src/Monkey/Command/RunFileCommand.php @@ -0,0 +1,82 @@ +getFilename(); + + if ($filename === null) { + throw new RuntimeException('No input file specified'); + } + + if (!file_exists($filename)) { + throw new RuntimeException("File not found: {$filename}"); + } + + $contents = file_get_contents($filename); + + if ($contents === false) { + throw new RuntimeException("Could not read file: {$filename}"); + } + + if ($config->hasStats()) { + $this->performanceTracker->start(); + } + + try { + $result = $this->evaluateCode($contents); + $this->outputFormatter->writeOutput($result, $config->hasDebug()); + + if ($config->hasStats()) { + $metrics = $this->performanceTracker->stop(); + $this->outputFormatter->writePerformanceStats($metrics); + } + + return 0; + } catch (Throwable $throwable) { + $this->outputFormatter->writeError($throwable->getMessage()); + + return 1; + } + } + + private function evaluateCode(string $contents): MonkeyObject + { + $lexer = new Lexer($contents); + $parser = new Parser($lexer); + + if ($parser->errors() !== []) { + throw new RuntimeException( + "Parser errors:\n" . implode("\n", $parser->errors()), + ); + } + + $program = new ProgramParser()($parser); + $evaluator = new Evaluator(); + + return $evaluator->eval($program, new Environment()); + } +} diff --git a/src/Monkey/Command/VersionCommand.php b/src/Monkey/Command/VersionCommand.php new file mode 100644 index 0000000..da7d795 --- /dev/null +++ b/src/Monkey/Command/VersionCommand.php @@ -0,0 +1,23 @@ +outputFormatter->write('Monkey Programming Language v 1.0'); + + return 0; + } +} diff --git a/src/Monkey/Config/Configuration.php b/src/Monkey/Config/Configuration.php new file mode 100644 index 0000000..80deea7 --- /dev/null +++ b/src/Monkey/Config/Configuration.php @@ -0,0 +1,30 @@ +options['debug']); + } + + public function hasStats(): bool + { + return isset($this->options['stats']); + } + + public function getFilename(): ?string + { + return $this->arguments[0] ?? null; + } +} diff --git a/src/Monkey/Config/ConfigurationManager.php b/src/Monkey/Config/ConfigurationManager.php new file mode 100644 index 0000000..e5c7e80 --- /dev/null +++ b/src/Monkey/Config/ConfigurationManager.php @@ -0,0 +1,57 @@ + $arg) { + if ($index === 0) { + continue; + } // Skip script name + + if (str_starts_with((string)$arg, '--')) { + if (!in_array($arg, self::VALID_OPTIONS)) { + throw new RuntimeException("Invalid option: {$arg}"); + } + + $options[trim((string)$arg, '-')] = true; + } elseif ($command === '') { + if (!in_array($arg, self::VALID_COMMANDS)) { + throw new RuntimeException("Invalid command: {$arg}"); + } + + $command = $arg; + } else { + $arguments[] = $arg; + } + } + + // If no command was found after processing options + if ($command === '') { + $command = '--help'; + } + + return new Configuration($command, $options, $arguments); + } +} diff --git a/src/Monkey/Exceptions/MonkeyRuntimeException.php b/src/Monkey/Exceptions/MonkeyRuntimeException.php new file mode 100644 index 0000000..e761f03 --- /dev/null +++ b/src/Monkey/Exceptions/MonkeyRuntimeException.php @@ -0,0 +1,22 @@ +{$prompt} "); + + try { + $answer = $this->questionHelper->ask($this->input, $this->output, $question); + + if (!is_scalar($answer)) { + return false; + } + + return (string)$answer; + } catch (Throwable) { + return false; + } + } +} diff --git a/src/Monkey/IO/InputValidator.php b/src/Monkey/IO/InputValidator.php new file mode 100644 index 0000000..b3b492a --- /dev/null +++ b/src/Monkey/IO/InputValidator.php @@ -0,0 +1,37 @@ + $maxLength) { + throw new MonkeyRuntimeException( + sprintf('Input exceeds maximum length of %d characters', $maxLength), + ); + } + } + + public function validatePattern(string $input, string $pattern): void + { + if (in_array(preg_match($pattern, $input), [0, false], true)) { + throw new MonkeyRuntimeException('Input format is invalid'); + } + } +} diff --git a/src/Monkey/IO/OutputFormatter.php b/src/Monkey/IO/OutputFormatter.php new file mode 100644 index 0000000..c95d8c2 --- /dev/null +++ b/src/Monkey/IO/OutputFormatter.php @@ -0,0 +1,115 @@ +configureStyles(); + } + + public function writeOutput(MonkeyObject $result, bool $debug = false): void + { + // Skip output for NullObject unless in debug mode + if ($result instanceof NullObject && !$debug) { + return; + } + + if ($debug) { + $class = $result::class; + $this->output->write("{$class}: "); + } + + $this->output->writeln($result->inspect()); + } + + public function writeError(string $message): void + { + $this->output->writeln("Error: {$message}"); + } + + public function write(string $message): void + { + $this->output->writeln($message); + } + + public function writePerformanceStats(PerformanceMetrics $metrics): void + { + $this->output->writeln(''); + $this->output->writeln(''); + $this->output->writeln('Performance Statistics'); + + $tableStyle = new TableStyle(); + $tableStyle + ->setHorizontalBorderChars('-') + ->setVerticalBorderChars('|') + ->setCrossingChars('+', '+', '+', '+', '+', '+', '+', '+', '+') + ->setPadType(STR_PAD_RIGHT); + + $table = new Table($this->output); + $table->setStyle($tableStyle); + + $table->setRows([ + ['Memory used', "{$this->formatBytes($metrics->memoryUsed)}"], + ['Peak memory', "{$this->formatBytes($metrics->peakMemory)}"], + ['Time taken', ''], + ]); + + $table->render(); + + $this->output->writeln(''); + } + + private function configureStyles(): void + { + $this->output->getFormatter()->setStyle( + 'title', + new OutputFormatterStyle('white', null, ['bold']), + ); + $this->output->getFormatter()->setStyle( + 'memory', + new OutputFormatterStyle('green'), + ); + $this->output->getFormatter()->setStyle( + 'peak', + new OutputFormatterStyle('yellow'), + ); + $this->output->getFormatter()->setStyle( + 'time', + new OutputFormatterStyle('blue'), + ); + $this->output->getFormatter()->setStyle( + 'prompt', + new OutputFormatterStyle('cyan'), + ); + } + + private function formatBytes(int $bytes): string + { + $units = ['B', 'KB', 'MB', 'GB']; + $bytes = max($bytes, 0); + $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); + $pow = min($pow, count($units) - 1); + + $bytes /= (1 << (10 * $pow)); + + return sprintf('%.2f %s', $bytes, $units[$pow]); + } +} diff --git a/src/Monkey/Monkey.php b/src/Monkey/Monkey.php new file mode 100644 index 0000000..a5e30e1 --- /dev/null +++ b/src/Monkey/Monkey.php @@ -0,0 +1,40 @@ +configManager->parseArguments($argv); + + return $this->commandRunner->execute($config); + } catch (Throwable $throwable) { + fwrite(STDERR, "Error: {$throwable->getMessage()}\n"); + + return 1; + } + } +} diff --git a/src/Monkey/Performance/PerformanceMetrics.php b/src/Monkey/Performance/PerformanceMetrics.php new file mode 100644 index 0000000..cc4d613 --- /dev/null +++ b/src/Monkey/Performance/PerformanceMetrics.php @@ -0,0 +1,15 @@ +startTime = microtime(true); + $this->startMemory = memory_get_usage(); + } + + public function stop(): PerformanceMetrics + { + if ($this->startTime === null || $this->startMemory === null) { + throw new RuntimeException('Performance tracking not started'); + } + + $metrics = new PerformanceMetrics( + timeElapsed: microtime(true) - $this->startTime, + memoryUsed: memory_get_usage() - $this->startMemory, + peakMemory: memory_get_peak_usage(true), + ); + + $this->startTime = null; + $this->startMemory = null; + + return $metrics; + } +} diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php new file mode 100644 index 0000000..2806cc8 --- /dev/null +++ b/src/Monkey/Repl/ReplManager.php @@ -0,0 +1,233 @@ + 'handleQuit', + ':quit' => 'handleQuit', + 'exit' => 'handleQuit', + ':h' => 'handleHelp', + ':help' => 'handleHelp', + ':c' => 'handleClear', + ':clear' => 'handleClear', + ':d' => 'handleDebugToggle', + ':debug' => 'handleDebugToggle', + ':r' => 'handleResetEnvironment', + ':reset' => 'handleResetEnvironment', + ]; + + private bool $debugMode = false; + + private bool $running = true; + + public function __construct( + private readonly InputReader $inputReader, + private readonly OutputFormatter $outputFormatter, + private readonly PerformanceTracker $performanceTracker, + private Environment $environment = new Environment(), + private readonly Evaluator $evaluator = new Evaluator(), + ) { + } + + public function start(Configuration $config): int + { + try { + $this->debugMode = $config->hasDebug(); + $this->showWelcomeBanner(); + + while ($this->running) { + $this->outputFormatter->write(''); // Add newline before prompt + $input = $this->inputReader->readLine(); + + if ($input === false) { + $this->outputFormatter->write("\nGoodbye!"); + + return 0; + } + + if (trim($input) === '') { + continue; + } + + if ($this->handleSpecialCommand($input)) { + continue; + } + + try { + $this->evaluateAndOutput($input, $config); + } catch (MonkeyRuntimeException $e) { + $this->outputFormatter->writeError($e->getMessage()); + } catch (Throwable $e) { + $this->outputFormatter->writeError("Unexpected error: {$e->getMessage()}"); + + if ($this->debugMode) { + $this->outputFormatter->write($e->getTraceAsString()); + } + } + } + + return 0; + } catch (Throwable $throwable) { + $this->outputFormatter->writeError("Fatal error: {$throwable->getMessage()}"); + + if ($this->debugMode) { + $this->outputFormatter->write($throwable->getTraceAsString()); + } + + return 1; + } + } + + public function isDebugMode(): bool + { + return $this->debugMode; + } + + public function getEnvironment(): Environment + { + return $this->environment; + } + + private function evaluateAndOutput(string $input, Configuration $config): void + { + if ($config->hasStats()) { + $this->performanceTracker->start(); + } + + $result = $this->evaluate($input); + $this->outputFormatter->writeOutput($result, $this->debugMode); + + if ($config->hasStats()) { + $metrics = $this->performanceTracker->stop(); + $this->outputFormatter->writePerformanceStats($metrics); + } + } + + private function evaluate(string $input): MonkeyObject + { + $lexer = new Lexer($input); + $parser = new Parser($lexer); + + $errors = $parser->errors(); + + if ($errors !== []) { + throw new MonkeyRuntimeException( + "Parser errors:\n" . implode("\n", $errors), + ); + } + + $program = (new ProgramParser())($parser); + + return $this->evaluator->eval($program, $this->environment); + } + + private function handleSpecialCommand(string $input): bool + { + $trimmedInput = trim($input); + + if (isset(self::SPECIAL_COMMANDS[$trimmedInput])) { + $method = self::SPECIAL_COMMANDS[$trimmedInput]; + + return $this->{$method}(); + } + + return false; + } + + private function handleQuit(): bool + { + $this->running = false; + $this->outputFormatter->write('Goodbye!'); + + return true; + } + + private function handleHelp(): bool + { + $this->outputFormatter->write(<<showWelcomeBanner(); + + return true; + } + + private function handleDebugToggle(): bool + { + $this->debugMode = !$this->debugMode; + $this->outputFormatter->write( + 'Debug mode: ' . ($this->debugMode ? 'Enabled' : 'Disabled'), + ); + + return true; + } + + private function handleResetEnvironment(): bool + { + $this->environment = new Environment(); + $this->outputFormatter->write('Environment has been reset'); + + return true; + } + + private function showWelcomeBanner(): void + { + $this->outputFormatter->write(<<outputFormatter->write(''); + } +} From 5f80cd0de36d8899b7dd41d2c22646305f9df81a Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 12:36:23 -0300 Subject: [PATCH 05/22] Namespace --- composer.json | 2 +- monkey | 18 ++--- src/Ast/Expressions/BinaryExpression.php | 6 +- src/Ast/Expressions/CallExpression.php | 6 +- src/Ast/Expressions/Expression.php | 4 +- src/Ast/Expressions/IdentifierExpression.php | 4 +- src/Ast/Expressions/IfExpression.php | 8 +- src/Ast/Expressions/IndexExpression.php | 6 +- src/Ast/Expressions/PostfixExpression.php | 6 +- src/Ast/Expressions/UnaryExpression.php | 6 +- src/Ast/Expressions/WhileExpression.php | 8 +- src/Ast/Node.php | 2 +- src/Ast/Program.php | 6 +- src/Ast/Statements/AssignStatement.php | 10 +-- src/Ast/Statements/BlockStatement.php | 8 +- src/Ast/Statements/ExpressionStatement.php | 6 +- src/Ast/Statements/LetStatement.php | 10 +-- src/Ast/Statements/ReturnStatement.php | 10 +-- src/Ast/Statements/Statement.php | 4 +- src/Ast/Types/ArrayLiteral.php | 8 +- src/Ast/Types/BooleanLiteral.php | 6 +- src/Ast/Types/FloatLiteral.php | 6 +- src/Ast/Types/FunctionLiteral.php | 12 +-- src/Ast/Types/IntegerLiteral.php | 6 +- src/Ast/Types/StringLiteral.php | 6 +- src/Evaluator/Builtin/EvalBuiltinFunction.php | 6 +- src/Evaluator/Builtin/EvalFirstFunction.php | 10 +-- src/Evaluator/Builtin/EvalLastFunction.php | 10 +-- src/Evaluator/Builtin/EvalLenFunction.php | 12 +-- src/Evaluator/Builtin/EvalMapFunction.php | 12 +-- src/Evaluator/Builtin/EvalPushFunction.php | 8 +- src/Evaluator/Builtin/EvalPutsFunction.php | 8 +- src/Evaluator/Builtin/EvalSliceFunction.php | 12 +-- src/Evaluator/BuiltinFunction.php | 6 +- src/Evaluator/Environment.php | 4 +- src/Evaluator/EvalArrayBinaryExpression.php | 8 +- src/Evaluator/EvalArrayLiteral.php | 10 +-- src/Evaluator/EvalAssingStatement.php | 8 +- src/Evaluator/EvalBinaryExpression.php | 18 ++--- src/Evaluator/EvalBlockStatement.php | 12 +-- src/Evaluator/EvalCallExpression.php | 16 ++-- src/Evaluator/EvalIdentifier.php | 8 +- src/Evaluator/EvalIfExpression.php | 12 +-- src/Evaluator/EvalIndexExpression.php | 16 ++-- src/Evaluator/EvalLetStatement.php | 8 +- .../EvalMinusUnaryOperatorExpression.php | 8 +- src/Evaluator/EvalNotOperatorExpression.php | 8 +- src/Evaluator/EvalNumericBinaryExpression.php | 8 +- src/Evaluator/EvalPostfixExpression.php | 10 +-- src/Evaluator/EvalProgram.php | 12 +-- src/Evaluator/EvalReturnStatement.php | 10 +-- src/Evaluator/EvalStringBinaryExpression.php | 10 +-- src/Evaluator/EvalUnaryExpression.php | 6 +- src/Evaluator/EvalWhileExpression.php | 10 +-- src/Evaluator/Evaluator.php | 76 +++++++++---------- src/Lexer/Char.php | 2 +- src/Lexer/Input.php | 2 +- src/Lexer/Lexer.php | 6 +- src/Monkey/Command/Command.php | 4 +- src/Monkey/Command/CommandFactory.php | 8 +- src/Monkey/Command/CommandRunner.php | 4 +- src/Monkey/Command/HelpCommand.php | 6 +- src/Monkey/Command/ReplCommand.php | 6 +- src/Monkey/Command/RunFileCommand.php | 22 +++--- src/Monkey/Command/VersionCommand.php | 6 +- src/Monkey/Config/Configuration.php | 2 +- src/Monkey/Config/ConfigurationManager.php | 2 +- .../Exceptions/MonkeyRuntimeException.php | 2 +- src/Monkey/IO/ConsoleOutput.php | 2 +- src/Monkey/IO/FileReader.php | 4 +- src/Monkey/IO/InputReader.php | 2 +- src/Monkey/IO/InputValidator.php | 4 +- src/Monkey/IO/OutputFormatter.php | 8 +- src/Monkey/Monkey.php | 6 +- src/Monkey/Performance/PerformanceMetrics.php | 2 +- src/Monkey/Performance/PerformanceTracker.php | 2 +- src/Monkey/Repl/ReplManager.php | 26 +++---- src/Object/ArrayObject.php | 2 +- src/Object/BooleanObject.php | 2 +- src/Object/BuiltinFunctionObject.php | 2 +- src/Object/ErrorObject.php | 2 +- src/Object/FloatObject.php | 2 +- src/Object/FunctionObject.php | 8 +- src/Object/IntegerObject.php | 2 +- src/Object/MonkeyObject.php | 2 +- src/Object/MonkeyObjectType.php | 2 +- src/Object/NullObject.php | 2 +- src/Object/ReturnValueObject.php | 2 +- src/Object/StringObject.php | 2 +- src/Parser/ExpressionListParser.php | 6 +- src/Parser/FunctionParametersParser.php | 6 +- src/Parser/Parselet/ArrayParselet.php | 12 +-- .../Parselet/BinaryOperatorParselet.php | 8 +- .../Parselet/CallExpressionParselet.php | 12 +-- .../Parselet/FunctionLiteralParselet.php | 16 ++-- .../Parselet/GroupedExpressionParselet.php | 10 +-- src/Parser/Parselet/IdentifierParselet.php | 8 +- src/Parser/Parselet/IfExpressionParselet.php | 16 ++-- .../Parselet/IndexExpressionParselet.php | 12 +-- src/Parser/Parselet/InfixParselet.php | 4 +- .../Parselet/PostfixOperatorParselet.php | 8 +- src/Parser/Parselet/PostfixParselet.php | 4 +- src/Parser/Parselet/PrefixParselet.php | 4 +- src/Parser/Parselet/ScalarParselet.php | 16 ++-- src/Parser/Parselet/UnaryOperatorParselet.php | 10 +-- .../Parselet/WhileExpressionParselet.php | 16 ++-- src/Parser/Parser.php | 42 +++++----- src/Parser/Precedence.php | 2 +- src/Parser/ProgramParser.php | 10 +-- .../Statements/AssignStatementParser.php | 16 ++-- .../Statements/BlockStatementParser.php | 10 +-- .../Statements/ExpressionStatementParser.php | 12 +-- src/Parser/Statements/LetStatementParser.php | 16 ++-- .../Statements/ReturnStatementParser.php | 12 +-- src/Parser/Statements/StatementParser.php | 8 +- src/Support/StringBuilder.php | 2 +- src/Token/Token.php | 2 +- src/Token/TokenType.php | 6 +- tests/AstTest.php | 12 +-- tests/EvaluatorTest.php | 20 ++--- tests/Helpers.php | 20 ++--- tests/LexerTest.php | 4 +- tests/ParserTest.php | 36 ++++----- 123 files changed, 546 insertions(+), 546 deletions(-) diff --git a/composer.json b/composer.json index 8ebdd53..c5a0142 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ }, "autoload": { "psr-4": { - "Monkey\\": "src" + "MonkeyLang\\": "src" } }, "autoload-dev": { diff --git a/monkey b/monkey index d8e704b..11f4a97 100755 --- a/monkey +++ b/monkey @@ -5,15 +5,15 @@ declare(strict_types=1); require 'vendor/autoload.php'; -use Monkey\Monkey\Command\CommandFactory; -use Monkey\Monkey\Command\CommandRunner; -use Monkey\Monkey\Config\ConfigurationManager; -use Monkey\Monkey\IO\ConsoleOutput; -use Monkey\Monkey\IO\InputReader; -use Monkey\Monkey\IO\OutputFormatter; -use Monkey\Monkey\Monkey; -use Monkey\Monkey\Performance\PerformanceTracker; -use Monkey\Monkey\Repl\ReplManager; +use MonkeyLang\Monkey\Command\CommandFactory; +use MonkeyLang\Monkey\Command\CommandRunner; +use MonkeyLang\Monkey\Config\ConfigurationManager; +use MonkeyLang\Monkey\IO\ConsoleOutput; +use MonkeyLang\Monkey\IO\InputReader; +use MonkeyLang\Monkey\IO\OutputFormatter; +use MonkeyLang\Monkey\Monkey; +use MonkeyLang\Monkey\Performance\PerformanceTracker; +use MonkeyLang\Monkey\Repl\ReplManager; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\ArgvInput; diff --git a/src/Ast/Expressions/BinaryExpression.php b/src/Ast/Expressions/BinaryExpression.php index 606ada0..6ca0f8f 100644 --- a/src/Ast/Expressions/BinaryExpression.php +++ b/src/Ast/Expressions/BinaryExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Expressions; +namespace MonkeyLang\Ast\Expressions; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class BinaryExpression extends Expression { diff --git a/src/Ast/Expressions/CallExpression.php b/src/Ast/Expressions/CallExpression.php index bc7a42f..ad619fa 100644 --- a/src/Ast/Expressions/CallExpression.php +++ b/src/Ast/Expressions/CallExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Expressions; +namespace MonkeyLang\Ast\Expressions; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; use function count; diff --git a/src/Ast/Expressions/Expression.php b/src/Ast/Expressions/Expression.php index 0c95382..b95f7e7 100644 --- a/src/Ast/Expressions/Expression.php +++ b/src/Ast/Expressions/Expression.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Ast\Expressions; +namespace MonkeyLang\Ast\Expressions; -use Monkey\Ast\Node; +use MonkeyLang\Ast\Node; abstract class Expression extends Node { diff --git a/src/Ast/Expressions/IdentifierExpression.php b/src/Ast/Expressions/IdentifierExpression.php index 1fde759..aba00c2 100644 --- a/src/Ast/Expressions/IdentifierExpression.php +++ b/src/Ast/Expressions/IdentifierExpression.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Ast\Expressions; +namespace MonkeyLang\Ast\Expressions; -use Monkey\Token\Token; +use MonkeyLang\Token\Token; final class IdentifierExpression extends Expression { diff --git a/src/Ast/Expressions/IfExpression.php b/src/Ast/Expressions/IfExpression.php index 6cbee49..0619338 100644 --- a/src/Ast/Expressions/IfExpression.php +++ b/src/Ast/Expressions/IfExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Ast\Expressions; +namespace MonkeyLang\Ast\Expressions; -use Monkey\Ast\Statements\BlockStatement; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Ast\Statements\BlockStatement; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class IfExpression extends Expression { diff --git a/src/Ast/Expressions/IndexExpression.php b/src/Ast/Expressions/IndexExpression.php index 0103042..8ee8bdb 100644 --- a/src/Ast/Expressions/IndexExpression.php +++ b/src/Ast/Expressions/IndexExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Expressions; +namespace MonkeyLang\Ast\Expressions; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class IndexExpression extends Expression { diff --git a/src/Ast/Expressions/PostfixExpression.php b/src/Ast/Expressions/PostfixExpression.php index 1013baf..f06d938 100644 --- a/src/Ast/Expressions/PostfixExpression.php +++ b/src/Ast/Expressions/PostfixExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Expressions; +namespace MonkeyLang\Ast\Expressions; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class PostfixExpression extends Expression { diff --git a/src/Ast/Expressions/UnaryExpression.php b/src/Ast/Expressions/UnaryExpression.php index 160725c..0243e9f 100644 --- a/src/Ast/Expressions/UnaryExpression.php +++ b/src/Ast/Expressions/UnaryExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Expressions; +namespace MonkeyLang\Ast\Expressions; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class UnaryExpression extends Expression { diff --git a/src/Ast/Expressions/WhileExpression.php b/src/Ast/Expressions/WhileExpression.php index da01e47..dee2e7d 100644 --- a/src/Ast/Expressions/WhileExpression.php +++ b/src/Ast/Expressions/WhileExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Ast\Expressions; +namespace MonkeyLang\Ast\Expressions; -use Monkey\Ast\Statements\BlockStatement; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Ast\Statements\BlockStatement; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class WhileExpression extends Expression { diff --git a/src/Ast/Node.php b/src/Ast/Node.php index 4034f65..a3290c5 100644 --- a/src/Ast/Node.php +++ b/src/Ast/Node.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Ast; +namespace MonkeyLang\Ast; use Stringable; diff --git a/src/Ast/Program.php b/src/Ast/Program.php index c189859..f8c0fad 100644 --- a/src/Ast/Program.php +++ b/src/Ast/Program.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Ast; +namespace MonkeyLang\Ast; -use Monkey\Ast\Statements\Statement; +use MonkeyLang\Ast\Statements\Statement; -use Monkey\Support\StringBuilder; +use MonkeyLang\Support\StringBuilder; use function count; diff --git a/src/Ast/Statements/AssignStatement.php b/src/Ast/Statements/AssignStatement.php index d98a1cf..6439b22 100644 --- a/src/Ast/Statements/AssignStatement.php +++ b/src/Ast/Statements/AssignStatement.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Ast\Statements; +namespace MonkeyLang\Ast\Statements; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class AssignStatement extends Statement { diff --git a/src/Ast/Statements/BlockStatement.php b/src/Ast/Statements/BlockStatement.php index 3638227..e50095f 100644 --- a/src/Ast/Statements/BlockStatement.php +++ b/src/Ast/Statements/BlockStatement.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Ast\Statements; +namespace MonkeyLang\Ast\Statements; -namespace Monkey\Ast\Statements; +namespace MonkeyLang\Ast\Statements; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class BlockStatement extends Statement { diff --git a/src/Ast/Statements/ExpressionStatement.php b/src/Ast/Statements/ExpressionStatement.php index b2054a8..b893277 100644 --- a/src/Ast/Statements/ExpressionStatement.php +++ b/src/Ast/Statements/ExpressionStatement.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Statements; +namespace MonkeyLang\Ast\Statements; -use Monkey\Ast\Expressions\Expression; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Token\Token; final class ExpressionStatement extends Statement { diff --git a/src/Ast/Statements/LetStatement.php b/src/Ast/Statements/LetStatement.php index b385491..be5c5bf 100644 --- a/src/Ast/Statements/LetStatement.php +++ b/src/Ast/Statements/LetStatement.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Ast\Statements; +namespace MonkeyLang\Ast\Statements; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class LetStatement extends Statement { diff --git a/src/Ast/Statements/ReturnStatement.php b/src/Ast/Statements/ReturnStatement.php index be0eef8..a3c70e6 100644 --- a/src/Ast/Statements/ReturnStatement.php +++ b/src/Ast/Statements/ReturnStatement.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Ast\Statements; +namespace MonkeyLang\Ast\Statements; -namespace Monkey\Ast\Statements; +namespace MonkeyLang\Ast\Statements; -use Monkey\Ast\Expressions\Expression; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; final class ReturnStatement extends Statement { diff --git a/src/Ast/Statements/Statement.php b/src/Ast/Statements/Statement.php index ef010f1..6d753d5 100644 --- a/src/Ast/Statements/Statement.php +++ b/src/Ast/Statements/Statement.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Ast\Statements; +namespace MonkeyLang\Ast\Statements; -use Monkey\Ast\Node; +use MonkeyLang\Ast\Node; abstract class Statement extends Node { diff --git a/src/Ast/Types/ArrayLiteral.php b/src/Ast/Types/ArrayLiteral.php index 7ad7f0d..93d4748 100644 --- a/src/Ast/Types/ArrayLiteral.php +++ b/src/Ast/Types/ArrayLiteral.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Ast\Types; +namespace MonkeyLang\Ast\Types; -use Monkey\Ast\Expressions\Expression; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; use function count; diff --git a/src/Ast/Types/BooleanLiteral.php b/src/Ast/Types/BooleanLiteral.php index e603226..9e2aed2 100644 --- a/src/Ast/Types/BooleanLiteral.php +++ b/src/Ast/Types/BooleanLiteral.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Types; +namespace MonkeyLang\Ast\Types; -use Monkey\Ast\Expressions\Expression; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Token\Token; final class BooleanLiteral extends Expression { diff --git a/src/Ast/Types/FloatLiteral.php b/src/Ast/Types/FloatLiteral.php index 8350a0a..31102ae 100644 --- a/src/Ast/Types/FloatLiteral.php +++ b/src/Ast/Types/FloatLiteral.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Types; +namespace MonkeyLang\Ast\Types; -use Monkey\Ast\Expressions\Expression; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Token\Token; final class FloatLiteral extends Expression { diff --git a/src/Ast/Types/FunctionLiteral.php b/src/Ast/Types/FunctionLiteral.php index 6e15721..184f1a6 100644 --- a/src/Ast/Types/FunctionLiteral.php +++ b/src/Ast/Types/FunctionLiteral.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Ast\Types; +namespace MonkeyLang\Ast\Types; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Ast\Statements\BlockStatement; -use Monkey\Support\StringBuilder; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Ast\Statements\BlockStatement; +use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Token\Token; use function count; diff --git a/src/Ast/Types/IntegerLiteral.php b/src/Ast/Types/IntegerLiteral.php index 3ee392c..ef4e84e 100644 --- a/src/Ast/Types/IntegerLiteral.php +++ b/src/Ast/Types/IntegerLiteral.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Types; +namespace MonkeyLang\Ast\Types; -use Monkey\Ast\Expressions\Expression; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Token\Token; final class IntegerLiteral extends Expression { diff --git a/src/Ast/Types/StringLiteral.php b/src/Ast/Types/StringLiteral.php index 12f1c6a..825c533 100644 --- a/src/Ast/Types/StringLiteral.php +++ b/src/Ast/Types/StringLiteral.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Ast\Types; +namespace MonkeyLang\Ast\Types; -use Monkey\Ast\Expressions\Expression; -use Monkey\Token\Token; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Token\Token; final class StringLiteral extends Expression { diff --git a/src/Evaluator/Builtin/EvalBuiltinFunction.php b/src/Evaluator/Builtin/EvalBuiltinFunction.php index ca364fb..ebfab33 100644 --- a/src/Evaluator/Builtin/EvalBuiltinFunction.php +++ b/src/Evaluator/Builtin/EvalBuiltinFunction.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Evaluator\Builtin; +namespace MonkeyLang\Evaluator\Builtin; -use Monkey\Evaluator\Evaluator; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Evaluator\Evaluator; +use MonkeyLang\Object\MonkeyObject; abstract readonly class EvalBuiltinFunction { diff --git a/src/Evaluator/Builtin/EvalFirstFunction.php b/src/Evaluator/Builtin/EvalFirstFunction.php index 799766c..0359df3 100644 --- a/src/Evaluator/Builtin/EvalFirstFunction.php +++ b/src/Evaluator/Builtin/EvalFirstFunction.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Evaluator\Builtin; +namespace MonkeyLang\Evaluator\Builtin; -use Monkey\Object\ArrayObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; use function count; diff --git a/src/Evaluator/Builtin/EvalLastFunction.php b/src/Evaluator/Builtin/EvalLastFunction.php index d2663d9..208b1f5 100644 --- a/src/Evaluator/Builtin/EvalLastFunction.php +++ b/src/Evaluator/Builtin/EvalLastFunction.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Evaluator\Builtin; +namespace MonkeyLang\Evaluator\Builtin; -use Monkey\Object\ArrayObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; use function count; diff --git a/src/Evaluator/Builtin/EvalLenFunction.php b/src/Evaluator/Builtin/EvalLenFunction.php index fd7de98..b506833 100644 --- a/src/Evaluator/Builtin/EvalLenFunction.php +++ b/src/Evaluator/Builtin/EvalLenFunction.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Evaluator\Builtin; +namespace MonkeyLang\Evaluator\Builtin; -use Monkey\Object\ArrayObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\IntegerObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\StringObject; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\IntegerObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\StringObject; use function count; diff --git a/src/Evaluator/Builtin/EvalMapFunction.php b/src/Evaluator/Builtin/EvalMapFunction.php index 330afa8..24241e2 100644 --- a/src/Evaluator/Builtin/EvalMapFunction.php +++ b/src/Evaluator/Builtin/EvalMapFunction.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Evaluator\Builtin; +namespace MonkeyLang\Evaluator\Builtin; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Object\ArrayObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\FunctionObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\FunctionObject; +use MonkeyLang\Object\MonkeyObject; use function count; diff --git a/src/Evaluator/Builtin/EvalPushFunction.php b/src/Evaluator/Builtin/EvalPushFunction.php index d63baa2..7d38c1a 100644 --- a/src/Evaluator/Builtin/EvalPushFunction.php +++ b/src/Evaluator/Builtin/EvalPushFunction.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator\Builtin; +namespace MonkeyLang\Evaluator\Builtin; -use Monkey\Object\ArrayObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; use function count; diff --git a/src/Evaluator/Builtin/EvalPutsFunction.php b/src/Evaluator/Builtin/EvalPutsFunction.php index becf514..b2580e0 100644 --- a/src/Evaluator/Builtin/EvalPutsFunction.php +++ b/src/Evaluator/Builtin/EvalPutsFunction.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator\Builtin; +namespace MonkeyLang\Evaluator\Builtin; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; use function count; diff --git a/src/Evaluator/Builtin/EvalSliceFunction.php b/src/Evaluator/Builtin/EvalSliceFunction.php index 48c5a4d..58dac80 100644 --- a/src/Evaluator/Builtin/EvalSliceFunction.php +++ b/src/Evaluator/Builtin/EvalSliceFunction.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Evaluator\Builtin; +namespace MonkeyLang\Evaluator\Builtin; -use Monkey\Object\ArrayObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\IntegerObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\StringObject; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\IntegerObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\StringObject; use function array_slice; use function count; diff --git a/src/Evaluator/BuiltinFunction.php b/src/Evaluator/BuiltinFunction.php index 00e0d6a..40abace 100644 --- a/src/Evaluator/BuiltinFunction.php +++ b/src/Evaluator/BuiltinFunction.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; use Closure; -use Monkey\Object\BuiltinFunctionObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Object\BuiltinFunctionObject; +use MonkeyLang\Object\MonkeyObject; final class BuiltinFunction { diff --git a/src/Evaluator/Environment.php b/src/Evaluator/Environment.php index 4a03aa7..8397798 100644 --- a/src/Evaluator/Environment.php +++ b/src/Evaluator/Environment.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Object\MonkeyObject; final class Environment { diff --git a/src/Evaluator/EvalArrayBinaryExpression.php b/src/Evaluator/EvalArrayBinaryExpression.php index 68bf03e..9e092ba 100644 --- a/src/Evaluator/EvalArrayBinaryExpression.php +++ b/src/Evaluator/EvalArrayBinaryExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Object\ArrayObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; final class EvalArrayBinaryExpression { diff --git a/src/Evaluator/EvalArrayLiteral.php b/src/Evaluator/EvalArrayLiteral.php index 0372f39..da1db64 100644 --- a/src/Evaluator/EvalArrayLiteral.php +++ b/src/Evaluator/EvalArrayLiteral.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Types\ArrayLiteral; -use Monkey\Object\ArrayObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Ast\Types\ArrayLiteral; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; use function count; diff --git a/src/Evaluator/EvalAssingStatement.php b/src/Evaluator/EvalAssingStatement.php index 4b289b5..9677758 100644 --- a/src/Evaluator/EvalAssingStatement.php +++ b/src/Evaluator/EvalAssingStatement.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Statements\AssignStatement; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Ast\Statements\AssignStatement; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; final readonly class EvalAssingStatement { diff --git a/src/Evaluator/EvalBinaryExpression.php b/src/Evaluator/EvalBinaryExpression.php index 1dd3b01..29a251c 100644 --- a/src/Evaluator/EvalBinaryExpression.php +++ b/src/Evaluator/EvalBinaryExpression.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Monkey\Evaluator; - -use Monkey\Object\ArrayObject; -use Monkey\Object\BooleanObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\FloatObject; -use Monkey\Object\IntegerObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\StringObject; +namespace MonkeyLang\Evaluator; + +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\BooleanObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\FloatObject; +use MonkeyLang\Object\IntegerObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\StringObject; final class EvalBinaryExpression { diff --git a/src/Evaluator/EvalBlockStatement.php b/src/Evaluator/EvalBlockStatement.php index 726a1ab..2bc4b0d 100644 --- a/src/Evaluator/EvalBlockStatement.php +++ b/src/Evaluator/EvalBlockStatement.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Statements\BlockStatement; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; -use Monkey\Object\ReturnValueObject; +use MonkeyLang\Ast\Statements\BlockStatement; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; +use MonkeyLang\Object\ReturnValueObject; final readonly class EvalBlockStatement { diff --git a/src/Evaluator/EvalCallExpression.php b/src/Evaluator/EvalCallExpression.php index 4632f10..53e5f8c 100644 --- a/src/Evaluator/EvalCallExpression.php +++ b/src/Evaluator/EvalCallExpression.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Monkey\Evaluator; - -use Monkey\Ast\Expressions\CallExpression; -use Monkey\Object\BuiltinFunctionObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\FunctionObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\ReturnValueObject; +namespace MonkeyLang\Evaluator; + +use MonkeyLang\Ast\Expressions\CallExpression; +use MonkeyLang\Object\BuiltinFunctionObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\FunctionObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\ReturnValueObject; use function call_user_func; use function count; diff --git a/src/Evaluator/EvalIdentifier.php b/src/Evaluator/EvalIdentifier.php index 90fda02..080d4b0 100644 --- a/src/Evaluator/EvalIdentifier.php +++ b/src/Evaluator/EvalIdentifier.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; final readonly class EvalIdentifier { diff --git a/src/Evaluator/EvalIfExpression.php b/src/Evaluator/EvalIfExpression.php index 67f1429..370ddb2 100644 --- a/src/Evaluator/EvalIfExpression.php +++ b/src/Evaluator/EvalIfExpression.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Expressions\IfExpression; -use Monkey\Ast\Statements\BlockStatement; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; +use MonkeyLang\Ast\Expressions\IfExpression; +use MonkeyLang\Ast\Statements\BlockStatement; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; final readonly class EvalIfExpression { diff --git a/src/Evaluator/EvalIndexExpression.php b/src/Evaluator/EvalIndexExpression.php index bbe3269..402236a 100644 --- a/src/Evaluator/EvalIndexExpression.php +++ b/src/Evaluator/EvalIndexExpression.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Monkey\Evaluator; - -use Monkey\Ast\Expressions\IndexExpression; -use Monkey\Object\ArrayObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\IntegerObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; +namespace MonkeyLang\Evaluator; + +use MonkeyLang\Ast\Expressions\IndexExpression; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\IntegerObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; final readonly class EvalIndexExpression { diff --git a/src/Evaluator/EvalLetStatement.php b/src/Evaluator/EvalLetStatement.php index 74f8365..7437fec 100644 --- a/src/Evaluator/EvalLetStatement.php +++ b/src/Evaluator/EvalLetStatement.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Statements\LetStatement; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Ast\Statements\LetStatement; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; final readonly class EvalLetStatement { diff --git a/src/Evaluator/EvalMinusUnaryOperatorExpression.php b/src/Evaluator/EvalMinusUnaryOperatorExpression.php index b81cbac..2abb607 100644 --- a/src/Evaluator/EvalMinusUnaryOperatorExpression.php +++ b/src/Evaluator/EvalMinusUnaryOperatorExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Object\ErrorObject; -use Monkey\Object\IntegerObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\IntegerObject; +use MonkeyLang\Object\MonkeyObject; final class EvalMinusUnaryOperatorExpression { diff --git a/src/Evaluator/EvalNotOperatorExpression.php b/src/Evaluator/EvalNotOperatorExpression.php index 3f11695..46743b8 100644 --- a/src/Evaluator/EvalNotOperatorExpression.php +++ b/src/Evaluator/EvalNotOperatorExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Object\BooleanObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; +use MonkeyLang\Object\BooleanObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; final class EvalNotOperatorExpression { diff --git a/src/Evaluator/EvalNumericBinaryExpression.php b/src/Evaluator/EvalNumericBinaryExpression.php index e04d366..5b53000 100644 --- a/src/Evaluator/EvalNumericBinaryExpression.php +++ b/src/Evaluator/EvalNumericBinaryExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Object\BooleanObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Object\BooleanObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; final class EvalNumericBinaryExpression { diff --git a/src/Evaluator/EvalPostfixExpression.php b/src/Evaluator/EvalPostfixExpression.php index 4cebe18..f022174 100644 --- a/src/Evaluator/EvalPostfixExpression.php +++ b/src/Evaluator/EvalPostfixExpression.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Expressions\PostfixExpression; -use Monkey\Object\ErrorObject; -use Monkey\Object\IntegerObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Ast\Expressions\PostfixExpression; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\IntegerObject; +use MonkeyLang\Object\MonkeyObject; final readonly class EvalPostfixExpression { diff --git a/src/Evaluator/EvalProgram.php b/src/Evaluator/EvalProgram.php index 253e8a7..b1d4854 100644 --- a/src/Evaluator/EvalProgram.php +++ b/src/Evaluator/EvalProgram.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Program; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; -use Monkey\Object\ReturnValueObject; +use MonkeyLang\Ast\Program; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; +use MonkeyLang\Object\ReturnValueObject; final readonly class EvalProgram { diff --git a/src/Evaluator/EvalReturnStatement.php b/src/Evaluator/EvalReturnStatement.php index 5d6a4c2..75fd6f3 100644 --- a/src/Evaluator/EvalReturnStatement.php +++ b/src/Evaluator/EvalReturnStatement.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Statements\ReturnStatement; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\ReturnValueObject; +use MonkeyLang\Ast\Statements\ReturnStatement; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\ReturnValueObject; final readonly class EvalReturnStatement { diff --git a/src/Evaluator/EvalStringBinaryExpression.php b/src/Evaluator/EvalStringBinaryExpression.php index c8610c2..a667893 100644 --- a/src/Evaluator/EvalStringBinaryExpression.php +++ b/src/Evaluator/EvalStringBinaryExpression.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Object\BooleanObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\StringObject; +use MonkeyLang\Object\BooleanObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\StringObject; final class EvalStringBinaryExpression { diff --git a/src/Evaluator/EvalUnaryExpression.php b/src/Evaluator/EvalUnaryExpression.php index 26bb673..5a01ce9 100644 --- a/src/Evaluator/EvalUnaryExpression.php +++ b/src/Evaluator/EvalUnaryExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; final class EvalUnaryExpression { diff --git a/src/Evaluator/EvalWhileExpression.php b/src/Evaluator/EvalWhileExpression.php index 264a860..0042895 100644 --- a/src/Evaluator/EvalWhileExpression.php +++ b/src/Evaluator/EvalWhileExpression.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Expressions\WhileExpression; -use Monkey\Object\BooleanObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\MonkeyObject; +use MonkeyLang\Ast\Expressions\WhileExpression; +use MonkeyLang\Object\BooleanObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\MonkeyObject; final readonly class EvalWhileExpression { diff --git a/src/Evaluator/Evaluator.php b/src/Evaluator/Evaluator.php index 161e580..0f72e55 100644 --- a/src/Evaluator/Evaluator.php +++ b/src/Evaluator/Evaluator.php @@ -2,45 +2,45 @@ declare(strict_types=1); -namespace Monkey\Evaluator; +namespace MonkeyLang\Evaluator; -use Monkey\Ast\Expressions\BinaryExpression; -use Monkey\Ast\Expressions\CallExpression; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Ast\Expressions\IfExpression; -use Monkey\Ast\Expressions\IndexExpression; -use Monkey\Ast\Expressions\PostfixExpression; -use Monkey\Ast\Expressions\UnaryExpression; -use Monkey\Ast\Expressions\WhileExpression; -use Monkey\Ast\Node; -use Monkey\Ast\Program; -use Monkey\Ast\Statements\AssignStatement; -use Monkey\Ast\Statements\BlockStatement; -use Monkey\Ast\Statements\ExpressionStatement; -use Monkey\Ast\Statements\LetStatement; -use Monkey\Ast\Statements\ReturnStatement; -use Monkey\Ast\Types\ArrayLiteral; -use Monkey\Ast\Types\BooleanLiteral; -use Monkey\Ast\Types\FloatLiteral; -use Monkey\Ast\Types\FunctionLiteral; -use Monkey\Ast\Types\IntegerLiteral; -use Monkey\Ast\Types\StringLiteral; -use Monkey\Evaluator\Builtin\EvalFirstFunction; -use Monkey\Evaluator\Builtin\EvalLastFunction; -use Monkey\Evaluator\Builtin\EvalLenFunction; -use Monkey\Evaluator\Builtin\EvalMapFunction; -use Monkey\Evaluator\Builtin\EvalPushFunction; -use Monkey\Evaluator\Builtin\EvalPutsFunction; -use Monkey\Evaluator\Builtin\EvalSliceFunction; -use Monkey\Object\BooleanObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\FloatObject; -use Monkey\Object\FunctionObject; -use Monkey\Object\IntegerObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; -use Monkey\Object\StringObject; +use MonkeyLang\Ast\Expressions\BinaryExpression; +use MonkeyLang\Ast\Expressions\CallExpression; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Ast\Expressions\IfExpression; +use MonkeyLang\Ast\Expressions\IndexExpression; +use MonkeyLang\Ast\Expressions\PostfixExpression; +use MonkeyLang\Ast\Expressions\UnaryExpression; +use MonkeyLang\Ast\Expressions\WhileExpression; +use MonkeyLang\Ast\Node; +use MonkeyLang\Ast\Program; +use MonkeyLang\Ast\Statements\AssignStatement; +use MonkeyLang\Ast\Statements\BlockStatement; +use MonkeyLang\Ast\Statements\ExpressionStatement; +use MonkeyLang\Ast\Statements\LetStatement; +use MonkeyLang\Ast\Statements\ReturnStatement; +use MonkeyLang\Ast\Types\ArrayLiteral; +use MonkeyLang\Ast\Types\BooleanLiteral; +use MonkeyLang\Ast\Types\FloatLiteral; +use MonkeyLang\Ast\Types\FunctionLiteral; +use MonkeyLang\Ast\Types\IntegerLiteral; +use MonkeyLang\Ast\Types\StringLiteral; +use MonkeyLang\Evaluator\Builtin\EvalFirstFunction; +use MonkeyLang\Evaluator\Builtin\EvalLastFunction; +use MonkeyLang\Evaluator\Builtin\EvalLenFunction; +use MonkeyLang\Evaluator\Builtin\EvalMapFunction; +use MonkeyLang\Evaluator\Builtin\EvalPushFunction; +use MonkeyLang\Evaluator\Builtin\EvalPutsFunction; +use MonkeyLang\Evaluator\Builtin\EvalSliceFunction; +use MonkeyLang\Object\BooleanObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\FloatObject; +use MonkeyLang\Object\FunctionObject; +use MonkeyLang\Object\IntegerObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; +use MonkeyLang\Object\StringObject; use function call_user_func; diff --git a/src/Lexer/Char.php b/src/Lexer/Char.php index 33c480c..3022b87 100644 --- a/src/Lexer/Char.php +++ b/src/Lexer/Char.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Lexer; +namespace MonkeyLang\Lexer; use Stringable; diff --git a/src/Lexer/Input.php b/src/Lexer/Input.php index 02795b8..a9a6d37 100644 --- a/src/Lexer/Input.php +++ b/src/Lexer/Input.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Lexer; +namespace MonkeyLang\Lexer; final class Input { diff --git a/src/Lexer/Lexer.php b/src/Lexer/Lexer.php index d4616c3..57ba799 100644 --- a/src/Lexer/Lexer.php +++ b/src/Lexer/Lexer.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Lexer; +namespace MonkeyLang\Lexer; -use Monkey\Token\Token; -use Monkey\Token\TokenType; +use MonkeyLang\Token\Token; +use MonkeyLang\Token\TokenType; final class Lexer { diff --git a/src/Monkey/Command/Command.php b/src/Monkey/Command/Command.php index 1d2b68a..5b8ab39 100644 --- a/src/Monkey/Command/Command.php +++ b/src/Monkey/Command/Command.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Monkey\Command; +namespace MonkeyLang\Monkey\Command; -use Monkey\Monkey\Config\Configuration; +use MonkeyLang\Monkey\Config\Configuration; interface Command { diff --git a/src/Monkey/Command/CommandFactory.php b/src/Monkey/Command/CommandFactory.php index e5b630b..fa72b52 100644 --- a/src/Monkey/Command/CommandFactory.php +++ b/src/Monkey/Command/CommandFactory.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Monkey\Command; +namespace MonkeyLang\Monkey\Command; -use Monkey\Monkey\IO\OutputFormatter; -use Monkey\Monkey\Performance\PerformanceTracker; -use Monkey\Monkey\Repl\ReplManager; +use MonkeyLang\Monkey\IO\OutputFormatter; +use MonkeyLang\Monkey\Performance\PerformanceTracker; +use MonkeyLang\Monkey\Repl\ReplManager; use RuntimeException; final class CommandFactory diff --git a/src/Monkey/Command/CommandRunner.php b/src/Monkey/Command/CommandRunner.php index fc5e38e..509f590 100644 --- a/src/Monkey/Command/CommandRunner.php +++ b/src/Monkey/Command/CommandRunner.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Monkey\Command; +namespace MonkeyLang\Monkey\Command; -use Monkey\Monkey\Config\Configuration; +use MonkeyLang\Monkey\Config\Configuration; final readonly class CommandRunner { diff --git a/src/Monkey/Command/HelpCommand.php b/src/Monkey/Command/HelpCommand.php index 47d5e38..aa34caf 100644 --- a/src/Monkey/Command/HelpCommand.php +++ b/src/Monkey/Command/HelpCommand.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Monkey\Command; +namespace MonkeyLang\Monkey\Command; -use Monkey\Monkey\Config\Configuration; -use Monkey\Monkey\IO\OutputFormatter; +use MonkeyLang\Monkey\Config\Configuration; +use MonkeyLang\Monkey\IO\OutputFormatter; final readonly class HelpCommand implements Command { diff --git a/src/Monkey/Command/ReplCommand.php b/src/Monkey/Command/ReplCommand.php index 7e86a80..4cc2a98 100644 --- a/src/Monkey/Command/ReplCommand.php +++ b/src/Monkey/Command/ReplCommand.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Monkey\Command; +namespace MonkeyLang\Monkey\Command; -use Monkey\Monkey\Config\Configuration; -use Monkey\Monkey\Repl\ReplManager; +use MonkeyLang\Monkey\Config\Configuration; +use MonkeyLang\Monkey\Repl\ReplManager; final readonly class ReplCommand implements Command { diff --git a/src/Monkey/Command/RunFileCommand.php b/src/Monkey/Command/RunFileCommand.php index 2cbda0c..dc68017 100644 --- a/src/Monkey/Command/RunFileCommand.php +++ b/src/Monkey/Command/RunFileCommand.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace Monkey\Monkey\Command; - -use Monkey\Evaluator\Environment; -use Monkey\Evaluator\Evaluator; -use Monkey\Lexer\Lexer; -use Monkey\Monkey\Config\Configuration; -use Monkey\Monkey\IO\OutputFormatter; -use Monkey\Monkey\Performance\PerformanceTracker; -use Monkey\Object\MonkeyObject; -use Monkey\Parser\Parser; -use Monkey\Parser\ProgramParser; +namespace MonkeyLang\Monkey\Command; + +use MonkeyLang\Evaluator\Environment; +use MonkeyLang\Evaluator\Evaluator; +use MonkeyLang\Lexer\Lexer; +use MonkeyLang\Monkey\Config\Configuration; +use MonkeyLang\Monkey\IO\OutputFormatter; +use MonkeyLang\Monkey\Performance\PerformanceTracker; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\ProgramParser; use RuntimeException; use Throwable; diff --git a/src/Monkey/Command/VersionCommand.php b/src/Monkey/Command/VersionCommand.php index da7d795..ba06153 100644 --- a/src/Monkey/Command/VersionCommand.php +++ b/src/Monkey/Command/VersionCommand.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Monkey\Command; +namespace MonkeyLang\Monkey\Command; -use Monkey\Monkey\Config\Configuration; -use Monkey\Monkey\IO\OutputFormatter; +use MonkeyLang\Monkey\Config\Configuration; +use MonkeyLang\Monkey\IO\OutputFormatter; final readonly class VersionCommand implements Command { diff --git a/src/Monkey/Config/Configuration.php b/src/Monkey/Config/Configuration.php index 80deea7..56eabe7 100644 --- a/src/Monkey/Config/Configuration.php +++ b/src/Monkey/Config/Configuration.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Monkey\Config; +namespace MonkeyLang\Monkey\Config; final readonly class Configuration { diff --git a/src/Monkey/Config/ConfigurationManager.php b/src/Monkey/Config/ConfigurationManager.php index e5c7e80..5f1d835 100644 --- a/src/Monkey/Config/ConfigurationManager.php +++ b/src/Monkey/Config/ConfigurationManager.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Monkey\Config; +namespace MonkeyLang\Monkey\Config; use RuntimeException; diff --git a/src/Monkey/Exceptions/MonkeyRuntimeException.php b/src/Monkey/Exceptions/MonkeyRuntimeException.php index e761f03..c579522 100644 --- a/src/Monkey/Exceptions/MonkeyRuntimeException.php +++ b/src/Monkey/Exceptions/MonkeyRuntimeException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Monkey\Exceptions; +namespace MonkeyLang\Monkey\Exceptions; use RuntimeException; diff --git a/src/Monkey/IO/ConsoleOutput.php b/src/Monkey/IO/ConsoleOutput.php index 023c0a2..882f1d7 100644 --- a/src/Monkey/IO/ConsoleOutput.php +++ b/src/Monkey/IO/ConsoleOutput.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Monkey\IO; +namespace MonkeyLang\Monkey\IO; use Symfony\Component\Console\Output\ConsoleOutput as SymfonyConsoleOutput; diff --git a/src/Monkey/IO/FileReader.php b/src/Monkey/IO/FileReader.php index 840d17d..baee9dc 100644 --- a/src/Monkey/IO/FileReader.php +++ b/src/Monkey/IO/FileReader.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Monkey\IO; +namespace MonkeyLang\Monkey\IO; -use Monkey\Monkey\Exceptions\MonkeyRuntimeException; +use MonkeyLang\Monkey\Exceptions\MonkeyRuntimeException; final class FileReader { diff --git a/src/Monkey/IO/InputReader.php b/src/Monkey/IO/InputReader.php index 52a21c7..ff3452b 100644 --- a/src/Monkey/IO/InputReader.php +++ b/src/Monkey/IO/InputReader.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Monkey\IO; +namespace MonkeyLang\Monkey\IO; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Monkey/IO/InputValidator.php b/src/Monkey/IO/InputValidator.php index b3b492a..e9b5c46 100644 --- a/src/Monkey/IO/InputValidator.php +++ b/src/Monkey/IO/InputValidator.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Monkey\IO; +namespace MonkeyLang\Monkey\IO; -use Monkey\Monkey\Exceptions\MonkeyRuntimeException; +use MonkeyLang\Monkey\Exceptions\MonkeyRuntimeException; use function in_array; use function sprintf; diff --git a/src/Monkey/IO/OutputFormatter.php b/src/Monkey/IO/OutputFormatter.php index c95d8c2..9c59006 100644 --- a/src/Monkey/IO/OutputFormatter.php +++ b/src/Monkey/IO/OutputFormatter.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Monkey\IO; +namespace MonkeyLang\Monkey\IO; -use Monkey\Monkey\Performance\PerformanceMetrics; -use Monkey\Object\MonkeyObject; -use Monkey\Object\NullObject; +use MonkeyLang\Monkey\Performance\PerformanceMetrics; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\NullObject; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\TableStyle; diff --git a/src/Monkey/Monkey.php b/src/Monkey/Monkey.php index a5e30e1..a123547 100644 --- a/src/Monkey/Monkey.php +++ b/src/Monkey/Monkey.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Monkey; +namespace MonkeyLang\Monkey; -use Monkey\Monkey\Command\CommandRunner; -use Monkey\Monkey\Config\ConfigurationManager; +use MonkeyLang\Monkey\Command\CommandRunner; +use MonkeyLang\Monkey\Config\ConfigurationManager; use Throwable; use const STDERR; diff --git a/src/Monkey/Performance/PerformanceMetrics.php b/src/Monkey/Performance/PerformanceMetrics.php index cc4d613..295f8ec 100644 --- a/src/Monkey/Performance/PerformanceMetrics.php +++ b/src/Monkey/Performance/PerformanceMetrics.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Monkey\Performance; +namespace MonkeyLang\Monkey\Performance; final readonly class PerformanceMetrics { diff --git a/src/Monkey/Performance/PerformanceTracker.php b/src/Monkey/Performance/PerformanceTracker.php index 3438f11..32a242c 100644 --- a/src/Monkey/Performance/PerformanceTracker.php +++ b/src/Monkey/Performance/PerformanceTracker.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Monkey\Performance; +namespace MonkeyLang\Monkey\Performance; use RuntimeException; diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php index 2806cc8..ab44c64 100644 --- a/src/Monkey/Repl/ReplManager.php +++ b/src/Monkey/Repl/ReplManager.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace Monkey\Monkey\Repl; - -use Monkey\Evaluator\Environment; -use Monkey\Evaluator\Evaluator; -use Monkey\Lexer\Lexer; -use Monkey\Monkey\Config\Configuration; -use Monkey\Monkey\Exceptions\MonkeyRuntimeException; -use Monkey\Monkey\IO\InputReader; -use Monkey\Monkey\IO\OutputFormatter; -use Monkey\Monkey\Performance\PerformanceTracker; -use Monkey\Object\MonkeyObject; -use Monkey\Parser\Parser; -use Monkey\Parser\ProgramParser; +namespace MonkeyLang\Monkey\Repl; + +use MonkeyLang\Evaluator\Environment; +use MonkeyLang\Evaluator\Evaluator; +use MonkeyLang\Lexer\Lexer; +use MonkeyLang\Monkey\Config\Configuration; +use MonkeyLang\Monkey\Exceptions\MonkeyRuntimeException; +use MonkeyLang\Monkey\IO\InputReader; +use MonkeyLang\Monkey\IO\OutputFormatter; +use MonkeyLang\Monkey\Performance\PerformanceTracker; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\ProgramParser; use Throwable; use const PHP_OS_FAMILY; diff --git a/src/Object/ArrayObject.php b/src/Object/ArrayObject.php index 910f09c..2f5cac3 100644 --- a/src/Object/ArrayObject.php +++ b/src/Object/ArrayObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; use function count; use function sprintf; diff --git a/src/Object/BooleanObject.php b/src/Object/BooleanObject.php index b489237..79a9382 100644 --- a/src/Object/BooleanObject.php +++ b/src/Object/BooleanObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; final readonly class BooleanObject extends MonkeyObject { diff --git a/src/Object/BuiltinFunctionObject.php b/src/Object/BuiltinFunctionObject.php index 87cb2af..6d2708c 100644 --- a/src/Object/BuiltinFunctionObject.php +++ b/src/Object/BuiltinFunctionObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; use Closure; diff --git a/src/Object/ErrorObject.php b/src/Object/ErrorObject.php index 108fe88..7331a56 100644 --- a/src/Object/ErrorObject.php +++ b/src/Object/ErrorObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; use function sprintf; diff --git a/src/Object/FloatObject.php b/src/Object/FloatObject.php index b219a44..206bbcd 100644 --- a/src/Object/FloatObject.php +++ b/src/Object/FloatObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; use function sprintf; diff --git a/src/Object/FunctionObject.php b/src/Object/FunctionObject.php index fa2e0be..6aba678 100644 --- a/src/Object/FunctionObject.php +++ b/src/Object/FunctionObject.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Ast\Statements\BlockStatement; -use Monkey\Evaluator\Environment; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Ast\Statements\BlockStatement; +use MonkeyLang\Evaluator\Environment; use function sprintf; diff --git a/src/Object/IntegerObject.php b/src/Object/IntegerObject.php index 20a514c..59dbbfa 100644 --- a/src/Object/IntegerObject.php +++ b/src/Object/IntegerObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; use function sprintf; diff --git a/src/Object/MonkeyObject.php b/src/Object/MonkeyObject.php index 644bf1b..1c1954f 100644 --- a/src/Object/MonkeyObject.php +++ b/src/Object/MonkeyObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; abstract readonly class MonkeyObject { diff --git a/src/Object/MonkeyObjectType.php b/src/Object/MonkeyObjectType.php index 24804cf..867388d 100644 --- a/src/Object/MonkeyObjectType.php +++ b/src/Object/MonkeyObjectType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; enum MonkeyObjectType: int { diff --git a/src/Object/NullObject.php b/src/Object/NullObject.php index 56a85d8..fbec8f3 100644 --- a/src/Object/NullObject.php +++ b/src/Object/NullObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; final readonly class NullObject extends MonkeyObject { diff --git a/src/Object/ReturnValueObject.php b/src/Object/ReturnValueObject.php index eb1ad60..fa631f1 100644 --- a/src/Object/ReturnValueObject.php +++ b/src/Object/ReturnValueObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; final readonly class ReturnValueObject extends MonkeyObject { diff --git a/src/Object/StringObject.php b/src/Object/StringObject.php index 7dae9d3..9ebafa3 100644 --- a/src/Object/StringObject.php +++ b/src/Object/StringObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Object; +namespace MonkeyLang\Object; final readonly class StringObject extends MonkeyObject { diff --git a/src/Parser/ExpressionListParser.php b/src/Parser/ExpressionListParser.php index 0a39392..730fd94 100644 --- a/src/Parser/ExpressionListParser.php +++ b/src/Parser/ExpressionListParser.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Parser; +namespace MonkeyLang\Parser; -use Monkey\Ast\Expressions\Expression; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Token\TokenType; final class ExpressionListParser { diff --git a/src/Parser/FunctionParametersParser.php b/src/Parser/FunctionParametersParser.php index af11af3..a56783a 100644 --- a/src/Parser/FunctionParametersParser.php +++ b/src/Parser/FunctionParametersParser.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Parser; +namespace MonkeyLang\Parser; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Token\TokenType; final class FunctionParametersParser { diff --git a/src/Parser/Parselet/ArrayParselet.php b/src/Parser/Parselet/ArrayParselet.php index 0e5909f..8e5b851 100644 --- a/src/Parser/Parselet/ArrayParselet.php +++ b/src/Parser/Parselet/ArrayParselet.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Types\ArrayLiteral; -use Monkey\Parser\ExpressionListParser; -use Monkey\Parser\Parser; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Types\ArrayLiteral; +use MonkeyLang\Parser\ExpressionListParser; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Token\TokenType; final readonly class ArrayParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/BinaryOperatorParselet.php b/src/Parser/Parselet/BinaryOperatorParselet.php index 0522202..2436183 100644 --- a/src/Parser/Parselet/BinaryOperatorParselet.php +++ b/src/Parser/Parselet/BinaryOperatorParselet.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\BinaryExpression; -use Monkey\Ast\Expressions\Expression; -use Monkey\Parser\Parser; +use MonkeyLang\Ast\Expressions\BinaryExpression; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Parser\Parser; final readonly class BinaryOperatorParselet implements InfixParselet { diff --git a/src/Parser/Parselet/CallExpressionParselet.php b/src/Parser/Parselet/CallExpressionParselet.php index c4b5240..62469a0 100644 --- a/src/Parser/Parselet/CallExpressionParselet.php +++ b/src/Parser/Parselet/CallExpressionParselet.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\CallExpression; -use Monkey\Ast\Expressions\Expression; -use Monkey\Parser\ExpressionListParser; -use Monkey\Parser\Parser; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\CallExpression; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Parser\ExpressionListParser; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Token\TokenType; final readonly class CallExpressionParselet implements InfixParselet { diff --git a/src/Parser/Parselet/FunctionLiteralParselet.php b/src/Parser/Parselet/FunctionLiteralParselet.php index efe45a4..5b1e734 100644 --- a/src/Parser/Parselet/FunctionLiteralParselet.php +++ b/src/Parser/Parselet/FunctionLiteralParselet.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; - -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Types\FunctionLiteral; -use Monkey\Parser\FunctionParametersParser; -use Monkey\Parser\Parser; -use Monkey\Parser\Statements\BlockStatementParser; -use Monkey\Token\TokenType; +namespace MonkeyLang\Parser\Parselet; + +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Types\FunctionLiteral; +use MonkeyLang\Parser\FunctionParametersParser; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Statements\BlockStatementParser; +use MonkeyLang\Token\TokenType; final readonly class FunctionLiteralParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/GroupedExpressionParselet.php b/src/Parser/Parselet/GroupedExpressionParselet.php index 979d1da..0a7e0bf 100644 --- a/src/Parser/Parselet/GroupedExpressionParselet.php +++ b/src/Parser/Parselet/GroupedExpressionParselet.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\Expression; -use Monkey\Parser\Parser; -use Monkey\Parser\Precedence; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Precedence; +use MonkeyLang\Token\TokenType; final readonly class GroupedExpressionParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/IdentifierParselet.php b/src/Parser/Parselet/IdentifierParselet.php index 5327fa0..101562d 100644 --- a/src/Parser/Parselet/IdentifierParselet.php +++ b/src/Parser/Parselet/IdentifierParselet.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Parser\Parser; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Parser\Parser; final readonly class IdentifierParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/IfExpressionParselet.php b/src/Parser/Parselet/IfExpressionParselet.php index 1892e88..3210176 100644 --- a/src/Parser/Parselet/IfExpressionParselet.php +++ b/src/Parser/Parselet/IfExpressionParselet.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; - -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\IfExpression; -use Monkey\Parser\Parser; -use Monkey\Parser\Precedence; -use Monkey\Parser\Statements\BlockStatementParser; -use Monkey\Token\TokenType; +namespace MonkeyLang\Parser\Parselet; + +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\IfExpression; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Precedence; +use MonkeyLang\Parser\Statements\BlockStatementParser; +use MonkeyLang\Token\TokenType; final readonly class IfExpressionParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/IndexExpressionParselet.php b/src/Parser/Parselet/IndexExpressionParselet.php index 49eaf47..70e544c 100644 --- a/src/Parser/Parselet/IndexExpressionParselet.php +++ b/src/Parser/Parselet/IndexExpressionParselet.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\IndexExpression; -use Monkey\Parser\Parser; -use Monkey\Parser\Precedence; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\IndexExpression; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Precedence; +use MonkeyLang\Token\TokenType; final readonly class IndexExpressionParselet implements InfixParselet { diff --git a/src/Parser/Parselet/InfixParselet.php b/src/Parser/Parselet/InfixParselet.php index 47270a7..ed723a6 100644 --- a/src/Parser/Parselet/InfixParselet.php +++ b/src/Parser/Parselet/InfixParselet.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\Expression; interface InfixParselet { diff --git a/src/Parser/Parselet/PostfixOperatorParselet.php b/src/Parser/Parselet/PostfixOperatorParselet.php index e3482a1..4a900ca 100644 --- a/src/Parser/Parselet/PostfixOperatorParselet.php +++ b/src/Parser/Parselet/PostfixOperatorParselet.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\PostfixExpression; -use Monkey\Parser\Parser; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\PostfixExpression; +use MonkeyLang\Parser\Parser; final readonly class PostfixOperatorParselet implements PostfixParselet { diff --git a/src/Parser/Parselet/PostfixParselet.php b/src/Parser/Parselet/PostfixParselet.php index 268cb7f..151830c 100644 --- a/src/Parser/Parselet/PostfixParselet.php +++ b/src/Parser/Parselet/PostfixParselet.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\Expression; interface PostfixParselet { diff --git a/src/Parser/Parselet/PrefixParselet.php b/src/Parser/Parselet/PrefixParselet.php index 6cf005c..66c661a 100644 --- a/src/Parser/Parselet/PrefixParselet.php +++ b/src/Parser/Parselet/PrefixParselet.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\Expression; interface PrefixParselet { diff --git a/src/Parser/Parselet/ScalarParselet.php b/src/Parser/Parselet/ScalarParselet.php index b2de936..4a12258 100644 --- a/src/Parser/Parselet/ScalarParselet.php +++ b/src/Parser/Parselet/ScalarParselet.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; use InvalidArgumentException; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Types\BooleanLiteral; -use Monkey\Ast\Types\FloatLiteral; -use Monkey\Ast\Types\IntegerLiteral; -use Monkey\Ast\Types\StringLiteral; -use Monkey\Parser\Parser; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Types\BooleanLiteral; +use MonkeyLang\Ast\Types\FloatLiteral; +use MonkeyLang\Ast\Types\IntegerLiteral; +use MonkeyLang\Ast\Types\StringLiteral; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Token\TokenType; final class ScalarParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/UnaryOperatorParselet.php b/src/Parser/Parselet/UnaryOperatorParselet.php index 1baf23a..ed69bc8 100644 --- a/src/Parser/Parselet/UnaryOperatorParselet.php +++ b/src/Parser/Parselet/UnaryOperatorParselet.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; +namespace MonkeyLang\Parser\Parselet; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\UnaryExpression; -use Monkey\Parser\Parser; -use Monkey\Parser\Precedence; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\UnaryExpression; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Precedence; final readonly class UnaryOperatorParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/WhileExpressionParselet.php b/src/Parser/Parselet/WhileExpressionParselet.php index 3033a9f..f8255f4 100644 --- a/src/Parser/Parselet/WhileExpressionParselet.php +++ b/src/Parser/Parselet/WhileExpressionParselet.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Monkey\Parser\Parselet; - -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\WhileExpression; -use Monkey\Parser\Parser; -use Monkey\Parser\Precedence; -use Monkey\Parser\Statements\BlockStatementParser; -use Monkey\Token\TokenType; +namespace MonkeyLang\Parser\Parselet; + +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\WhileExpression; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Precedence; +use MonkeyLang\Parser\Statements\BlockStatementParser; +use MonkeyLang\Token\TokenType; final readonly class WhileExpressionParselet implements PrefixParselet { diff --git a/src/Parser/Parser.php b/src/Parser/Parser.php index bf9cb48..76e2173 100644 --- a/src/Parser/Parser.php +++ b/src/Parser/Parser.php @@ -2,27 +2,27 @@ declare(strict_types=1); -namespace Monkey\Parser; - -use Monkey\Ast\Expressions\Expression; -use Monkey\Lexer\Lexer; -use Monkey\Parser\Parselet\ArrayParselet; -use Monkey\Parser\Parselet\BinaryOperatorParselet; -use Monkey\Parser\Parselet\CallExpressionParselet; -use Monkey\Parser\Parselet\FunctionLiteralParselet; -use Monkey\Parser\Parselet\GroupedExpressionParselet; -use Monkey\Parser\Parselet\IdentifierParselet; -use Monkey\Parser\Parselet\IfExpressionParselet; -use Monkey\Parser\Parselet\IndexExpressionParselet; -use Monkey\Parser\Parselet\InfixParselet; -use Monkey\Parser\Parselet\PostfixOperatorParselet; -use Monkey\Parser\Parselet\PostfixParselet; -use Monkey\Parser\Parselet\PrefixParselet; -use Monkey\Parser\Parselet\ScalarParselet; -use Monkey\Parser\Parselet\UnaryOperatorParselet; -use Monkey\Parser\Parselet\WhileExpressionParselet; -use Monkey\Token\Token; -use Monkey\Token\TokenType; +namespace MonkeyLang\Parser; + +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Lexer\Lexer; +use MonkeyLang\Parser\Parselet\ArrayParselet; +use MonkeyLang\Parser\Parselet\BinaryOperatorParselet; +use MonkeyLang\Parser\Parselet\CallExpressionParselet; +use MonkeyLang\Parser\Parselet\FunctionLiteralParselet; +use MonkeyLang\Parser\Parselet\GroupedExpressionParselet; +use MonkeyLang\Parser\Parselet\IdentifierParselet; +use MonkeyLang\Parser\Parselet\IfExpressionParselet; +use MonkeyLang\Parser\Parselet\IndexExpressionParselet; +use MonkeyLang\Parser\Parselet\InfixParselet; +use MonkeyLang\Parser\Parselet\PostfixOperatorParselet; +use MonkeyLang\Parser\Parselet\PostfixParselet; +use MonkeyLang\Parser\Parselet\PrefixParselet; +use MonkeyLang\Parser\Parselet\ScalarParselet; +use MonkeyLang\Parser\Parselet\UnaryOperatorParselet; +use MonkeyLang\Parser\Parselet\WhileExpressionParselet; +use MonkeyLang\Token\Token; +use MonkeyLang\Token\TokenType; use function sprintf; diff --git a/src/Parser/Precedence.php b/src/Parser/Precedence.php index 3f7ecd0..9fd734f 100644 --- a/src/Parser/Precedence.php +++ b/src/Parser/Precedence.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Parser; +namespace MonkeyLang\Parser; enum Precedence: int { diff --git a/src/Parser/ProgramParser.php b/src/Parser/ProgramParser.php index 2b0a070..1e988b8 100644 --- a/src/Parser/ProgramParser.php +++ b/src/Parser/ProgramParser.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Parser; +namespace MonkeyLang\Parser; -use Monkey\Ast\Program; -use Monkey\Ast\Statements\Statement; -use Monkey\Parser\Statements\StatementParser; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Program; +use MonkeyLang\Ast\Statements\Statement; +use MonkeyLang\Parser\Statements\StatementParser; +use MonkeyLang\Token\TokenType; final class ProgramParser { diff --git a/src/Parser/Statements/AssignStatementParser.php b/src/Parser/Statements/AssignStatementParser.php index 6ae964d..a51b524 100644 --- a/src/Parser/Statements/AssignStatementParser.php +++ b/src/Parser/Statements/AssignStatementParser.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Monkey\Parser\Statements; - -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Ast\Statements\AssignStatement; -use Monkey\Parser\Parser; -use Monkey\Parser\Precedence; -use Monkey\Token\TokenType; +namespace MonkeyLang\Parser\Statements; + +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Ast\Statements\AssignStatement; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Precedence; +use MonkeyLang\Token\TokenType; final class AssignStatementParser { diff --git a/src/Parser/Statements/BlockStatementParser.php b/src/Parser/Statements/BlockStatementParser.php index 96164f4..85bddd1 100644 --- a/src/Parser/Statements/BlockStatementParser.php +++ b/src/Parser/Statements/BlockStatementParser.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Monkey\Parser\Statements; +namespace MonkeyLang\Parser\Statements; -use Monkey\Ast\Statements\BlockStatement; -use Monkey\Ast\Statements\Statement; -use Monkey\Parser\Parser; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Statements\BlockStatement; +use MonkeyLang\Ast\Statements\Statement; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Token\TokenType; final class BlockStatementParser { diff --git a/src/Parser/Statements/ExpressionStatementParser.php b/src/Parser/Statements/ExpressionStatementParser.php index 25b06e4..6181b64 100644 --- a/src/Parser/Statements/ExpressionStatementParser.php +++ b/src/Parser/Statements/ExpressionStatementParser.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Parser\Statements; +namespace MonkeyLang\Parser\Statements; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Statements\ExpressionStatement; -use Monkey\Parser\Parser; -use Monkey\Parser\Precedence; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Statements\ExpressionStatement; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Precedence; +use MonkeyLang\Token\TokenType; final class ExpressionStatementParser { diff --git a/src/Parser/Statements/LetStatementParser.php b/src/Parser/Statements/LetStatementParser.php index 7001b29..01180f2 100644 --- a/src/Parser/Statements/LetStatementParser.php +++ b/src/Parser/Statements/LetStatementParser.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Monkey\Parser\Statements; - -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Ast\Statements\LetStatement; -use Monkey\Parser\Parser; -use Monkey\Parser\Precedence; -use Monkey\Token\TokenType; +namespace MonkeyLang\Parser\Statements; + +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Ast\Statements\LetStatement; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Precedence; +use MonkeyLang\Token\TokenType; final class LetStatementParser { diff --git a/src/Parser/Statements/ReturnStatementParser.php b/src/Parser/Statements/ReturnStatementParser.php index 1c0edf7..c6f7b32 100644 --- a/src/Parser/Statements/ReturnStatementParser.php +++ b/src/Parser/Statements/ReturnStatementParser.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Monkey\Parser\Statements; +namespace MonkeyLang\Parser\Statements; -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Statements\ReturnStatement; -use Monkey\Parser\Parser; -use Monkey\Parser\Precedence; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Statements\ReturnStatement; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\Precedence; +use MonkeyLang\Token\TokenType; final class ReturnStatementParser { diff --git a/src/Parser/Statements/StatementParser.php b/src/Parser/Statements/StatementParser.php index 7b0e6a0..4614e25 100644 --- a/src/Parser/Statements/StatementParser.php +++ b/src/Parser/Statements/StatementParser.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Monkey\Parser\Statements; +namespace MonkeyLang\Parser\Statements; -use Monkey\Ast\Statements\Statement; -use Monkey\Parser\Parser; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Statements\Statement; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Token\TokenType; final class StatementParser { diff --git a/src/Support/StringBuilder.php b/src/Support/StringBuilder.php index c9dcff9..9181a5a 100644 --- a/src/Support/StringBuilder.php +++ b/src/Support/StringBuilder.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Support; +namespace MonkeyLang\Support; use Stringable; diff --git a/src/Token/Token.php b/src/Token/Token.php index a9d6075..40d0f41 100644 --- a/src/Token/Token.php +++ b/src/Token/Token.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Monkey\Token; +namespace MonkeyLang\Token; final readonly class Token { diff --git a/src/Token/TokenType.php b/src/Token/TokenType.php index 595d723..ef5f8f6 100644 --- a/src/Token/TokenType.php +++ b/src/Token/TokenType.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Monkey\Token; +namespace MonkeyLang\Token; -use Monkey\Lexer\Char; -use Monkey\Parser\Precedence; +use MonkeyLang\Lexer\Char; +use MonkeyLang\Parser\Precedence; enum TokenType: int { diff --git a/tests/AstTest.php b/tests/AstTest.php index 99c85ae..8de3107 100644 --- a/tests/AstTest.php +++ b/tests/AstTest.php @@ -4,12 +4,12 @@ namespace Tests; -use Monkey\Ast\Expressions\IdentifierExpression; -use Monkey\Ast\Program; -use Monkey\Ast\Statements\LetStatement; -use Monkey\Ast\Types\IntegerLiteral; -use Monkey\Token\Token; -use Monkey\Token\TokenType; +use MonkeyLang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Ast\Program; +use MonkeyLang\Ast\Statements\LetStatement; +use MonkeyLang\Ast\Types\IntegerLiteral; +use MonkeyLang\Token\Token; +use MonkeyLang\Token\TokenType; test('to string', function () { $program = new Program(); diff --git a/tests/EvaluatorTest.php b/tests/EvaluatorTest.php index 7b88429..f3f5441 100644 --- a/tests/EvaluatorTest.php +++ b/tests/EvaluatorTest.php @@ -4,16 +4,16 @@ namespace Tests; -use Monkey\Object\ArrayObject; -use Monkey\Object\BooleanObject; -use Monkey\Object\ErrorObject; -use Monkey\Object\FloatObject; -use Monkey\Object\FunctionObject; -use Monkey\Object\IntegerObject; -use Monkey\Object\MonkeyObject; -use Monkey\Object\MonkeyObjectType; -use Monkey\Object\NullObject; -use Monkey\Object\StringObject; +use MonkeyLang\Object\ArrayObject; +use MonkeyLang\Object\BooleanObject; +use MonkeyLang\Object\ErrorObject; +use MonkeyLang\Object\FloatObject; +use MonkeyLang\Object\FunctionObject; +use MonkeyLang\Object\IntegerObject; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Object\MonkeyObjectType; +use MonkeyLang\Object\NullObject; +use MonkeyLang\Object\StringObject; function testObjectValue(MonkeyObject $object, $expected) { diff --git a/tests/Helpers.php b/tests/Helpers.php index 3769c6a..47ba4a9 100644 --- a/tests/Helpers.php +++ b/tests/Helpers.php @@ -2,16 +2,16 @@ declare(strict_types=1); -use Monkey\Ast\Expressions\Expression; -use Monkey\Ast\Program; -use Monkey\Ast\Types\BooleanLiteral; -use Monkey\Ast\Types\IntegerLiteral; -use Monkey\Evaluator\Environment; -use Monkey\Evaluator\Evaluator; -use Monkey\Lexer\Lexer; -use Monkey\Object\MonkeyObject; -use Monkey\Parser\Parser; -use Monkey\Parser\ProgramParser; +use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Ast\Program; +use MonkeyLang\Ast\Types\BooleanLiteral; +use MonkeyLang\Ast\Types\IntegerLiteral; +use MonkeyLang\Evaluator\Environment; +use MonkeyLang\Evaluator\Evaluator; +use MonkeyLang\Lexer\Lexer; +use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Parser\Parser; +use MonkeyLang\Parser\ProgramParser; function assertInfixExpression(Expression $expression, $leftValue, string $operator, $rightValue): void { diff --git a/tests/LexerTest.php b/tests/LexerTest.php index 915829f..1cc1e06 100644 --- a/tests/LexerTest.php +++ b/tests/LexerTest.php @@ -4,8 +4,8 @@ namespace Tests; -use Monkey\Lexer\Lexer; -use Monkey\Token\TokenType; +use MonkeyLang\Lexer\Lexer; +use MonkeyLang\Token\TokenType; test('basic tokens', function () { $input = << Date: Sun, 15 Dec 2024 12:36:42 -0300 Subject: [PATCH 06/22] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0065076..fdb64ef 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ .DS_Store composer.lock .php-cs-fixer.cache +/.phpunit.cache/ From 0733f63aadbe3e1659aa1ec6b95a6fa52748a2ec Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 12:46:22 -0300 Subject: [PATCH 07/22] Namespace --- .../Ast/Expressions/BinaryExpression.php | 6 +- .../Ast/Expressions/CallExpression.php | 6 +- src/{ => Lang}/Ast/Expressions/Expression.php | 4 +- .../Ast/Expressions/IdentifierExpression.php | 4 +- .../Ast/Expressions/IfExpression.php | 8 +- .../Ast/Expressions/IndexExpression.php | 6 +- .../Ast/Expressions/PostfixExpression.php | 6 +- .../Ast/Expressions/UnaryExpression.php | 6 +- .../Ast/Expressions/WhileExpression.php | 8 +- src/{ => Lang}/Ast/Node.php | 2 +- src/{ => Lang}/Ast/Program.php | 7 +- .../Ast/Statements/AssignStatement.php | 10 +-- .../Ast/Statements/BlockStatement.php | 6 +- .../Ast/Statements/ExpressionStatement.php | 6 +- .../Ast/Statements/LetStatement.php | 10 +-- .../Ast/Statements/ReturnStatement.php | 8 +- src/{ => Lang}/Ast/Statements/Statement.php | 4 +- src/{ => Lang}/Ast/Types/ArrayLiteral.php | 8 +- src/{ => Lang}/Ast/Types/BooleanLiteral.php | 6 +- src/{ => Lang}/Ast/Types/FloatLiteral.php | 6 +- src/{ => Lang}/Ast/Types/FunctionLiteral.php | 12 +-- src/{ => Lang}/Ast/Types/IntegerLiteral.php | 6 +- src/{ => Lang}/Ast/Types/StringLiteral.php | 6 +- .../Evaluator/Builtin/EvalBuiltinFunction.php | 6 +- .../Evaluator/Builtin/EvalFirstFunction.php | 10 +-- .../Evaluator/Builtin/EvalLastFunction.php | 10 +-- .../Evaluator/Builtin/EvalLenFunction.php | 12 +-- .../Evaluator/Builtin/EvalMapFunction.php | 12 +-- .../Evaluator/Builtin/EvalPushFunction.php | 8 +- .../Evaluator/Builtin/EvalPutsFunction.php | 8 +- .../Evaluator/Builtin/EvalSliceFunction.php | 12 +-- src/{ => Lang}/Evaluator/BuiltinFunction.php | 6 +- src/{ => Lang}/Evaluator/Environment.php | 4 +- .../Evaluator/EvalArrayBinaryExpression.php | 8 +- src/{ => Lang}/Evaluator/EvalArrayLiteral.php | 10 +-- .../Evaluator/EvalAssingStatement.php | 8 +- .../Evaluator/EvalBinaryExpression.php | 18 ++--- .../Evaluator/EvalBlockStatement.php | 12 +-- .../Evaluator/EvalCallExpression.php | 16 ++-- src/{ => Lang}/Evaluator/EvalIdentifier.php | 8 +- src/{ => Lang}/Evaluator/EvalIfExpression.php | 12 +-- .../Evaluator/EvalIndexExpression.php | 16 ++-- src/{ => Lang}/Evaluator/EvalLetStatement.php | 8 +- .../EvalMinusUnaryOperatorExpression.php | 8 +- .../Evaluator/EvalNotOperatorExpression.php | 8 +- .../Evaluator/EvalNumericBinaryExpression.php | 8 +- .../Evaluator/EvalPostfixExpression.php | 10 +-- src/{ => Lang}/Evaluator/EvalProgram.php | 12 +-- .../Evaluator/EvalReturnStatement.php | 10 +-- .../Evaluator/EvalStringBinaryExpression.php | 10 +-- .../Evaluator/EvalUnaryExpression.php | 6 +- .../Evaluator/EvalWhileExpression.php | 10 +-- src/{ => Lang}/Evaluator/Evaluator.php | 76 +++++++++---------- src/{ => Lang}/Lexer/Char.php | 2 +- src/{ => Lang}/Lexer/Input.php | 2 +- src/{ => Lang}/Lexer/Lexer.php | 6 +- src/{ => Lang}/Object/ArrayObject.php | 2 +- src/{ => Lang}/Object/BooleanObject.php | 2 +- .../Object/BuiltinFunctionObject.php | 2 +- src/{ => Lang}/Object/ErrorObject.php | 2 +- src/{ => Lang}/Object/FloatObject.php | 2 +- src/{ => Lang}/Object/FunctionObject.php | 8 +- src/{ => Lang}/Object/IntegerObject.php | 2 +- src/{ => Lang}/Object/MonkeyObject.php | 2 +- src/{ => Lang}/Object/MonkeyObjectType.php | 2 +- src/{ => Lang}/Object/NullObject.php | 2 +- src/{ => Lang}/Object/ReturnValueObject.php | 2 +- src/{ => Lang}/Object/StringObject.php | 2 +- .../Parser/ExpressionListParser.php | 6 +- .../Parser/FunctionParametersParser.php | 6 +- .../Parser/Parselet/ArrayParselet.php | 12 +-- .../Parselet/BinaryOperatorParselet.php | 8 +- .../Parselet/CallExpressionParselet.php | 12 +-- .../Parselet/FunctionLiteralParselet.php | 16 ++-- .../Parselet/GroupedExpressionParselet.php | 10 +-- .../Parser/Parselet/IdentifierParselet.php | 8 +- .../Parser/Parselet/IfExpressionParselet.php | 16 ++-- .../Parselet/IndexExpressionParselet.php | 12 +-- .../Parser/Parselet/InfixParselet.php | 4 +- .../Parselet/PostfixOperatorParselet.php | 8 +- .../Parser/Parselet/PostfixParselet.php | 4 +- .../Parser/Parselet/PrefixParselet.php | 4 +- .../Parser/Parselet/ScalarParselet.php | 16 ++-- .../Parser/Parselet/UnaryOperatorParselet.php | 10 +-- .../Parselet/WhileExpressionParselet.php | 16 ++-- src/{ => Lang}/Parser/Parser.php | 42 +++++----- src/{ => Lang}/Parser/Precedence.php | 2 +- src/{ => Lang}/Parser/ProgramParser.php | 10 +-- .../Statements/AssignStatementParser.php | 16 ++-- .../Statements/BlockStatementParser.php | 10 +-- .../Statements/ExpressionStatementParser.php | 12 +-- .../Parser/Statements/LetStatementParser.php | 16 ++-- .../Statements/ReturnStatementParser.php | 12 +-- .../Parser/Statements/StatementParser.php | 8 +- src/{ => Lang}/Support/StringBuilder.php | 2 +- src/{ => Lang}/Token/Token.php | 2 +- src/{ => Lang}/Token/TokenType.php | 6 +- src/Monkey/Command/RunFileCommand.php | 12 +-- src/Monkey/IO/OutputFormatter.php | 4 +- src/Monkey/Repl/ReplManager.php | 12 +-- tests/AstTest.php | 12 +-- tests/EvaluatorTest.php | 20 ++--- tests/Helpers.php | 20 ++--- tests/LexerTest.php | 4 +- tests/ParserTest.php | 36 ++++----- 105 files changed, 489 insertions(+), 490 deletions(-) rename src/{ => Lang}/Ast/Expressions/BinaryExpression.php (84%) rename src/{ => Lang}/Ast/Expressions/CallExpression.php (86%) rename src/{ => Lang}/Ast/Expressions/Expression.php (51%) rename src/{ => Lang}/Ast/Expressions/IdentifierExpression.php (79%) rename src/{ => Lang}/Ast/Expressions/IfExpression.php (81%) rename src/{ => Lang}/Ast/Expressions/IndexExpression.php (81%) rename src/{ => Lang}/Ast/Expressions/PostfixExpression.php (79%) rename src/{ => Lang}/Ast/Expressions/UnaryExpression.php (80%) rename src/{ => Lang}/Ast/Expressions/WhileExpression.php (74%) rename src/{ => Lang}/Ast/Node.php (88%) rename src/{ => Lang}/Ast/Program.php (87%) rename src/{ => Lang}/Ast/Statements/AssignStatement.php (70%) rename src/{ => Lang}/Ast/Statements/BlockStatement.php (82%) rename src/{ => Lang}/Ast/Statements/ExpressionStatement.php (72%) rename src/{ => Lang}/Ast/Statements/LetStatement.php (72%) rename src/{ => Lang}/Ast/Statements/ReturnStatement.php (75%) rename src/{ => Lang}/Ast/Statements/Statement.php (51%) rename src/{ => Lang}/Ast/Types/ArrayLiteral.php (80%) rename src/{ => Lang}/Ast/Types/BooleanLiteral.php (71%) rename src/{ => Lang}/Ast/Types/FloatLiteral.php (71%) rename src/{ => Lang}/Ast/Types/FunctionLiteral.php (74%) rename src/{ => Lang}/Ast/Types/IntegerLiteral.php (71%) rename src/{ => Lang}/Ast/Types/StringLiteral.php (71%) rename src/{ => Lang}/Evaluator/Builtin/EvalBuiltinFunction.php (66%) rename src/{ => Lang}/Evaluator/Builtin/EvalFirstFunction.php (76%) rename src/{ => Lang}/Evaluator/Builtin/EvalLastFunction.php (76%) rename src/{ => Lang}/Evaluator/Builtin/EvalLenFunction.php (73%) rename src/{ => Lang}/Evaluator/Builtin/EvalMapFunction.php (83%) rename src/{ => Lang}/Evaluator/Builtin/EvalPushFunction.php (79%) rename src/{ => Lang}/Evaluator/Builtin/EvalPutsFunction.php (75%) rename src/{ => Lang}/Evaluator/Builtin/EvalSliceFunction.php (86%) rename src/{ => Lang}/Evaluator/BuiltinFunction.php (77%) rename src/{ => Lang}/Evaluator/Environment.php (85%) rename src/{ => Lang}/Evaluator/EvalArrayBinaryExpression.php (74%) rename src/{ => Lang}/Evaluator/EvalArrayLiteral.php (73%) rename src/{ => Lang}/Evaluator/EvalAssingStatement.php (82%) rename src/{ => Lang}/Evaluator/EvalBinaryExpression.php (83%) rename src/{ => Lang}/Evaluator/EvalBlockStatement.php (73%) rename src/{ => Lang}/Evaluator/EvalCallExpression.php (87%) rename src/{ => Lang}/Evaluator/EvalIdentifier.php (75%) rename src/{ => Lang}/Evaluator/EvalIfExpression.php (76%) rename src/{ => Lang}/Evaluator/EvalIndexExpression.php (75%) rename src/{ => Lang}/Evaluator/EvalLetStatement.php (79%) rename src/{ => Lang}/Evaluator/EvalMinusUnaryOperatorExpression.php (70%) rename src/{ => Lang}/Evaluator/EvalNotOperatorExpression.php (72%) rename src/{ => Lang}/Evaluator/EvalNumericBinaryExpression.php (88%) rename src/{ => Lang}/Evaluator/EvalPostfixExpression.php (86%) rename src/{ => Lang}/Evaluator/EvalProgram.php (74%) rename src/{ => Lang}/Evaluator/EvalReturnStatement.php (71%) rename src/{ => Lang}/Evaluator/EvalStringBinaryExpression.php (74%) rename src/{ => Lang}/Evaluator/EvalUnaryExpression.php (82%) rename src/{ => Lang}/Evaluator/EvalWhileExpression.php (80%) rename src/{ => Lang}/Evaluator/Evaluator.php (66%) rename src/{ => Lang}/Lexer/Char.php (97%) rename src/{ => Lang}/Lexer/Input.php (94%) rename src/{ => Lang}/Lexer/Lexer.php (97%) rename src/{ => Lang}/Object/ArrayObject.php (96%) rename src/{ => Lang}/Object/BooleanObject.php (95%) rename src/{ => Lang}/Object/BuiltinFunctionObject.php (93%) rename src/{ => Lang}/Object/ErrorObject.php (97%) rename src/{ => Lang}/Object/FloatObject.php (93%) rename src/{ => Lang}/Object/FunctionObject.php (83%) rename src/{ => Lang}/Object/IntegerObject.php (93%) rename src/{ => Lang}/Object/MonkeyObject.php (95%) rename src/{ => Lang}/Object/MonkeyObjectType.php (96%) rename src/{ => Lang}/Object/NullObject.php (93%) rename src/{ => Lang}/Object/ReturnValueObject.php (93%) rename src/{ => Lang}/Object/StringObject.php (94%) rename src/{ => Lang}/Parser/ExpressionListParser.php (86%) rename src/{ => Lang}/Parser/FunctionParametersParser.php (87%) rename src/{ => Lang}/Parser/Parselet/ArrayParselet.php (61%) rename src/{ => Lang}/Parser/Parselet/BinaryOperatorParselet.php (75%) rename src/{ => Lang}/Parser/Parselet/CallExpressionParselet.php (63%) rename src/{ => Lang}/Parser/Parselet/FunctionLiteralParselet.php (67%) rename src/{ => Lang}/Parser/Parselet/GroupedExpressionParselet.php (72%) rename src/{ => Lang}/Parser/Parselet/IdentifierParselet.php (65%) rename src/{ => Lang}/Parser/Parselet/IfExpressionParselet.php (79%) rename src/{ => Lang}/Parser/Parselet/IndexExpressionParselet.php (72%) rename src/{ => Lang}/Parser/Parselet/InfixParselet.php (58%) rename src/{ => Lang}/Parser/Parselet/PostfixOperatorParselet.php (65%) rename src/{ => Lang}/Parser/Parselet/PostfixParselet.php (53%) rename src/{ => Lang}/Parser/Parselet/PrefixParselet.php (53%) rename src/{ => Lang}/Parser/Parselet/ScalarParselet.php (70%) rename src/{ => Lang}/Parser/Parselet/UnaryOperatorParselet.php (69%) rename src/{ => Lang}/Parser/Parselet/WhileExpressionParselet.php (73%) rename src/{ => Lang}/Parser/Parser.php (85%) rename src/{ => Lang}/Parser/Precedence.php (90%) rename src/{ => Lang}/Parser/ProgramParser.php (69%) rename src/{ => Lang}/Parser/Statements/AssignStatementParser.php (66%) rename src/{ => Lang}/Parser/Statements/BlockStatementParser.php (75%) rename src/{ => Lang}/Parser/Statements/ExpressionStatementParser.php (67%) rename src/{ => Lang}/Parser/Statements/LetStatementParser.php (72%) rename src/{ => Lang}/Parser/Statements/ReturnStatementParser.php (66%) rename src/{ => Lang}/Parser/Statements/StatementParser.php (79%) rename src/{ => Lang}/Support/StringBuilder.php (95%) rename src/{ => Lang}/Token/Token.php (94%) rename src/{ => Lang}/Token/TokenType.php (97%) diff --git a/src/Ast/Expressions/BinaryExpression.php b/src/Lang/Ast/Expressions/BinaryExpression.php similarity index 84% rename from src/Ast/Expressions/BinaryExpression.php rename to src/Lang/Ast/Expressions/BinaryExpression.php index 6ca0f8f..c64bcb0 100644 --- a/src/Ast/Expressions/BinaryExpression.php +++ b/src/Lang/Ast/Expressions/BinaryExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Expressions; +namespace MonkeyLang\Lang\Ast\Expressions; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class BinaryExpression extends Expression { diff --git a/src/Ast/Expressions/CallExpression.php b/src/Lang/Ast/Expressions/CallExpression.php similarity index 86% rename from src/Ast/Expressions/CallExpression.php rename to src/Lang/Ast/Expressions/CallExpression.php index ad619fa..5df8885 100644 --- a/src/Ast/Expressions/CallExpression.php +++ b/src/Lang/Ast/Expressions/CallExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Expressions; +namespace MonkeyLang\Lang\Ast\Expressions; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; use function count; diff --git a/src/Ast/Expressions/Expression.php b/src/Lang/Ast/Expressions/Expression.php similarity index 51% rename from src/Ast/Expressions/Expression.php rename to src/Lang/Ast/Expressions/Expression.php index b95f7e7..c06fe36 100644 --- a/src/Ast/Expressions/Expression.php +++ b/src/Lang/Ast/Expressions/Expression.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Expressions; +namespace MonkeyLang\Lang\Ast\Expressions; -use MonkeyLang\Ast\Node; +use MonkeyLang\Lang\Ast\Node; abstract class Expression extends Node { diff --git a/src/Ast/Expressions/IdentifierExpression.php b/src/Lang/Ast/Expressions/IdentifierExpression.php similarity index 79% rename from src/Ast/Expressions/IdentifierExpression.php rename to src/Lang/Ast/Expressions/IdentifierExpression.php index aba00c2..4a2c92a 100644 --- a/src/Ast/Expressions/IdentifierExpression.php +++ b/src/Lang/Ast/Expressions/IdentifierExpression.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Expressions; +namespace MonkeyLang\Lang\Ast\Expressions; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Token\Token; final class IdentifierExpression extends Expression { diff --git a/src/Ast/Expressions/IfExpression.php b/src/Lang/Ast/Expressions/IfExpression.php similarity index 81% rename from src/Ast/Expressions/IfExpression.php rename to src/Lang/Ast/Expressions/IfExpression.php index 0619338..208005b 100644 --- a/src/Ast/Expressions/IfExpression.php +++ b/src/Lang/Ast/Expressions/IfExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Expressions; +namespace MonkeyLang\Lang\Ast\Expressions; -use MonkeyLang\Ast\Statements\BlockStatement; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Statements\BlockStatement; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class IfExpression extends Expression { diff --git a/src/Ast/Expressions/IndexExpression.php b/src/Lang/Ast/Expressions/IndexExpression.php similarity index 81% rename from src/Ast/Expressions/IndexExpression.php rename to src/Lang/Ast/Expressions/IndexExpression.php index 8ee8bdb..fb59af6 100644 --- a/src/Ast/Expressions/IndexExpression.php +++ b/src/Lang/Ast/Expressions/IndexExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Expressions; +namespace MonkeyLang\Lang\Ast\Expressions; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class IndexExpression extends Expression { diff --git a/src/Ast/Expressions/PostfixExpression.php b/src/Lang/Ast/Expressions/PostfixExpression.php similarity index 79% rename from src/Ast/Expressions/PostfixExpression.php rename to src/Lang/Ast/Expressions/PostfixExpression.php index f06d938..37250c6 100644 --- a/src/Ast/Expressions/PostfixExpression.php +++ b/src/Lang/Ast/Expressions/PostfixExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Expressions; +namespace MonkeyLang\Lang\Ast\Expressions; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class PostfixExpression extends Expression { diff --git a/src/Ast/Expressions/UnaryExpression.php b/src/Lang/Ast/Expressions/UnaryExpression.php similarity index 80% rename from src/Ast/Expressions/UnaryExpression.php rename to src/Lang/Ast/Expressions/UnaryExpression.php index 0243e9f..d46c754 100644 --- a/src/Ast/Expressions/UnaryExpression.php +++ b/src/Lang/Ast/Expressions/UnaryExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Expressions; +namespace MonkeyLang\Lang\Ast\Expressions; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class UnaryExpression extends Expression { diff --git a/src/Ast/Expressions/WhileExpression.php b/src/Lang/Ast/Expressions/WhileExpression.php similarity index 74% rename from src/Ast/Expressions/WhileExpression.php rename to src/Lang/Ast/Expressions/WhileExpression.php index dee2e7d..bcda764 100644 --- a/src/Ast/Expressions/WhileExpression.php +++ b/src/Lang/Ast/Expressions/WhileExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Expressions; +namespace MonkeyLang\Lang\Ast\Expressions; -use MonkeyLang\Ast\Statements\BlockStatement; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Statements\BlockStatement; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class WhileExpression extends Expression { diff --git a/src/Ast/Node.php b/src/Lang/Ast/Node.php similarity index 88% rename from src/Ast/Node.php rename to src/Lang/Ast/Node.php index a3290c5..7bf07de 100644 --- a/src/Ast/Node.php +++ b/src/Lang/Ast/Node.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Ast; +namespace MonkeyLang\Lang\Ast; use Stringable; diff --git a/src/Ast/Program.php b/src/Lang/Ast/Program.php similarity index 87% rename from src/Ast/Program.php rename to src/Lang/Ast/Program.php index f8c0fad..6499464 100644 --- a/src/Ast/Program.php +++ b/src/Lang/Ast/Program.php @@ -2,11 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast; +namespace MonkeyLang\Lang\Ast; -use MonkeyLang\Ast\Statements\Statement; - -use MonkeyLang\Support\StringBuilder; +use MonkeyLang\Lang\Ast\Statements\Statement; +use MonkeyLang\Lang\Support\StringBuilder; use function count; diff --git a/src/Ast/Statements/AssignStatement.php b/src/Lang/Ast/Statements/AssignStatement.php similarity index 70% rename from src/Ast/Statements/AssignStatement.php rename to src/Lang/Ast/Statements/AssignStatement.php index 6439b22..0a739f2 100644 --- a/src/Ast/Statements/AssignStatement.php +++ b/src/Lang/Ast/Statements/AssignStatement.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Statements; +namespace MonkeyLang\Lang\Ast\Statements; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class AssignStatement extends Statement { diff --git a/src/Ast/Statements/BlockStatement.php b/src/Lang/Ast/Statements/BlockStatement.php similarity index 82% rename from src/Ast/Statements/BlockStatement.php rename to src/Lang/Ast/Statements/BlockStatement.php index e50095f..80e8fa6 100644 --- a/src/Ast/Statements/BlockStatement.php +++ b/src/Lang/Ast/Statements/BlockStatement.php @@ -4,10 +4,10 @@ namespace MonkeyLang\Ast\Statements; -namespace MonkeyLang\Ast\Statements; +namespace MonkeyLang\Lang\Ast\Statements; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class BlockStatement extends Statement { diff --git a/src/Ast/Statements/ExpressionStatement.php b/src/Lang/Ast/Statements/ExpressionStatement.php similarity index 72% rename from src/Ast/Statements/ExpressionStatement.php rename to src/Lang/Ast/Statements/ExpressionStatement.php index b893277..0ad5b30 100644 --- a/src/Ast/Statements/ExpressionStatement.php +++ b/src/Lang/Ast/Statements/ExpressionStatement.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Statements; +namespace MonkeyLang\Lang\Ast\Statements; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Token\Token; final class ExpressionStatement extends Statement { diff --git a/src/Ast/Statements/LetStatement.php b/src/Lang/Ast/Statements/LetStatement.php similarity index 72% rename from src/Ast/Statements/LetStatement.php rename to src/Lang/Ast/Statements/LetStatement.php index be5c5bf..5aa1ca5 100644 --- a/src/Ast/Statements/LetStatement.php +++ b/src/Lang/Ast/Statements/LetStatement.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Statements; +namespace MonkeyLang\Lang\Ast\Statements; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class LetStatement extends Statement { diff --git a/src/Ast/Statements/ReturnStatement.php b/src/Lang/Ast/Statements/ReturnStatement.php similarity index 75% rename from src/Ast/Statements/ReturnStatement.php rename to src/Lang/Ast/Statements/ReturnStatement.php index a3c70e6..5c73d98 100644 --- a/src/Ast/Statements/ReturnStatement.php +++ b/src/Lang/Ast/Statements/ReturnStatement.php @@ -4,11 +4,11 @@ namespace MonkeyLang\Ast\Statements; -namespace MonkeyLang\Ast\Statements; +namespace MonkeyLang\Lang\Ast\Statements; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; final class ReturnStatement extends Statement { diff --git a/src/Ast/Statements/Statement.php b/src/Lang/Ast/Statements/Statement.php similarity index 51% rename from src/Ast/Statements/Statement.php rename to src/Lang/Ast/Statements/Statement.php index 6d753d5..39b67a4 100644 --- a/src/Ast/Statements/Statement.php +++ b/src/Lang/Ast/Statements/Statement.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Statements; +namespace MonkeyLang\Lang\Ast\Statements; -use MonkeyLang\Ast\Node; +use MonkeyLang\Lang\Ast\Node; abstract class Statement extends Node { diff --git a/src/Ast/Types/ArrayLiteral.php b/src/Lang/Ast/Types/ArrayLiteral.php similarity index 80% rename from src/Ast/Types/ArrayLiteral.php rename to src/Lang/Ast/Types/ArrayLiteral.php index 93d4748..b97b387 100644 --- a/src/Ast/Types/ArrayLiteral.php +++ b/src/Lang/Ast/Types/ArrayLiteral.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Types; +namespace MonkeyLang\Lang\Ast\Types; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; use function count; diff --git a/src/Ast/Types/BooleanLiteral.php b/src/Lang/Ast/Types/BooleanLiteral.php similarity index 71% rename from src/Ast/Types/BooleanLiteral.php rename to src/Lang/Ast/Types/BooleanLiteral.php index 9e2aed2..4e77229 100644 --- a/src/Ast/Types/BooleanLiteral.php +++ b/src/Lang/Ast/Types/BooleanLiteral.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Types; +namespace MonkeyLang\Lang\Ast\Types; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Token\Token; final class BooleanLiteral extends Expression { diff --git a/src/Ast/Types/FloatLiteral.php b/src/Lang/Ast/Types/FloatLiteral.php similarity index 71% rename from src/Ast/Types/FloatLiteral.php rename to src/Lang/Ast/Types/FloatLiteral.php index 31102ae..f65bd1b 100644 --- a/src/Ast/Types/FloatLiteral.php +++ b/src/Lang/Ast/Types/FloatLiteral.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Types; +namespace MonkeyLang\Lang\Ast\Types; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Token\Token; final class FloatLiteral extends Expression { diff --git a/src/Ast/Types/FunctionLiteral.php b/src/Lang/Ast/Types/FunctionLiteral.php similarity index 74% rename from src/Ast/Types/FunctionLiteral.php rename to src/Lang/Ast/Types/FunctionLiteral.php index 184f1a6..032a458 100644 --- a/src/Ast/Types/FunctionLiteral.php +++ b/src/Lang/Ast/Types/FunctionLiteral.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Types; +namespace MonkeyLang\Lang\Ast\Types; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Ast\Statements\BlockStatement; -use MonkeyLang\Support\StringBuilder; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Ast\Statements\BlockStatement; +use MonkeyLang\Lang\Support\StringBuilder; +use MonkeyLang\Lang\Token\Token; use function count; diff --git a/src/Ast/Types/IntegerLiteral.php b/src/Lang/Ast/Types/IntegerLiteral.php similarity index 71% rename from src/Ast/Types/IntegerLiteral.php rename to src/Lang/Ast/Types/IntegerLiteral.php index ef4e84e..1b641d1 100644 --- a/src/Ast/Types/IntegerLiteral.php +++ b/src/Lang/Ast/Types/IntegerLiteral.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Types; +namespace MonkeyLang\Lang\Ast\Types; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Token\Token; final class IntegerLiteral extends Expression { diff --git a/src/Ast/Types/StringLiteral.php b/src/Lang/Ast/Types/StringLiteral.php similarity index 71% rename from src/Ast/Types/StringLiteral.php rename to src/Lang/Ast/Types/StringLiteral.php index 825c533..5ef4179 100644 --- a/src/Ast/Types/StringLiteral.php +++ b/src/Lang/Ast/Types/StringLiteral.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Ast\Types; +namespace MonkeyLang\Lang\Ast\Types; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Token\Token; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Token\Token; final class StringLiteral extends Expression { diff --git a/src/Evaluator/Builtin/EvalBuiltinFunction.php b/src/Lang/Evaluator/Builtin/EvalBuiltinFunction.php similarity index 66% rename from src/Evaluator/Builtin/EvalBuiltinFunction.php rename to src/Lang/Evaluator/Builtin/EvalBuiltinFunction.php index ebfab33..347ca37 100644 --- a/src/Evaluator/Builtin/EvalBuiltinFunction.php +++ b/src/Lang/Evaluator/Builtin/EvalBuiltinFunction.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator\Builtin; +namespace MonkeyLang\Lang\Evaluator\Builtin; -use MonkeyLang\Evaluator\Evaluator; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Evaluator\Evaluator; +use MonkeyLang\Lang\Object\MonkeyObject; abstract readonly class EvalBuiltinFunction { diff --git a/src/Evaluator/Builtin/EvalFirstFunction.php b/src/Lang/Evaluator/Builtin/EvalFirstFunction.php similarity index 76% rename from src/Evaluator/Builtin/EvalFirstFunction.php rename to src/Lang/Evaluator/Builtin/EvalFirstFunction.php index 0359df3..2e3ec76 100644 --- a/src/Evaluator/Builtin/EvalFirstFunction.php +++ b/src/Lang/Evaluator/Builtin/EvalFirstFunction.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator\Builtin; +namespace MonkeyLang\Lang\Evaluator\Builtin; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; use function count; diff --git a/src/Evaluator/Builtin/EvalLastFunction.php b/src/Lang/Evaluator/Builtin/EvalLastFunction.php similarity index 76% rename from src/Evaluator/Builtin/EvalLastFunction.php rename to src/Lang/Evaluator/Builtin/EvalLastFunction.php index 208b1f5..6468a65 100644 --- a/src/Evaluator/Builtin/EvalLastFunction.php +++ b/src/Lang/Evaluator/Builtin/EvalLastFunction.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator\Builtin; +namespace MonkeyLang\Lang\Evaluator\Builtin; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; use function count; diff --git a/src/Evaluator/Builtin/EvalLenFunction.php b/src/Lang/Evaluator/Builtin/EvalLenFunction.php similarity index 73% rename from src/Evaluator/Builtin/EvalLenFunction.php rename to src/Lang/Evaluator/Builtin/EvalLenFunction.php index b506833..b730fd1 100644 --- a/src/Evaluator/Builtin/EvalLenFunction.php +++ b/src/Lang/Evaluator/Builtin/EvalLenFunction.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator\Builtin; +namespace MonkeyLang\Lang\Evaluator\Builtin; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\IntegerObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\StringObject; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\IntegerObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\StringObject; use function count; diff --git a/src/Evaluator/Builtin/EvalMapFunction.php b/src/Lang/Evaluator/Builtin/EvalMapFunction.php similarity index 83% rename from src/Evaluator/Builtin/EvalMapFunction.php rename to src/Lang/Evaluator/Builtin/EvalMapFunction.php index 24241e2..1e587ee 100644 --- a/src/Evaluator/Builtin/EvalMapFunction.php +++ b/src/Lang/Evaluator/Builtin/EvalMapFunction.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator\Builtin; +namespace MonkeyLang\Lang\Evaluator\Builtin; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\FunctionObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\FunctionObject; +use MonkeyLang\Lang\Object\MonkeyObject; use function count; diff --git a/src/Evaluator/Builtin/EvalPushFunction.php b/src/Lang/Evaluator/Builtin/EvalPushFunction.php similarity index 79% rename from src/Evaluator/Builtin/EvalPushFunction.php rename to src/Lang/Evaluator/Builtin/EvalPushFunction.php index 7d38c1a..27d6f13 100644 --- a/src/Evaluator/Builtin/EvalPushFunction.php +++ b/src/Lang/Evaluator/Builtin/EvalPushFunction.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator\Builtin; +namespace MonkeyLang\Lang\Evaluator\Builtin; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; use function count; diff --git a/src/Evaluator/Builtin/EvalPutsFunction.php b/src/Lang/Evaluator/Builtin/EvalPutsFunction.php similarity index 75% rename from src/Evaluator/Builtin/EvalPutsFunction.php rename to src/Lang/Evaluator/Builtin/EvalPutsFunction.php index b2580e0..6c146b5 100644 --- a/src/Evaluator/Builtin/EvalPutsFunction.php +++ b/src/Lang/Evaluator/Builtin/EvalPutsFunction.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator\Builtin; +namespace MonkeyLang\Lang\Evaluator\Builtin; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; use function count; diff --git a/src/Evaluator/Builtin/EvalSliceFunction.php b/src/Lang/Evaluator/Builtin/EvalSliceFunction.php similarity index 86% rename from src/Evaluator/Builtin/EvalSliceFunction.php rename to src/Lang/Evaluator/Builtin/EvalSliceFunction.php index 58dac80..5560beb 100644 --- a/src/Evaluator/Builtin/EvalSliceFunction.php +++ b/src/Lang/Evaluator/Builtin/EvalSliceFunction.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator\Builtin; +namespace MonkeyLang\Lang\Evaluator\Builtin; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\IntegerObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\StringObject; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\IntegerObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\StringObject; use function array_slice; use function count; diff --git a/src/Evaluator/BuiltinFunction.php b/src/Lang/Evaluator/BuiltinFunction.php similarity index 77% rename from src/Evaluator/BuiltinFunction.php rename to src/Lang/Evaluator/BuiltinFunction.php index 40abace..2ccd4e3 100644 --- a/src/Evaluator/BuiltinFunction.php +++ b/src/Lang/Evaluator/BuiltinFunction.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; use Closure; -use MonkeyLang\Object\BuiltinFunctionObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\BuiltinFunctionObject; +use MonkeyLang\Lang\Object\MonkeyObject; final class BuiltinFunction { diff --git a/src/Evaluator/Environment.php b/src/Lang/Evaluator/Environment.php similarity index 85% rename from src/Evaluator/Environment.php rename to src/Lang/Evaluator/Environment.php index 8397798..bb8dfb8 100644 --- a/src/Evaluator/Environment.php +++ b/src/Lang/Evaluator/Environment.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\MonkeyObject; final class Environment { diff --git a/src/Evaluator/EvalArrayBinaryExpression.php b/src/Lang/Evaluator/EvalArrayBinaryExpression.php similarity index 74% rename from src/Evaluator/EvalArrayBinaryExpression.php rename to src/Lang/Evaluator/EvalArrayBinaryExpression.php index 9e092ba..2bb0cff 100644 --- a/src/Evaluator/EvalArrayBinaryExpression.php +++ b/src/Lang/Evaluator/EvalArrayBinaryExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; final class EvalArrayBinaryExpression { diff --git a/src/Evaluator/EvalArrayLiteral.php b/src/Lang/Evaluator/EvalArrayLiteral.php similarity index 73% rename from src/Evaluator/EvalArrayLiteral.php rename to src/Lang/Evaluator/EvalArrayLiteral.php index da1db64..d7eb8e1 100644 --- a/src/Evaluator/EvalArrayLiteral.php +++ b/src/Lang/Evaluator/EvalArrayLiteral.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Types\ArrayLiteral; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Ast\Types\ArrayLiteral; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; use function count; diff --git a/src/Evaluator/EvalAssingStatement.php b/src/Lang/Evaluator/EvalAssingStatement.php similarity index 82% rename from src/Evaluator/EvalAssingStatement.php rename to src/Lang/Evaluator/EvalAssingStatement.php index 9677758..6b8a089 100644 --- a/src/Evaluator/EvalAssingStatement.php +++ b/src/Lang/Evaluator/EvalAssingStatement.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Statements\AssignStatement; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Ast\Statements\AssignStatement; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; final readonly class EvalAssingStatement { diff --git a/src/Evaluator/EvalBinaryExpression.php b/src/Lang/Evaluator/EvalBinaryExpression.php similarity index 83% rename from src/Evaluator/EvalBinaryExpression.php rename to src/Lang/Evaluator/EvalBinaryExpression.php index 29a251c..335f870 100644 --- a/src/Evaluator/EvalBinaryExpression.php +++ b/src/Lang/Evaluator/EvalBinaryExpression.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; - -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\BooleanObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\FloatObject; -use MonkeyLang\Object\IntegerObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\StringObject; +namespace MonkeyLang\Lang\Evaluator; + +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\BooleanObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\FloatObject; +use MonkeyLang\Lang\Object\IntegerObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\StringObject; final class EvalBinaryExpression { diff --git a/src/Evaluator/EvalBlockStatement.php b/src/Lang/Evaluator/EvalBlockStatement.php similarity index 73% rename from src/Evaluator/EvalBlockStatement.php rename to src/Lang/Evaluator/EvalBlockStatement.php index 2bc4b0d..8fc14fc 100644 --- a/src/Evaluator/EvalBlockStatement.php +++ b/src/Lang/Evaluator/EvalBlockStatement.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Statements\BlockStatement; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; -use MonkeyLang\Object\ReturnValueObject; +use MonkeyLang\Lang\Ast\Statements\BlockStatement; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; +use MonkeyLang\Lang\Object\ReturnValueObject; final readonly class EvalBlockStatement { diff --git a/src/Evaluator/EvalCallExpression.php b/src/Lang/Evaluator/EvalCallExpression.php similarity index 87% rename from src/Evaluator/EvalCallExpression.php rename to src/Lang/Evaluator/EvalCallExpression.php index 53e5f8c..9d154a5 100644 --- a/src/Evaluator/EvalCallExpression.php +++ b/src/Lang/Evaluator/EvalCallExpression.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; - -use MonkeyLang\Ast\Expressions\CallExpression; -use MonkeyLang\Object\BuiltinFunctionObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\FunctionObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\ReturnValueObject; +namespace MonkeyLang\Lang\Evaluator; + +use MonkeyLang\Lang\Ast\Expressions\CallExpression; +use MonkeyLang\Lang\Object\BuiltinFunctionObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\FunctionObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\ReturnValueObject; use function call_user_func; use function count; diff --git a/src/Evaluator/EvalIdentifier.php b/src/Lang/Evaluator/EvalIdentifier.php similarity index 75% rename from src/Evaluator/EvalIdentifier.php rename to src/Lang/Evaluator/EvalIdentifier.php index 080d4b0..d9a8340 100644 --- a/src/Evaluator/EvalIdentifier.php +++ b/src/Lang/Evaluator/EvalIdentifier.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; final readonly class EvalIdentifier { diff --git a/src/Evaluator/EvalIfExpression.php b/src/Lang/Evaluator/EvalIfExpression.php similarity index 76% rename from src/Evaluator/EvalIfExpression.php rename to src/Lang/Evaluator/EvalIfExpression.php index 370ddb2..b56a52e 100644 --- a/src/Evaluator/EvalIfExpression.php +++ b/src/Lang/Evaluator/EvalIfExpression.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Expressions\IfExpression; -use MonkeyLang\Ast\Statements\BlockStatement; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; +use MonkeyLang\Lang\Ast\Expressions\IfExpression; +use MonkeyLang\Lang\Ast\Statements\BlockStatement; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; final readonly class EvalIfExpression { diff --git a/src/Evaluator/EvalIndexExpression.php b/src/Lang/Evaluator/EvalIndexExpression.php similarity index 75% rename from src/Evaluator/EvalIndexExpression.php rename to src/Lang/Evaluator/EvalIndexExpression.php index 402236a..5840129 100644 --- a/src/Evaluator/EvalIndexExpression.php +++ b/src/Lang/Evaluator/EvalIndexExpression.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; - -use MonkeyLang\Ast\Expressions\IndexExpression; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\IntegerObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; +namespace MonkeyLang\Lang\Evaluator; + +use MonkeyLang\Lang\Ast\Expressions\IndexExpression; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\IntegerObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; final readonly class EvalIndexExpression { diff --git a/src/Evaluator/EvalLetStatement.php b/src/Lang/Evaluator/EvalLetStatement.php similarity index 79% rename from src/Evaluator/EvalLetStatement.php rename to src/Lang/Evaluator/EvalLetStatement.php index 7437fec..c3f3aa1 100644 --- a/src/Evaluator/EvalLetStatement.php +++ b/src/Lang/Evaluator/EvalLetStatement.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Statements\LetStatement; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Ast\Statements\LetStatement; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; final readonly class EvalLetStatement { diff --git a/src/Evaluator/EvalMinusUnaryOperatorExpression.php b/src/Lang/Evaluator/EvalMinusUnaryOperatorExpression.php similarity index 70% rename from src/Evaluator/EvalMinusUnaryOperatorExpression.php rename to src/Lang/Evaluator/EvalMinusUnaryOperatorExpression.php index 2abb607..47418f5 100644 --- a/src/Evaluator/EvalMinusUnaryOperatorExpression.php +++ b/src/Lang/Evaluator/EvalMinusUnaryOperatorExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\IntegerObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\IntegerObject; +use MonkeyLang\Lang\Object\MonkeyObject; final class EvalMinusUnaryOperatorExpression { diff --git a/src/Evaluator/EvalNotOperatorExpression.php b/src/Lang/Evaluator/EvalNotOperatorExpression.php similarity index 72% rename from src/Evaluator/EvalNotOperatorExpression.php rename to src/Lang/Evaluator/EvalNotOperatorExpression.php index 46743b8..8f33739 100644 --- a/src/Evaluator/EvalNotOperatorExpression.php +++ b/src/Lang/Evaluator/EvalNotOperatorExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Object\BooleanObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; +use MonkeyLang\Lang\Object\BooleanObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; final class EvalNotOperatorExpression { diff --git a/src/Evaluator/EvalNumericBinaryExpression.php b/src/Lang/Evaluator/EvalNumericBinaryExpression.php similarity index 88% rename from src/Evaluator/EvalNumericBinaryExpression.php rename to src/Lang/Evaluator/EvalNumericBinaryExpression.php index 5b53000..89ce950 100644 --- a/src/Evaluator/EvalNumericBinaryExpression.php +++ b/src/Lang/Evaluator/EvalNumericBinaryExpression.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Object\BooleanObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\BooleanObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; final class EvalNumericBinaryExpression { diff --git a/src/Evaluator/EvalPostfixExpression.php b/src/Lang/Evaluator/EvalPostfixExpression.php similarity index 86% rename from src/Evaluator/EvalPostfixExpression.php rename to src/Lang/Evaluator/EvalPostfixExpression.php index f022174..bf674a2 100644 --- a/src/Evaluator/EvalPostfixExpression.php +++ b/src/Lang/Evaluator/EvalPostfixExpression.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Expressions\PostfixExpression; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\IntegerObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Ast\Expressions\PostfixExpression; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\IntegerObject; +use MonkeyLang\Lang\Object\MonkeyObject; final readonly class EvalPostfixExpression { diff --git a/src/Evaluator/EvalProgram.php b/src/Lang/Evaluator/EvalProgram.php similarity index 74% rename from src/Evaluator/EvalProgram.php rename to src/Lang/Evaluator/EvalProgram.php index b1d4854..ecf1b60 100644 --- a/src/Evaluator/EvalProgram.php +++ b/src/Lang/Evaluator/EvalProgram.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Program; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; -use MonkeyLang\Object\ReturnValueObject; +use MonkeyLang\Lang\Ast\Program; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; +use MonkeyLang\Lang\Object\ReturnValueObject; final readonly class EvalProgram { diff --git a/src/Evaluator/EvalReturnStatement.php b/src/Lang/Evaluator/EvalReturnStatement.php similarity index 71% rename from src/Evaluator/EvalReturnStatement.php rename to src/Lang/Evaluator/EvalReturnStatement.php index 75fd6f3..a56b22a 100644 --- a/src/Evaluator/EvalReturnStatement.php +++ b/src/Lang/Evaluator/EvalReturnStatement.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Statements\ReturnStatement; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\ReturnValueObject; +use MonkeyLang\Lang\Ast\Statements\ReturnStatement; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\ReturnValueObject; final readonly class EvalReturnStatement { diff --git a/src/Evaluator/EvalStringBinaryExpression.php b/src/Lang/Evaluator/EvalStringBinaryExpression.php similarity index 74% rename from src/Evaluator/EvalStringBinaryExpression.php rename to src/Lang/Evaluator/EvalStringBinaryExpression.php index a667893..08a90ad 100644 --- a/src/Evaluator/EvalStringBinaryExpression.php +++ b/src/Lang/Evaluator/EvalStringBinaryExpression.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Object\BooleanObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\StringObject; +use MonkeyLang\Lang\Object\BooleanObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\StringObject; final class EvalStringBinaryExpression { diff --git a/src/Evaluator/EvalUnaryExpression.php b/src/Lang/Evaluator/EvalUnaryExpression.php similarity index 82% rename from src/Evaluator/EvalUnaryExpression.php rename to src/Lang/Evaluator/EvalUnaryExpression.php index 5a01ce9..b29b2ae 100644 --- a/src/Evaluator/EvalUnaryExpression.php +++ b/src/Lang/Evaluator/EvalUnaryExpression.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; final class EvalUnaryExpression { diff --git a/src/Evaluator/EvalWhileExpression.php b/src/Lang/Evaluator/EvalWhileExpression.php similarity index 80% rename from src/Evaluator/EvalWhileExpression.php rename to src/Lang/Evaluator/EvalWhileExpression.php index 0042895..c6dc650 100644 --- a/src/Evaluator/EvalWhileExpression.php +++ b/src/Lang/Evaluator/EvalWhileExpression.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Expressions\WhileExpression; -use MonkeyLang\Object\BooleanObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\MonkeyObject; +use MonkeyLang\Lang\Ast\Expressions\WhileExpression; +use MonkeyLang\Lang\Object\BooleanObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\MonkeyObject; final readonly class EvalWhileExpression { diff --git a/src/Evaluator/Evaluator.php b/src/Lang/Evaluator/Evaluator.php similarity index 66% rename from src/Evaluator/Evaluator.php rename to src/Lang/Evaluator/Evaluator.php index 0f72e55..40a6bf3 100644 --- a/src/Evaluator/Evaluator.php +++ b/src/Lang/Evaluator/Evaluator.php @@ -2,45 +2,45 @@ declare(strict_types=1); -namespace MonkeyLang\Evaluator; +namespace MonkeyLang\Lang\Evaluator; -use MonkeyLang\Ast\Expressions\BinaryExpression; -use MonkeyLang\Ast\Expressions\CallExpression; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Ast\Expressions\IfExpression; -use MonkeyLang\Ast\Expressions\IndexExpression; -use MonkeyLang\Ast\Expressions\PostfixExpression; -use MonkeyLang\Ast\Expressions\UnaryExpression; -use MonkeyLang\Ast\Expressions\WhileExpression; -use MonkeyLang\Ast\Node; -use MonkeyLang\Ast\Program; -use MonkeyLang\Ast\Statements\AssignStatement; -use MonkeyLang\Ast\Statements\BlockStatement; -use MonkeyLang\Ast\Statements\ExpressionStatement; -use MonkeyLang\Ast\Statements\LetStatement; -use MonkeyLang\Ast\Statements\ReturnStatement; -use MonkeyLang\Ast\Types\ArrayLiteral; -use MonkeyLang\Ast\Types\BooleanLiteral; -use MonkeyLang\Ast\Types\FloatLiteral; -use MonkeyLang\Ast\Types\FunctionLiteral; -use MonkeyLang\Ast\Types\IntegerLiteral; -use MonkeyLang\Ast\Types\StringLiteral; -use MonkeyLang\Evaluator\Builtin\EvalFirstFunction; -use MonkeyLang\Evaluator\Builtin\EvalLastFunction; -use MonkeyLang\Evaluator\Builtin\EvalLenFunction; -use MonkeyLang\Evaluator\Builtin\EvalMapFunction; -use MonkeyLang\Evaluator\Builtin\EvalPushFunction; -use MonkeyLang\Evaluator\Builtin\EvalPutsFunction; -use MonkeyLang\Evaluator\Builtin\EvalSliceFunction; -use MonkeyLang\Object\BooleanObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\FloatObject; -use MonkeyLang\Object\FunctionObject; -use MonkeyLang\Object\IntegerObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; -use MonkeyLang\Object\StringObject; +use MonkeyLang\Lang\Ast\Expressions\BinaryExpression; +use MonkeyLang\Lang\Ast\Expressions\CallExpression; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Ast\Expressions\IfExpression; +use MonkeyLang\Lang\Ast\Expressions\IndexExpression; +use MonkeyLang\Lang\Ast\Expressions\PostfixExpression; +use MonkeyLang\Lang\Ast\Expressions\UnaryExpression; +use MonkeyLang\Lang\Ast\Expressions\WhileExpression; +use MonkeyLang\Lang\Ast\Node; +use MonkeyLang\Lang\Ast\Program; +use MonkeyLang\Lang\Ast\Statements\AssignStatement; +use MonkeyLang\Lang\Ast\Statements\BlockStatement; +use MonkeyLang\Lang\Ast\Statements\ExpressionStatement; +use MonkeyLang\Lang\Ast\Statements\LetStatement; +use MonkeyLang\Lang\Ast\Statements\ReturnStatement; +use MonkeyLang\Lang\Ast\Types\ArrayLiteral; +use MonkeyLang\Lang\Ast\Types\BooleanLiteral; +use MonkeyLang\Lang\Ast\Types\FloatLiteral; +use MonkeyLang\Lang\Ast\Types\FunctionLiteral; +use MonkeyLang\Lang\Ast\Types\IntegerLiteral; +use MonkeyLang\Lang\Ast\Types\StringLiteral; +use MonkeyLang\Lang\Evaluator\Builtin\EvalFirstFunction; +use MonkeyLang\Lang\Evaluator\Builtin\EvalLastFunction; +use MonkeyLang\Lang\Evaluator\Builtin\EvalLenFunction; +use MonkeyLang\Lang\Evaluator\Builtin\EvalMapFunction; +use MonkeyLang\Lang\Evaluator\Builtin\EvalPushFunction; +use MonkeyLang\Lang\Evaluator\Builtin\EvalPutsFunction; +use MonkeyLang\Lang\Evaluator\Builtin\EvalSliceFunction; +use MonkeyLang\Lang\Object\BooleanObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\FloatObject; +use MonkeyLang\Lang\Object\FunctionObject; +use MonkeyLang\Lang\Object\IntegerObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; +use MonkeyLang\Lang\Object\StringObject; use function call_user_func; diff --git a/src/Lexer/Char.php b/src/Lang/Lexer/Char.php similarity index 97% rename from src/Lexer/Char.php rename to src/Lang/Lexer/Char.php index 3022b87..39c4b90 100644 --- a/src/Lexer/Char.php +++ b/src/Lang/Lexer/Char.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Lexer; +namespace MonkeyLang\Lang\Lexer; use Stringable; diff --git a/src/Lexer/Input.php b/src/Lang/Lexer/Input.php similarity index 94% rename from src/Lexer/Input.php rename to src/Lang/Lexer/Input.php index a9a6d37..0fc3e46 100644 --- a/src/Lexer/Input.php +++ b/src/Lang/Lexer/Input.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Lexer; +namespace MonkeyLang\Lang\Lexer; final class Input { diff --git a/src/Lexer/Lexer.php b/src/Lang/Lexer/Lexer.php similarity index 97% rename from src/Lexer/Lexer.php rename to src/Lang/Lexer/Lexer.php index 57ba799..11ae09c 100644 --- a/src/Lexer/Lexer.php +++ b/src/Lang/Lexer/Lexer.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Lexer; +namespace MonkeyLang\Lang\Lexer; -use MonkeyLang\Token\Token; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Token\Token; +use MonkeyLang\Lang\Token\TokenType; final class Lexer { diff --git a/src/Object/ArrayObject.php b/src/Lang/Object/ArrayObject.php similarity index 96% rename from src/Object/ArrayObject.php rename to src/Lang/Object/ArrayObject.php index 2f5cac3..3728cae 100644 --- a/src/Object/ArrayObject.php +++ b/src/Lang/Object/ArrayObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; use function count; use function sprintf; diff --git a/src/Object/BooleanObject.php b/src/Lang/Object/BooleanObject.php similarity index 95% rename from src/Object/BooleanObject.php rename to src/Lang/Object/BooleanObject.php index 79a9382..502aab6 100644 --- a/src/Object/BooleanObject.php +++ b/src/Lang/Object/BooleanObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; final readonly class BooleanObject extends MonkeyObject { diff --git a/src/Object/BuiltinFunctionObject.php b/src/Lang/Object/BuiltinFunctionObject.php similarity index 93% rename from src/Object/BuiltinFunctionObject.php rename to src/Lang/Object/BuiltinFunctionObject.php index 6d2708c..8e80f23 100644 --- a/src/Object/BuiltinFunctionObject.php +++ b/src/Lang/Object/BuiltinFunctionObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; use Closure; diff --git a/src/Object/ErrorObject.php b/src/Lang/Object/ErrorObject.php similarity index 97% rename from src/Object/ErrorObject.php rename to src/Lang/Object/ErrorObject.php index 7331a56..413a4ac 100644 --- a/src/Object/ErrorObject.php +++ b/src/Lang/Object/ErrorObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; use function sprintf; diff --git a/src/Object/FloatObject.php b/src/Lang/Object/FloatObject.php similarity index 93% rename from src/Object/FloatObject.php rename to src/Lang/Object/FloatObject.php index 206bbcd..b594a91 100644 --- a/src/Object/FloatObject.php +++ b/src/Lang/Object/FloatObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; use function sprintf; diff --git a/src/Object/FunctionObject.php b/src/Lang/Object/FunctionObject.php similarity index 83% rename from src/Object/FunctionObject.php rename to src/Lang/Object/FunctionObject.php index 6aba678..3b1b561 100644 --- a/src/Object/FunctionObject.php +++ b/src/Lang/Object/FunctionObject.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Ast\Statements\BlockStatement; -use MonkeyLang\Evaluator\Environment; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Ast\Statements\BlockStatement; +use MonkeyLang\Lang\Evaluator\Environment; use function sprintf; diff --git a/src/Object/IntegerObject.php b/src/Lang/Object/IntegerObject.php similarity index 93% rename from src/Object/IntegerObject.php rename to src/Lang/Object/IntegerObject.php index 59dbbfa..608f90b 100644 --- a/src/Object/IntegerObject.php +++ b/src/Lang/Object/IntegerObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; use function sprintf; diff --git a/src/Object/MonkeyObject.php b/src/Lang/Object/MonkeyObject.php similarity index 95% rename from src/Object/MonkeyObject.php rename to src/Lang/Object/MonkeyObject.php index 1c1954f..0abd0b2 100644 --- a/src/Object/MonkeyObject.php +++ b/src/Lang/Object/MonkeyObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; abstract readonly class MonkeyObject { diff --git a/src/Object/MonkeyObjectType.php b/src/Lang/Object/MonkeyObjectType.php similarity index 96% rename from src/Object/MonkeyObjectType.php rename to src/Lang/Object/MonkeyObjectType.php index 867388d..cbadf2e 100644 --- a/src/Object/MonkeyObjectType.php +++ b/src/Lang/Object/MonkeyObjectType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; enum MonkeyObjectType: int { diff --git a/src/Object/NullObject.php b/src/Lang/Object/NullObject.php similarity index 93% rename from src/Object/NullObject.php rename to src/Lang/Object/NullObject.php index fbec8f3..f9d91ee 100644 --- a/src/Object/NullObject.php +++ b/src/Lang/Object/NullObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; final readonly class NullObject extends MonkeyObject { diff --git a/src/Object/ReturnValueObject.php b/src/Lang/Object/ReturnValueObject.php similarity index 93% rename from src/Object/ReturnValueObject.php rename to src/Lang/Object/ReturnValueObject.php index fa631f1..2f37c5f 100644 --- a/src/Object/ReturnValueObject.php +++ b/src/Lang/Object/ReturnValueObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; final readonly class ReturnValueObject extends MonkeyObject { diff --git a/src/Object/StringObject.php b/src/Lang/Object/StringObject.php similarity index 94% rename from src/Object/StringObject.php rename to src/Lang/Object/StringObject.php index 9ebafa3..ba6ffed 100644 --- a/src/Object/StringObject.php +++ b/src/Lang/Object/StringObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Object; +namespace MonkeyLang\Lang\Object; final readonly class StringObject extends MonkeyObject { diff --git a/src/Parser/ExpressionListParser.php b/src/Lang/Parser/ExpressionListParser.php similarity index 86% rename from src/Parser/ExpressionListParser.php rename to src/Lang/Parser/ExpressionListParser.php index 730fd94..ff1b94c 100644 --- a/src/Parser/ExpressionListParser.php +++ b/src/Lang/Parser/ExpressionListParser.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Parser; +namespace MonkeyLang\Lang\Parser; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Token\TokenType; final class ExpressionListParser { diff --git a/src/Parser/FunctionParametersParser.php b/src/Lang/Parser/FunctionParametersParser.php similarity index 87% rename from src/Parser/FunctionParametersParser.php rename to src/Lang/Parser/FunctionParametersParser.php index a56783a..ab84438 100644 --- a/src/Parser/FunctionParametersParser.php +++ b/src/Lang/Parser/FunctionParametersParser.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Parser; +namespace MonkeyLang\Lang\Parser; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Token\TokenType; final class FunctionParametersParser { diff --git a/src/Parser/Parselet/ArrayParselet.php b/src/Lang/Parser/Parselet/ArrayParselet.php similarity index 61% rename from src/Parser/Parselet/ArrayParselet.php rename to src/Lang/Parser/Parselet/ArrayParselet.php index 8e5b851..de3bdde 100644 --- a/src/Parser/Parselet/ArrayParselet.php +++ b/src/Lang/Parser/Parselet/ArrayParselet.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Types\ArrayLiteral; -use MonkeyLang\Parser\ExpressionListParser; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Types\ArrayLiteral; +use MonkeyLang\Lang\Parser\ExpressionListParser; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Token\TokenType; final readonly class ArrayParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/BinaryOperatorParselet.php b/src/Lang/Parser/Parselet/BinaryOperatorParselet.php similarity index 75% rename from src/Parser/Parselet/BinaryOperatorParselet.php rename to src/Lang/Parser/Parselet/BinaryOperatorParselet.php index 2436183..f79a464 100644 --- a/src/Parser/Parselet/BinaryOperatorParselet.php +++ b/src/Lang/Parser/Parselet/BinaryOperatorParselet.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\BinaryExpression; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Parser\Parser; +use MonkeyLang\Lang\Ast\Expressions\BinaryExpression; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Parser\Parser; final readonly class BinaryOperatorParselet implements InfixParselet { diff --git a/src/Parser/Parselet/CallExpressionParselet.php b/src/Lang/Parser/Parselet/CallExpressionParselet.php similarity index 63% rename from src/Parser/Parselet/CallExpressionParselet.php rename to src/Lang/Parser/Parselet/CallExpressionParselet.php index 62469a0..f7db74c 100644 --- a/src/Parser/Parselet/CallExpressionParselet.php +++ b/src/Lang/Parser/Parselet/CallExpressionParselet.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\CallExpression; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Parser\ExpressionListParser; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\CallExpression; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Parser\ExpressionListParser; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Token\TokenType; final readonly class CallExpressionParselet implements InfixParselet { diff --git a/src/Parser/Parselet/FunctionLiteralParselet.php b/src/Lang/Parser/Parselet/FunctionLiteralParselet.php similarity index 67% rename from src/Parser/Parselet/FunctionLiteralParselet.php rename to src/Lang/Parser/Parselet/FunctionLiteralParselet.php index 5b1e734..113c24c 100644 --- a/src/Parser/Parselet/FunctionLiteralParselet.php +++ b/src/Lang/Parser/Parselet/FunctionLiteralParselet.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; - -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Types\FunctionLiteral; -use MonkeyLang\Parser\FunctionParametersParser; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Statements\BlockStatementParser; -use MonkeyLang\Token\TokenType; +namespace MonkeyLang\Lang\Parser\Parselet; + +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Types\FunctionLiteral; +use MonkeyLang\Lang\Parser\FunctionParametersParser; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Statements\BlockStatementParser; +use MonkeyLang\Lang\Token\TokenType; final readonly class FunctionLiteralParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/GroupedExpressionParselet.php b/src/Lang/Parser/Parselet/GroupedExpressionParselet.php similarity index 72% rename from src/Parser/Parselet/GroupedExpressionParselet.php rename to src/Lang/Parser/Parselet/GroupedExpressionParselet.php index 0a7e0bf..4743aef 100644 --- a/src/Parser/Parselet/GroupedExpressionParselet.php +++ b/src/Lang/Parser/Parselet/GroupedExpressionParselet.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Precedence; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Precedence; +use MonkeyLang\Lang\Token\TokenType; final readonly class GroupedExpressionParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/IdentifierParselet.php b/src/Lang/Parser/Parselet/IdentifierParselet.php similarity index 65% rename from src/Parser/Parselet/IdentifierParselet.php rename to src/Lang/Parser/Parselet/IdentifierParselet.php index 101562d..31466e8 100644 --- a/src/Parser/Parselet/IdentifierParselet.php +++ b/src/Lang/Parser/Parselet/IdentifierParselet.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Parser\Parser; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Parser\Parser; final readonly class IdentifierParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/IfExpressionParselet.php b/src/Lang/Parser/Parselet/IfExpressionParselet.php similarity index 79% rename from src/Parser/Parselet/IfExpressionParselet.php rename to src/Lang/Parser/Parselet/IfExpressionParselet.php index 3210176..ed787aa 100644 --- a/src/Parser/Parselet/IfExpressionParselet.php +++ b/src/Lang/Parser/Parselet/IfExpressionParselet.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; - -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\IfExpression; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Precedence; -use MonkeyLang\Parser\Statements\BlockStatementParser; -use MonkeyLang\Token\TokenType; +namespace MonkeyLang\Lang\Parser\Parselet; + +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\IfExpression; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Precedence; +use MonkeyLang\Lang\Parser\Statements\BlockStatementParser; +use MonkeyLang\Lang\Token\TokenType; final readonly class IfExpressionParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/IndexExpressionParselet.php b/src/Lang/Parser/Parselet/IndexExpressionParselet.php similarity index 72% rename from src/Parser/Parselet/IndexExpressionParselet.php rename to src/Lang/Parser/Parselet/IndexExpressionParselet.php index 70e544c..acd2ed2 100644 --- a/src/Parser/Parselet/IndexExpressionParselet.php +++ b/src/Lang/Parser/Parselet/IndexExpressionParselet.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\IndexExpression; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Precedence; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\IndexExpression; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Precedence; +use MonkeyLang\Lang\Token\TokenType; final readonly class IndexExpressionParselet implements InfixParselet { diff --git a/src/Parser/Parselet/InfixParselet.php b/src/Lang/Parser/Parselet/InfixParselet.php similarity index 58% rename from src/Parser/Parselet/InfixParselet.php rename to src/Lang/Parser/Parselet/InfixParselet.php index ed723a6..89f986c 100644 --- a/src/Parser/Parselet/InfixParselet.php +++ b/src/Lang/Parser/Parselet/InfixParselet.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\Expression; interface InfixParselet { diff --git a/src/Parser/Parselet/PostfixOperatorParselet.php b/src/Lang/Parser/Parselet/PostfixOperatorParselet.php similarity index 65% rename from src/Parser/Parselet/PostfixOperatorParselet.php rename to src/Lang/Parser/Parselet/PostfixOperatorParselet.php index 4a900ca..0aa796e 100644 --- a/src/Parser/Parselet/PostfixOperatorParselet.php +++ b/src/Lang/Parser/Parselet/PostfixOperatorParselet.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\PostfixExpression; -use MonkeyLang\Parser\Parser; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\PostfixExpression; +use MonkeyLang\Lang\Parser\Parser; final readonly class PostfixOperatorParselet implements PostfixParselet { diff --git a/src/Parser/Parselet/PostfixParselet.php b/src/Lang/Parser/Parselet/PostfixParselet.php similarity index 53% rename from src/Parser/Parselet/PostfixParselet.php rename to src/Lang/Parser/Parselet/PostfixParselet.php index 151830c..4fe251e 100644 --- a/src/Parser/Parselet/PostfixParselet.php +++ b/src/Lang/Parser/Parselet/PostfixParselet.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\Expression; interface PostfixParselet { diff --git a/src/Parser/Parselet/PrefixParselet.php b/src/Lang/Parser/Parselet/PrefixParselet.php similarity index 53% rename from src/Parser/Parselet/PrefixParselet.php rename to src/Lang/Parser/Parselet/PrefixParselet.php index 66c661a..f5bad8d 100644 --- a/src/Parser/Parselet/PrefixParselet.php +++ b/src/Lang/Parser/Parselet/PrefixParselet.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\Expression; interface PrefixParselet { diff --git a/src/Parser/Parselet/ScalarParselet.php b/src/Lang/Parser/Parselet/ScalarParselet.php similarity index 70% rename from src/Parser/Parselet/ScalarParselet.php rename to src/Lang/Parser/Parselet/ScalarParselet.php index 4a12258..389fa0f 100644 --- a/src/Parser/Parselet/ScalarParselet.php +++ b/src/Lang/Parser/Parselet/ScalarParselet.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; use InvalidArgumentException; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Types\BooleanLiteral; -use MonkeyLang\Ast\Types\FloatLiteral; -use MonkeyLang\Ast\Types\IntegerLiteral; -use MonkeyLang\Ast\Types\StringLiteral; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Types\BooleanLiteral; +use MonkeyLang\Lang\Ast\Types\FloatLiteral; +use MonkeyLang\Lang\Ast\Types\IntegerLiteral; +use MonkeyLang\Lang\Ast\Types\StringLiteral; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Token\TokenType; final class ScalarParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/UnaryOperatorParselet.php b/src/Lang/Parser/Parselet/UnaryOperatorParselet.php similarity index 69% rename from src/Parser/Parselet/UnaryOperatorParselet.php rename to src/Lang/Parser/Parselet/UnaryOperatorParselet.php index ed69bc8..795d9f7 100644 --- a/src/Parser/Parselet/UnaryOperatorParselet.php +++ b/src/Lang/Parser/Parselet/UnaryOperatorParselet.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; +namespace MonkeyLang\Lang\Parser\Parselet; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\UnaryExpression; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Precedence; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\UnaryExpression; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Precedence; final readonly class UnaryOperatorParselet implements PrefixParselet { diff --git a/src/Parser/Parselet/WhileExpressionParselet.php b/src/Lang/Parser/Parselet/WhileExpressionParselet.php similarity index 73% rename from src/Parser/Parselet/WhileExpressionParselet.php rename to src/Lang/Parser/Parselet/WhileExpressionParselet.php index f8255f4..012a35b 100644 --- a/src/Parser/Parselet/WhileExpressionParselet.php +++ b/src/Lang/Parser/Parselet/WhileExpressionParselet.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Parselet; - -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\WhileExpression; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Precedence; -use MonkeyLang\Parser\Statements\BlockStatementParser; -use MonkeyLang\Token\TokenType; +namespace MonkeyLang\Lang\Parser\Parselet; + +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\WhileExpression; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Precedence; +use MonkeyLang\Lang\Parser\Statements\BlockStatementParser; +use MonkeyLang\Lang\Token\TokenType; final readonly class WhileExpressionParselet implements PrefixParselet { diff --git a/src/Parser/Parser.php b/src/Lang/Parser/Parser.php similarity index 85% rename from src/Parser/Parser.php rename to src/Lang/Parser/Parser.php index 76e2173..b928af1 100644 --- a/src/Parser/Parser.php +++ b/src/Lang/Parser/Parser.php @@ -2,27 +2,27 @@ declare(strict_types=1); -namespace MonkeyLang\Parser; - -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Lexer\Lexer; -use MonkeyLang\Parser\Parselet\ArrayParselet; -use MonkeyLang\Parser\Parselet\BinaryOperatorParselet; -use MonkeyLang\Parser\Parselet\CallExpressionParselet; -use MonkeyLang\Parser\Parselet\FunctionLiteralParselet; -use MonkeyLang\Parser\Parselet\GroupedExpressionParselet; -use MonkeyLang\Parser\Parselet\IdentifierParselet; -use MonkeyLang\Parser\Parselet\IfExpressionParselet; -use MonkeyLang\Parser\Parselet\IndexExpressionParselet; -use MonkeyLang\Parser\Parselet\InfixParselet; -use MonkeyLang\Parser\Parselet\PostfixOperatorParselet; -use MonkeyLang\Parser\Parselet\PostfixParselet; -use MonkeyLang\Parser\Parselet\PrefixParselet; -use MonkeyLang\Parser\Parselet\ScalarParselet; -use MonkeyLang\Parser\Parselet\UnaryOperatorParselet; -use MonkeyLang\Parser\Parselet\WhileExpressionParselet; -use MonkeyLang\Token\Token; -use MonkeyLang\Token\TokenType; +namespace MonkeyLang\Lang\Parser; + +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Lexer\Lexer; +use MonkeyLang\Lang\Parser\Parselet\ArrayParselet; +use MonkeyLang\Lang\Parser\Parselet\BinaryOperatorParselet; +use MonkeyLang\Lang\Parser\Parselet\CallExpressionParselet; +use MonkeyLang\Lang\Parser\Parselet\FunctionLiteralParselet; +use MonkeyLang\Lang\Parser\Parselet\GroupedExpressionParselet; +use MonkeyLang\Lang\Parser\Parselet\IdentifierParselet; +use MonkeyLang\Lang\Parser\Parselet\IfExpressionParselet; +use MonkeyLang\Lang\Parser\Parselet\IndexExpressionParselet; +use MonkeyLang\Lang\Parser\Parselet\InfixParselet; +use MonkeyLang\Lang\Parser\Parselet\PostfixOperatorParselet; +use MonkeyLang\Lang\Parser\Parselet\PostfixParselet; +use MonkeyLang\Lang\Parser\Parselet\PrefixParselet; +use MonkeyLang\Lang\Parser\Parselet\ScalarParselet; +use MonkeyLang\Lang\Parser\Parselet\UnaryOperatorParselet; +use MonkeyLang\Lang\Parser\Parselet\WhileExpressionParselet; +use MonkeyLang\Lang\Token\Token; +use MonkeyLang\Lang\Token\TokenType; use function sprintf; diff --git a/src/Parser/Precedence.php b/src/Lang/Parser/Precedence.php similarity index 90% rename from src/Parser/Precedence.php rename to src/Lang/Parser/Precedence.php index 9fd734f..ad8d25e 100644 --- a/src/Parser/Precedence.php +++ b/src/Lang/Parser/Precedence.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Parser; +namespace MonkeyLang\Lang\Parser; enum Precedence: int { diff --git a/src/Parser/ProgramParser.php b/src/Lang/Parser/ProgramParser.php similarity index 69% rename from src/Parser/ProgramParser.php rename to src/Lang/Parser/ProgramParser.php index 1e988b8..6cc558c 100644 --- a/src/Parser/ProgramParser.php +++ b/src/Lang/Parser/ProgramParser.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Parser; +namespace MonkeyLang\Lang\Parser; -use MonkeyLang\Ast\Program; -use MonkeyLang\Ast\Statements\Statement; -use MonkeyLang\Parser\Statements\StatementParser; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Program; +use MonkeyLang\Lang\Ast\Statements\Statement; +use MonkeyLang\Lang\Parser\Statements\StatementParser; +use MonkeyLang\Lang\Token\TokenType; final class ProgramParser { diff --git a/src/Parser/Statements/AssignStatementParser.php b/src/Lang/Parser/Statements/AssignStatementParser.php similarity index 66% rename from src/Parser/Statements/AssignStatementParser.php rename to src/Lang/Parser/Statements/AssignStatementParser.php index a51b524..541f849 100644 --- a/src/Parser/Statements/AssignStatementParser.php +++ b/src/Lang/Parser/Statements/AssignStatementParser.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Statements; - -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Ast\Statements\AssignStatement; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Precedence; -use MonkeyLang\Token\TokenType; +namespace MonkeyLang\Lang\Parser\Statements; + +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Ast\Statements\AssignStatement; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Precedence; +use MonkeyLang\Lang\Token\TokenType; final class AssignStatementParser { diff --git a/src/Parser/Statements/BlockStatementParser.php b/src/Lang/Parser/Statements/BlockStatementParser.php similarity index 75% rename from src/Parser/Statements/BlockStatementParser.php rename to src/Lang/Parser/Statements/BlockStatementParser.php index 85bddd1..0d54c6d 100644 --- a/src/Parser/Statements/BlockStatementParser.php +++ b/src/Lang/Parser/Statements/BlockStatementParser.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Statements; +namespace MonkeyLang\Lang\Parser\Statements; -use MonkeyLang\Ast\Statements\BlockStatement; -use MonkeyLang\Ast\Statements\Statement; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Statements\BlockStatement; +use MonkeyLang\Lang\Ast\Statements\Statement; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Token\TokenType; final class BlockStatementParser { diff --git a/src/Parser/Statements/ExpressionStatementParser.php b/src/Lang/Parser/Statements/ExpressionStatementParser.php similarity index 67% rename from src/Parser/Statements/ExpressionStatementParser.php rename to src/Lang/Parser/Statements/ExpressionStatementParser.php index 6181b64..f48679e 100644 --- a/src/Parser/Statements/ExpressionStatementParser.php +++ b/src/Lang/Parser/Statements/ExpressionStatementParser.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Statements; +namespace MonkeyLang\Lang\Parser\Statements; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Statements\ExpressionStatement; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Precedence; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Statements\ExpressionStatement; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Precedence; +use MonkeyLang\Lang\Token\TokenType; final class ExpressionStatementParser { diff --git a/src/Parser/Statements/LetStatementParser.php b/src/Lang/Parser/Statements/LetStatementParser.php similarity index 72% rename from src/Parser/Statements/LetStatementParser.php rename to src/Lang/Parser/Statements/LetStatementParser.php index 01180f2..25cb50f 100644 --- a/src/Parser/Statements/LetStatementParser.php +++ b/src/Lang/Parser/Statements/LetStatementParser.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Statements; - -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Ast\Statements\LetStatement; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Precedence; -use MonkeyLang\Token\TokenType; +namespace MonkeyLang\Lang\Parser\Statements; + +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Ast\Statements\LetStatement; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Precedence; +use MonkeyLang\Lang\Token\TokenType; final class LetStatementParser { diff --git a/src/Parser/Statements/ReturnStatementParser.php b/src/Lang/Parser/Statements/ReturnStatementParser.php similarity index 66% rename from src/Parser/Statements/ReturnStatementParser.php rename to src/Lang/Parser/Statements/ReturnStatementParser.php index c6f7b32..ee15495 100644 --- a/src/Parser/Statements/ReturnStatementParser.php +++ b/src/Lang/Parser/Statements/ReturnStatementParser.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Statements; +namespace MonkeyLang\Lang\Parser\Statements; -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Statements\ReturnStatement; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\Precedence; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Statements\ReturnStatement; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\Precedence; +use MonkeyLang\Lang\Token\TokenType; final class ReturnStatementParser { diff --git a/src/Parser/Statements/StatementParser.php b/src/Lang/Parser/Statements/StatementParser.php similarity index 79% rename from src/Parser/Statements/StatementParser.php rename to src/Lang/Parser/Statements/StatementParser.php index 4614e25..57734e3 100644 --- a/src/Parser/Statements/StatementParser.php +++ b/src/Lang/Parser/Statements/StatementParser.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace MonkeyLang\Parser\Statements; +namespace MonkeyLang\Lang\Parser\Statements; -use MonkeyLang\Ast\Statements\Statement; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Statements\Statement; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Token\TokenType; final class StatementParser { diff --git a/src/Support/StringBuilder.php b/src/Lang/Support/StringBuilder.php similarity index 95% rename from src/Support/StringBuilder.php rename to src/Lang/Support/StringBuilder.php index 9181a5a..cdc6f9a 100644 --- a/src/Support/StringBuilder.php +++ b/src/Lang/Support/StringBuilder.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Support; +namespace MonkeyLang\Lang\Support; use Stringable; diff --git a/src/Token/Token.php b/src/Lang/Token/Token.php similarity index 94% rename from src/Token/Token.php rename to src/Lang/Token/Token.php index 40d0f41..2a2d1c3 100644 --- a/src/Token/Token.php +++ b/src/Lang/Token/Token.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace MonkeyLang\Token; +namespace MonkeyLang\Lang\Token; final readonly class Token { diff --git a/src/Token/TokenType.php b/src/Lang/Token/TokenType.php similarity index 97% rename from src/Token/TokenType.php rename to src/Lang/Token/TokenType.php index ef5f8f6..cc97eee 100644 --- a/src/Token/TokenType.php +++ b/src/Lang/Token/TokenType.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace MonkeyLang\Token; +namespace MonkeyLang\Lang\Token; -use MonkeyLang\Lexer\Char; -use MonkeyLang\Parser\Precedence; +use MonkeyLang\Lang\Lexer\Char; +use MonkeyLang\Lang\Parser\Precedence; enum TokenType: int { diff --git a/src/Monkey/Command/RunFileCommand.php b/src/Monkey/Command/RunFileCommand.php index dc68017..e678736 100644 --- a/src/Monkey/Command/RunFileCommand.php +++ b/src/Monkey/Command/RunFileCommand.php @@ -4,15 +4,15 @@ namespace MonkeyLang\Monkey\Command; -use MonkeyLang\Evaluator\Environment; -use MonkeyLang\Evaluator\Evaluator; -use MonkeyLang\Lexer\Lexer; +use MonkeyLang\Lang\Evaluator\Environment; +use MonkeyLang\Lang\Evaluator\Evaluator; +use MonkeyLang\Lang\Lexer\Lexer; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\ProgramParser; use MonkeyLang\Monkey\Config\Configuration; use MonkeyLang\Monkey\IO\OutputFormatter; use MonkeyLang\Monkey\Performance\PerformanceTracker; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\ProgramParser; use RuntimeException; use Throwable; diff --git a/src/Monkey/IO/OutputFormatter.php b/src/Monkey/IO/OutputFormatter.php index 9c59006..1b9f112 100644 --- a/src/Monkey/IO/OutputFormatter.php +++ b/src/Monkey/IO/OutputFormatter.php @@ -4,9 +4,9 @@ namespace MonkeyLang\Monkey\IO; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\NullObject; use MonkeyLang\Monkey\Performance\PerformanceMetrics; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\NullObject; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\TableStyle; diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php index ab44c64..955eaf1 100644 --- a/src/Monkey/Repl/ReplManager.php +++ b/src/Monkey/Repl/ReplManager.php @@ -4,17 +4,17 @@ namespace MonkeyLang\Monkey\Repl; -use MonkeyLang\Evaluator\Environment; -use MonkeyLang\Evaluator\Evaluator; -use MonkeyLang\Lexer\Lexer; +use MonkeyLang\Lang\Evaluator\Environment; +use MonkeyLang\Lang\Evaluator\Evaluator; +use MonkeyLang\Lang\Lexer\Lexer; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\ProgramParser; use MonkeyLang\Monkey\Config\Configuration; use MonkeyLang\Monkey\Exceptions\MonkeyRuntimeException; use MonkeyLang\Monkey\IO\InputReader; use MonkeyLang\Monkey\IO\OutputFormatter; use MonkeyLang\Monkey\Performance\PerformanceTracker; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\ProgramParser; use Throwable; use const PHP_OS_FAMILY; diff --git a/tests/AstTest.php b/tests/AstTest.php index 8de3107..ddfc408 100644 --- a/tests/AstTest.php +++ b/tests/AstTest.php @@ -4,12 +4,12 @@ namespace Tests; -use MonkeyLang\Ast\Expressions\IdentifierExpression; -use MonkeyLang\Ast\Program; -use MonkeyLang\Ast\Statements\LetStatement; -use MonkeyLang\Ast\Types\IntegerLiteral; -use MonkeyLang\Token\Token; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Ast\Expressions\IdentifierExpression; +use MonkeyLang\Lang\Ast\Program; +use MonkeyLang\Lang\Ast\Statements\LetStatement; +use MonkeyLang\Lang\Ast\Types\IntegerLiteral; +use MonkeyLang\Lang\Token\Token; +use MonkeyLang\Lang\Token\TokenType; test('to string', function () { $program = new Program(); diff --git a/tests/EvaluatorTest.php b/tests/EvaluatorTest.php index f3f5441..2be2d29 100644 --- a/tests/EvaluatorTest.php +++ b/tests/EvaluatorTest.php @@ -4,16 +4,16 @@ namespace Tests; -use MonkeyLang\Object\ArrayObject; -use MonkeyLang\Object\BooleanObject; -use MonkeyLang\Object\ErrorObject; -use MonkeyLang\Object\FloatObject; -use MonkeyLang\Object\FunctionObject; -use MonkeyLang\Object\IntegerObject; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Object\MonkeyObjectType; -use MonkeyLang\Object\NullObject; -use MonkeyLang\Object\StringObject; +use MonkeyLang\Lang\Object\ArrayObject; +use MonkeyLang\Lang\Object\BooleanObject; +use MonkeyLang\Lang\Object\ErrorObject; +use MonkeyLang\Lang\Object\FloatObject; +use MonkeyLang\Lang\Object\FunctionObject; +use MonkeyLang\Lang\Object\IntegerObject; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Object\MonkeyObjectType; +use MonkeyLang\Lang\Object\NullObject; +use MonkeyLang\Lang\Object\StringObject; function testObjectValue(MonkeyObject $object, $expected) { diff --git a/tests/Helpers.php b/tests/Helpers.php index 47ba4a9..ece3ad6 100644 --- a/tests/Helpers.php +++ b/tests/Helpers.php @@ -2,16 +2,16 @@ declare(strict_types=1); -use MonkeyLang\Ast\Expressions\Expression; -use MonkeyLang\Ast\Program; -use MonkeyLang\Ast\Types\BooleanLiteral; -use MonkeyLang\Ast\Types\IntegerLiteral; -use MonkeyLang\Evaluator\Environment; -use MonkeyLang\Evaluator\Evaluator; -use MonkeyLang\Lexer\Lexer; -use MonkeyLang\Object\MonkeyObject; -use MonkeyLang\Parser\Parser; -use MonkeyLang\Parser\ProgramParser; +use MonkeyLang\Lang\Ast\Expressions\Expression; +use MonkeyLang\Lang\Ast\Program; +use MonkeyLang\Lang\Ast\Types\BooleanLiteral; +use MonkeyLang\Lang\Ast\Types\IntegerLiteral; +use MonkeyLang\Lang\Evaluator\Environment; +use MonkeyLang\Lang\Evaluator\Evaluator; +use MonkeyLang\Lang\Lexer\Lexer; +use MonkeyLang\Lang\Object\MonkeyObject; +use MonkeyLang\Lang\Parser\Parser; +use MonkeyLang\Lang\Parser\ProgramParser; function assertInfixExpression(Expression $expression, $leftValue, string $operator, $rightValue): void { diff --git a/tests/LexerTest.php b/tests/LexerTest.php index 1cc1e06..67868a1 100644 --- a/tests/LexerTest.php +++ b/tests/LexerTest.php @@ -4,8 +4,8 @@ namespace Tests; -use MonkeyLang\Lexer\Lexer; -use MonkeyLang\Token\TokenType; +use MonkeyLang\Lang\Lexer\Lexer; +use MonkeyLang\Lang\Token\TokenType; test('basic tokens', function () { $input = << Date: Sun, 15 Dec 2024 12:47:08 -0300 Subject: [PATCH 08/22] Update Monkey.php --- src/Monkey/Monkey.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Monkey/Monkey.php b/src/Monkey/Monkey.php index a123547..bd84f7f 100644 --- a/src/Monkey/Monkey.php +++ b/src/Monkey/Monkey.php @@ -25,6 +25,9 @@ public static function version(): string return self::VERSION; } + /** + * @param array $argv + */ public function run(array $argv): int { try { From f7fe5d2a34ce4517795a7a6e4859e386760907c0 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 12:48:00 -0300 Subject: [PATCH 09/22] Update VersionCommand.php --- src/Monkey/Command/VersionCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Monkey/Command/VersionCommand.php b/src/Monkey/Command/VersionCommand.php index ba06153..a822b65 100644 --- a/src/Monkey/Command/VersionCommand.php +++ b/src/Monkey/Command/VersionCommand.php @@ -6,6 +6,7 @@ use MonkeyLang\Monkey\Config\Configuration; use MonkeyLang\Monkey\IO\OutputFormatter; +use MonkeyLang\Monkey\Monkey; final readonly class VersionCommand implements Command { @@ -16,7 +17,7 @@ public function __construct( public function execute(Configuration $config): int { - $this->outputFormatter->write('Monkey Programming Language v 1.0'); + $this->outputFormatter->write('Monkey Programming Language v' . Monkey::version()); return 0; } From bfad30f832db18588d1f5dde2410c8131d1ec87e Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:02:07 -0300 Subject: [PATCH 10/22] Chore --- monkey | 15 +++++++++++---- src/Monkey/Command/CommandFactory.php | 7 +++---- src/Monkey/Config/Configuration.php | 6 ++++++ src/Monkey/Config/ConfigurationManager.php | 11 +++++++---- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/monkey b/monkey index 11f4a97..0369741 100755 --- a/monkey +++ b/monkey @@ -21,7 +21,12 @@ if (PHP_SAPI !== 'cli') { exit; } -if (!isset($GLOBALS['argv']) || !is_array($GLOBALS['argv'])) { +/** + * @var array $argv + */ +$argv = (array) ($GLOBALS['argv'] ?? []); + +if ($argv === []) { exit(1); } @@ -33,6 +38,7 @@ try { $outputFormatter = new OutputFormatter($output); $inputReader = new InputReader($input, $output, $questionHelper); $performanceTracker = new PerformanceTracker(); + $replManager = new ReplManager( $inputReader, $outputFormatter, @@ -40,16 +46,17 @@ try { ); $commandFactory = new CommandFactory( - //$inputReader, $outputFormatter, $performanceTracker, $replManager ); - $commandRunner = new CommandRunner($commandFactory); + $configManager = new ConfigurationManager(); + $commandRunner = new CommandRunner($commandFactory); $monkey = new Monkey($commandRunner, $configManager); - exit($monkey->run($GLOBALS['argv'])); + + exit($monkey->run($argv)); } catch (Throwable $e) { fwrite(STDERR, "Fatal error: {$e->getMessage()}\n"); exit(1); diff --git a/src/Monkey/Command/CommandFactory.php b/src/Monkey/Command/CommandFactory.php index fa72b52..face96c 100644 --- a/src/Monkey/Command/CommandFactory.php +++ b/src/Monkey/Command/CommandFactory.php @@ -11,6 +11,7 @@ final class CommandFactory { + /** @var array */ private array $commands = []; public function __construct( @@ -35,10 +36,8 @@ private function registerCommands(): void $this->commands = [ 'repl' => new ReplCommand($this->replManager, $this->outputFormatter), 'run' => new RunFileCommand($this->outputFormatter, $this->performanceTracker), - '--help' => new HelpCommand($this->outputFormatter), - '-h' => new HelpCommand($this->outputFormatter), - '--version' => new VersionCommand($this->outputFormatter), - '-v' => new VersionCommand($this->outputFormatter), + 'help' => new HelpCommand($this->outputFormatter), + 'version' => new VersionCommand($this->outputFormatter), ]; } } diff --git a/src/Monkey/Config/Configuration.php b/src/Monkey/Config/Configuration.php index 56eabe7..2845fb3 100644 --- a/src/Monkey/Config/Configuration.php +++ b/src/Monkey/Config/Configuration.php @@ -8,7 +8,13 @@ { public function __construct( public string $command, + /** + * @var array + */ public array $options, + /** + * @var array + */ public array $arguments, ) { } diff --git a/src/Monkey/Config/ConfigurationManager.php b/src/Monkey/Config/ConfigurationManager.php index 5f1d835..dcaab1a 100644 --- a/src/Monkey/Config/ConfigurationManager.php +++ b/src/Monkey/Config/ConfigurationManager.php @@ -11,10 +11,13 @@ final class ConfigurationManager { - private const array VALID_COMMANDS = ['repl', 'run', '--version', '-v', '--help', '-h']; + private const array VALID_COMMANDS = ['repl', 'run', 'version', 'help']; private const array VALID_OPTIONS = ['--debug', '--stats']; + /** + * @param array $argv + */ public function parseArguments(array $argv): Configuration { if (count($argv) <= 1) { @@ -28,14 +31,14 @@ public function parseArguments(array $argv): Configuration foreach ($argv as $index => $arg) { if ($index === 0) { continue; - } // Skip script name + } - if (str_starts_with((string)$arg, '--')) { + if (str_starts_with($arg, '--')) { if (!in_array($arg, self::VALID_OPTIONS)) { throw new RuntimeException("Invalid option: {$arg}"); } - $options[trim((string)$arg, '-')] = true; + $options[trim($arg, '-')] = true; } elseif ($command === '') { if (!in_array($arg, self::VALID_COMMANDS)) { throw new RuntimeException("Invalid command: {$arg}"); From 8571456644374dc89e2a1b81e5075262ededd77d Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:03:39 -0300 Subject: [PATCH 11/22] Chore --- monkey | 1 + rector.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/monkey b/monkey index 0369741..68810de 100755 --- a/monkey +++ b/monkey @@ -59,5 +59,6 @@ try { exit($monkey->run($argv)); } catch (Throwable $e) { fwrite(STDERR, "Fatal error: {$e->getMessage()}\n"); + exit(1); } diff --git a/rector.php b/rector.php index 7b89131..83f8d0a 100644 --- a/rector.php +++ b/rector.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; +use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\LevelSetList; @@ -29,6 +30,7 @@ ]) ->withSkip([ EncapsedStringsToSprintfRector::class, + PostIncDecToPreIncDecRector::class, ]) ->withPaths([ __DIR__ . '/src', From 49cc7d138e1d72affa5de847e4eafaae255589a8 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:05:30 -0300 Subject: [PATCH 12/22] Update ConfigurationManager.php --- src/Monkey/Config/ConfigurationManager.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Monkey/Config/ConfigurationManager.php b/src/Monkey/Config/ConfigurationManager.php index dcaab1a..f45cc05 100644 --- a/src/Monkey/Config/ConfigurationManager.php +++ b/src/Monkey/Config/ConfigurationManager.php @@ -21,7 +21,7 @@ final class ConfigurationManager public function parseArguments(array $argv): Configuration { if (count($argv) <= 1) { - throw new RuntimeException('No command specified'); + $argv[] = 'help'; } $options = []; @@ -50,11 +50,6 @@ public function parseArguments(array $argv): Configuration } } - // If no command was found after processing options - if ($command === '') { - $command = '--help'; - } - return new Configuration($command, $options, $arguments); } } From 9bc4ae77cd5694d51efef464bf42a0918a0f89d5 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:07:44 -0300 Subject: [PATCH 13/22] Update CommandFactory.php --- src/Monkey/Command/CommandFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Monkey/Command/CommandFactory.php b/src/Monkey/Command/CommandFactory.php index face96c..8941b08 100644 --- a/src/Monkey/Command/CommandFactory.php +++ b/src/Monkey/Command/CommandFactory.php @@ -34,7 +34,7 @@ public function create(string $commandName): Command private function registerCommands(): void { $this->commands = [ - 'repl' => new ReplCommand($this->replManager, $this->outputFormatter), + 'repl' => new ReplCommand($this->replManager), 'run' => new RunFileCommand($this->outputFormatter, $this->performanceTracker), 'help' => new HelpCommand($this->outputFormatter), 'version' => new VersionCommand($this->outputFormatter), From a12fbf3b8e271195d160f0c077d16863615b638d Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:11:04 -0300 Subject: [PATCH 14/22] Update ReplManager.php --- src/Monkey/Repl/ReplManager.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php index 955eaf1..25d1bad 100644 --- a/src/Monkey/Repl/ReplManager.php +++ b/src/Monkey/Repl/ReplManager.php @@ -35,7 +35,11 @@ final class ReplManager ':reset' => 'handleResetEnvironment', ]; - private bool $debugMode = false; + private bool $debugMode = false { + get { + return $this->debugMode; + } + } private bool $running = true; @@ -43,7 +47,11 @@ public function __construct( private readonly InputReader $inputReader, private readonly OutputFormatter $outputFormatter, private readonly PerformanceTracker $performanceTracker, - private Environment $environment = new Environment(), + private Environment $environment = new Environment() { + get { + return $this->environment; + } + }, private readonly Evaluator $evaluator = new Evaluator(), ) { } @@ -55,7 +63,7 @@ public function start(Configuration $config): int $this->showWelcomeBanner(); while ($this->running) { - $this->outputFormatter->write(''); // Add newline before prompt + $this->outputFormatter->write(''); $input = $this->inputReader->readLine(); if ($input === false) { @@ -97,16 +105,6 @@ public function start(Configuration $config): int } } - public function isDebugMode(): bool - { - return $this->debugMode; - } - - public function getEnvironment(): Environment - { - return $this->environment; - } - private function evaluateAndOutput(string $input, Configuration $config): void { if ($config->hasStats()) { From 252e0daa24687d2f30a08fef87b645a5ce92c1d6 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:25:16 -0300 Subject: [PATCH 15/22] chore --- src/Monkey/IO/OutputFormatter.php | 2 +- src/Monkey/Repl/ReplManager.php | 93 +++++++++---------------------- 2 files changed, 27 insertions(+), 68 deletions(-) diff --git a/src/Monkey/IO/OutputFormatter.php b/src/Monkey/IO/OutputFormatter.php index 1b9f112..abfcd87 100644 --- a/src/Monkey/IO/OutputFormatter.php +++ b/src/Monkey/IO/OutputFormatter.php @@ -20,7 +20,7 @@ final readonly class OutputFormatter { public function __construct( - private OutputInterface $output, + private(set) OutputInterface $output, ) { $this->configureStyles(); } diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php index 25d1bad..856c13c 100644 --- a/src/Monkey/Repl/ReplManager.php +++ b/src/Monkey/Repl/ReplManager.php @@ -15,26 +15,15 @@ use MonkeyLang\Monkey\IO\InputReader; use MonkeyLang\Monkey\IO\OutputFormatter; use MonkeyLang\Monkey\Performance\PerformanceTracker; +use Symfony\Component\Console\Helper\Table; +use Symfony\Component\Console\Helper\TableStyle; use Throwable; + use const PHP_OS_FAMILY; final class ReplManager { - private const array SPECIAL_COMMANDS = [ - ':q' => 'handleQuit', - ':quit' => 'handleQuit', - 'exit' => 'handleQuit', - ':h' => 'handleHelp', - ':help' => 'handleHelp', - ':c' => 'handleClear', - ':clear' => 'handleClear', - ':d' => 'handleDebugToggle', - ':debug' => 'handleDebugToggle', - ':r' => 'handleResetEnvironment', - ':reset' => 'handleResetEnvironment', - ]; - private bool $debugMode = false { get { return $this->debugMode; @@ -133,7 +122,7 @@ private function evaluate(string $input): MonkeyObject ); } - $program = (new ProgramParser())($parser); + $program = new ProgramParser()($parser); return $this->evaluator->eval($program, $this->environment); } @@ -142,10 +131,15 @@ private function handleSpecialCommand(string $input): bool { $trimmedInput = trim($input); - if (isset(self::SPECIAL_COMMANDS[$trimmedInput])) { - $method = self::SPECIAL_COMMANDS[$trimmedInput]; + $commands = [ + ':q' => fn(): bool => $this->handleQuit(), + ':quit' => fn(): bool => $this->handleQuit(), + ':c' => fn(): bool => $this->handleClear(), + ':clear' => fn(): bool => $this->handleClear(), + ]; - return $this->{$method}(); + if (isset($commands[$trimmedInput])) { + return $commands[$trimmedInput](); } return false; @@ -159,22 +153,6 @@ private function handleQuit(): bool return true; } - private function handleHelp(): bool - { - $this->outputFormatter->write(<<debugMode = !$this->debugMode; - $this->outputFormatter->write( - 'Debug mode: ' . ($this->debugMode ? 'Enabled' : 'Disabled'), - ); + $tableStyle = new TableStyle(); + $tableStyle + ->setHorizontalBorderChars('-') + ->setVerticalBorderChars('|') + ->setCrossingChars('+', '+', '+', '+', '+', '+', '+', '+', '+') + ->setPadType(STR_PAD_RIGHT); - return true; - } + $table = new Table($this->outputFormatter->output); + $table->setStyle($tableStyle); - private function handleResetEnvironment(): bool - { - $this->environment = new Environment(); - $this->outputFormatter->write('Environment has been reset'); + $table->setRows([ + ['šŸ’ Monkey Programming Language v1.0.0'], + ["Type ':c' for clear, ':q' to quit"], + ]); - return true; - } + $table->render(); - private function showWelcomeBanner(): void - { - $this->outputFormatter->write(<<outputFormatter->write(''); } } From c0afb181214bd7d6dad30f20aed46d6315ef918c Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:26:14 -0300 Subject: [PATCH 16/22] Update rector.php --- rector.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rector.php b/rector.php index 83f8d0a..865b8df 100644 --- a/rector.php +++ b/rector.php @@ -5,6 +5,7 @@ use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; use Rector\Config\RectorConfig; +use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; use Rector\Set\ValueObject\LevelSetList; return RectorConfig::configure() @@ -31,6 +32,7 @@ ->withSkip([ EncapsedStringsToSprintfRector::class, PostIncDecToPreIncDecRector::class, + ReadOnlyPropertyRector::class, ]) ->withPaths([ __DIR__ . '/src', From 588f5f1d30f244a360df52833013ccee19656e81 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:27:18 -0300 Subject: [PATCH 17/22] Update ReplManager.php --- src/Monkey/Repl/ReplManager.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php index 856c13c..5e3d573 100644 --- a/src/Monkey/Repl/ReplManager.php +++ b/src/Monkey/Repl/ReplManager.php @@ -168,15 +168,7 @@ private function handleClear(): bool private function showWelcomeBanner(): void { - $tableStyle = new TableStyle(); - $tableStyle - ->setHorizontalBorderChars('-') - ->setVerticalBorderChars('|') - ->setCrossingChars('+', '+', '+', '+', '+', '+', '+', '+', '+') - ->setPadType(STR_PAD_RIGHT); - $table = new Table($this->outputFormatter->output); - $table->setStyle($tableStyle); $table->setRows([ ['šŸ’ Monkey Programming Language v1.0.0'], From fa9e6ebe4561136207b465a13152a2f3401f2832 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:28:00 -0300 Subject: [PATCH 18/22] Chore --- src/Monkey/IO/OutputFormatter.php | 11 ----------- src/Monkey/Repl/ReplManager.php | 1 - 2 files changed, 12 deletions(-) diff --git a/src/Monkey/IO/OutputFormatter.php b/src/Monkey/IO/OutputFormatter.php index abfcd87..33fa948 100644 --- a/src/Monkey/IO/OutputFormatter.php +++ b/src/Monkey/IO/OutputFormatter.php @@ -9,14 +9,11 @@ use MonkeyLang\Monkey\Performance\PerformanceMetrics; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Helper\TableStyle; use Symfony\Component\Console\Output\OutputInterface; use function count; use function sprintf; -use const STR_PAD_RIGHT; - final readonly class OutputFormatter { public function __construct( @@ -56,15 +53,7 @@ public function writePerformanceStats(PerformanceMetrics $metrics): void $this->output->writeln(''); $this->output->writeln('Performance Statistics'); - $tableStyle = new TableStyle(); - $tableStyle - ->setHorizontalBorderChars('-') - ->setVerticalBorderChars('|') - ->setCrossingChars('+', '+', '+', '+', '+', '+', '+', '+', '+') - ->setPadType(STR_PAD_RIGHT); - $table = new Table($this->output); - $table->setStyle($tableStyle); $table->setRows([ ['Memory used', "{$this->formatBytes($metrics->memoryUsed)}"], diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php index 5e3d573..4845e55 100644 --- a/src/Monkey/Repl/ReplManager.php +++ b/src/Monkey/Repl/ReplManager.php @@ -16,7 +16,6 @@ use MonkeyLang\Monkey\IO\OutputFormatter; use MonkeyLang\Monkey\Performance\PerformanceTracker; use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Helper\TableStyle; use Throwable; From ecddc343e76bb13d903d45963705ffd35f7bfff5 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:32:04 -0300 Subject: [PATCH 19/22] Chore --- monkey | 17 ++++++++++------- src/Monkey/Command/CommandFactory.php | 2 +- src/Monkey/Repl/ReplManager.php | 6 ++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/monkey b/monkey index 68810de..c085e2d 100755 --- a/monkey +++ b/monkey @@ -40,21 +40,24 @@ try { $performanceTracker = new PerformanceTracker(); $replManager = new ReplManager( - $inputReader, - $outputFormatter, - $performanceTracker + inputReader: $inputReader, + outputFormatter: $outputFormatter, + performanceTracker: $performanceTracker ); $commandFactory = new CommandFactory( - $outputFormatter, - $performanceTracker, - $replManager + replManager: $replManager, + outputFormatter: $outputFormatter, + performanceTracker: $performanceTracker ); $configManager = new ConfigurationManager(); $commandRunner = new CommandRunner($commandFactory); - $monkey = new Monkey($commandRunner, $configManager); + $monkey = new Monkey( + commandRunner: $commandRunner, + configManager: $configManager + ); exit($monkey->run($argv)); } catch (Throwable $e) { diff --git a/src/Monkey/Command/CommandFactory.php b/src/Monkey/Command/CommandFactory.php index 8941b08..3d0fbe0 100644 --- a/src/Monkey/Command/CommandFactory.php +++ b/src/Monkey/Command/CommandFactory.php @@ -15,9 +15,9 @@ final class CommandFactory private array $commands = []; public function __construct( + private readonly ReplManager $replManager, private readonly OutputFormatter $outputFormatter, private readonly PerformanceTracker $performanceTracker, - private readonly ReplManager $replManager, ) { $this->registerCommands(); } diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php index 4845e55..5d718c0 100644 --- a/src/Monkey/Repl/ReplManager.php +++ b/src/Monkey/Repl/ReplManager.php @@ -55,7 +55,8 @@ public function start(Configuration $config): int $input = $this->inputReader->readLine(); if ($input === false) { - $this->outputFormatter->write("\nGoodbye!"); + $this->outputFormatter->write(''); + $this->outputFormatter->write("Goodbye!"); return 0; } @@ -147,7 +148,8 @@ private function handleSpecialCommand(string $input): bool private function handleQuit(): bool { $this->running = false; - $this->outputFormatter->write('Goodbye!'); + $this->outputFormatter->write(''); + $this->outputFormatter->write("Goodbye!"); return true; } From db1a349891d6c45441a219363cdfbb3cb0d0c9bb Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:35:27 -0300 Subject: [PATCH 20/22] Chore --- src/Monkey/IO/InputReader.php | 2 +- src/Monkey/Repl/ReplManager.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Monkey/IO/InputReader.php b/src/Monkey/IO/InputReader.php index ff3452b..1971434 100644 --- a/src/Monkey/IO/InputReader.php +++ b/src/Monkey/IO/InputReader.php @@ -23,7 +23,7 @@ public function __construct( public function readLine(string $prompt = 'āžœ '): string | false { - $question = new Question("{$prompt} "); + $question = new Question($prompt); try { $answer = $this->questionHelper->ask($this->input, $this->output, $question); diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php index 5d718c0..5f48ff4 100644 --- a/src/Monkey/Repl/ReplManager.php +++ b/src/Monkey/Repl/ReplManager.php @@ -48,7 +48,7 @@ public function start(Configuration $config): int { try { $this->debugMode = $config->hasDebug(); - $this->showWelcomeBanner(); + $this->welcome(); while ($this->running) { $this->outputFormatter->write(''); @@ -162,18 +162,19 @@ private function handleClear(): bool system('clear'); } - $this->showWelcomeBanner(); + $this->welcome(); return true; } - private function showWelcomeBanner(): void + private function welcome(): void { $table = new Table($this->outputFormatter->output); $table->setRows([ - ['šŸ’ Monkey Programming Language v1.0.0'], - ["Type ':c' for clear, ':q' to quit"], + ['šŸ’ Monkey Programming Language v1.0.0'], + [''], + ["Type :c for clear, :q to quit"], ]); $table->render(); From 05d6c30a5c93f841ef681649cef33dda32b0b9eb Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:37:02 -0300 Subject: [PATCH 21/22] Update ReplManager.php --- src/Monkey/Repl/ReplManager.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Monkey/Repl/ReplManager.php b/src/Monkey/Repl/ReplManager.php index 5f48ff4..26137e2 100644 --- a/src/Monkey/Repl/ReplManager.php +++ b/src/Monkey/Repl/ReplManager.php @@ -65,7 +65,7 @@ public function start(Configuration $config): int continue; } - if ($this->handleSpecialCommand($input)) { + if ($this->runCommand($input)) { continue; } @@ -127,25 +127,18 @@ private function evaluate(string $input): MonkeyObject return $this->evaluator->eval($program, $this->environment); } - private function handleSpecialCommand(string $input): bool + private function runCommand(string $input): bool { $trimmedInput = trim($input); - $commands = [ - ':q' => fn(): bool => $this->handleQuit(), - ':quit' => fn(): bool => $this->handleQuit(), - ':c' => fn(): bool => $this->handleClear(), - ':clear' => fn(): bool => $this->handleClear(), - ]; - - if (isset($commands[$trimmedInput])) { - return $commands[$trimmedInput](); - } - - return false; + return match ($trimmedInput) { + ':q', ':quit' => $this->quit(), + ':c', ':clear' => $this->clear(), + default => false, + }; } - private function handleQuit(): bool + private function quit(): bool { $this->running = false; $this->outputFormatter->write(''); @@ -154,7 +147,7 @@ private function handleQuit(): bool return true; } - private function handleClear(): bool + private function clear(): bool { if (PHP_OS_FAMILY === 'Windows') { system('cls'); From fd20de5ef6813cb5040a8c5fb69d490fe8472bb1 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sun, 15 Dec 2024 13:38:45 -0300 Subject: [PATCH 22/22] Update README.md --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1d28e14..3528864 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ docker run --rm -v $(pwd):/monkey -w /monkey php:8.4-cli ./vendor/bin/pest Running from a file contents of the examples folder: ```bash -docker run --rm -v (pwd):/monkey -w /monkey php:8.4-cli ./monkey run examples/fibo_while.monkey +docker run --rm -v (pwd):/monkey -w /monkey php:8.4-cli ./monkey --stats run examples/fibo_while.monkey ``` ### Using the REPL @@ -158,17 +158,23 @@ docker run -it --rm -v (pwd):/monkey -w /monkey php:8.4-cli ./monkey repl Example: ```text -šŸ’ Monkey Programming Language v1.0.0 -Type ':h' for help, ':c' for clear, ':q' to quit ++---------------------------------------+ +| šŸ’ Monkey Programming Language v1.0.0 | +| | +| Type :c for clear, :q to quit | ++---------------------------------------+ + āžœ let a = 20 + fn(x){ return x + 10; }(2); 32 + +āžœ ``` Or, if you want to execute a file: ```bash -docker run --rm -v (pwd):/monkey -w /monkey php:8.4-cli ./monkey run examples/closure.monkey +docker run --rm -v (pwd):/monkey -w /monkey php:8.4-cli ./monkey --stats run examples/closure.monkey ``` ### Contributing