-
-
Save IMSoP/a98e33c71f72f9a2c0a44c912540cc94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
enum Token { | |
case identifier(string $name) = self(true); | |
case whitespace = self(true); | |
case comment(string $comment) = self(false); | |
public function __construct(public bool $isSignificant); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Token { | |
public function __construct(public bool $isSignificant); | |
} | |
class identifier extends Token { | |
public function __construct(public string $name) { | |
parent::__construct(true); | |
} | |
} | |
class whitespace extends Token { | |
public function __construct() { | |
parent::__construct(true); | |
} | |
} | |
class comment extends Token { | |
public function __construct(public string $comment) { | |
parent::__construct(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment