Source: ryangjchandler.co.uk

Let's Write an Esolang in PHP
An esolang (esoteric language) is a programming language designed to be used as a joke or test the limits of what can be achieved with a particular language syntax. Brainf*ck is a minimal esolang and the original implementation only consisted of 8 symbols — >, Move pointer to next cell => */ public function tokenise(string $input): array { $chars = str_split($input); $tokens = []; return $tokens; }}

protected function node(): Node { if ($this->current === Token::Plus) { $this->next(); return new IncrementNode; } elseif ($this->current === Token::Minus) { $this->next(); return new DecrementNode; } elseif ($this->current === Token::RightDoubleArrow) { $this->next(); return new MoveRightNode; } elseif ($this->current === Token::LeftDoubleArrow) { $this->next(); return new MoveLeftNode; } elseif ($this->current === Token::Dollar) { $this->next(); return new ReadByteNode; } elseif ($this->current === Token::Echo) { $this->next(); return new EchoNode; } elseif ($this->current === Token::Backslash) { $this->next(); $nodes = []; while ($this->current !== null && $this->current !== Token::Slash) { $nodes[] = $this->node(); } $this->expect(Token::Slash); return new WhileNode($nodes); } else { throw UnexpectedTokenException::make($this->current); }} protected function expect(Token $token): void { if ($this->current !== $token) { throw UnexpectedTokenException::make($this->current); } $this->next(); } protected function next(): void { $this->position++; $this->current = $this->next; $this->next = $this->tokens[$this->position + 1]?? null; }}

- / tape = array_fill(0, 30_000, 0);; $this->tp = 0; $this->input = $input; $this->ip = 0; $this->output = ''; foreach ($program->getNodes() as $node) { $this->node($node); }} }
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners