ZH
games/alis / tools / lang / human-reference.php · commit 9c722cf
<?php// The word tables of the "ALIS 90" form (docs/language.md, "Le format 90"), as Markdown, from App\Alis\Lang\Human.//   bin/jumphp php games/alis tools/lang/human-reference.phprequire __DIR__ . '/../../vendor/autoload.php';use App\Alis\Lang\Human;$table = static function (string $title, array $map, int $cols = 3): string {    $pairs = [];    foreach ($map as $machine => $human) {        $pairs[] = "`$human` | `$machine`";    }    $rows = (int) ceil(count($pairs) / $cols);    $out = "### $title\n\n|" . str_repeat(' Format 90 | Machine |', $cols) . "\n|" . str_repeat('---|---|', $cols) . "\n";    for ($r = 0; $r < $rows; $r++) {        $line = [];        for ($c = 0; $c < $cols; $c++) {            $line[] = $pairs[$c * $rows + $r] ?? ' | ';        }        $out .= '| ' . implode(' | ', $line) . " |\n";    }    return $out . "\n";};echo $table('Mots de contrôle', Human::CONTROL + ['{ … }' => 'alors … finsi / faire … fintantque', '} else {' => 'sinon']);echo $table('En-tête', Human::DIRECTIVES);echo $table('Fonctions', Human::FUNCTIONS);echo $table('Instructions', Human::STATEMENTS);