2020-05-08 00:37:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Automata\Machine;
|
|
|
|
use Program\ProgramParser;
|
|
|
|
|
|
|
|
class ProgramLoader
|
|
|
|
{
|
|
|
|
public function loadPrograms(Machine $machine): void
|
|
|
|
{
|
|
|
|
$parser = new ProgramParser();
|
|
|
|
|
|
|
|
foreach (glob(__DIR__ . '/../programs/part/*') as $partProgramFile) {
|
|
|
|
$partProgram = $parser->parseFile($partProgramFile);
|
2020-05-10 21:17:12 +02:00
|
|
|
$machine->PPM->write($partProgram);
|
2020-05-08 00:37:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach (glob(__DIR__ . '/../programs/sub/*') as $subProgramFile) {
|
|
|
|
$subProgram = $parser->parseFile($subProgramFile);
|
2020-05-10 21:17:12 +02:00
|
|
|
$machine->SPM->write($subProgram);
|
2020-05-08 00:37:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|