Implement lexer class for tokenization and replace all line endings by PHP_EOL

This commit is contained in:
Tim
2025-05-10 14:35:11 +02:00
parent 771f354346
commit cda03f7b67
3 changed files with 60 additions and 21 deletions

View File

@ -4,5 +4,13 @@ namespace App\Service\SnipContent;
class Lexer
{
public static function tokenize(string $text): array {
$text = str_replace("\r", '', $text);
return explode(PHP_EOL, $text);
}
public static function reconstruct(array $tokens): string
{
return implode(PHP_EOL, $tokens);
}
}