finished default parser
This commit is contained in:
15
src/Application/UseCases/MergeCollections.php
Normal file
15
src/Application/UseCases/MergeCollections.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Application\UseCases;
|
||||
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
||||
|
||||
class MergeCollections
|
||||
{
|
||||
|
||||
public function merge(TuneCollection $masterCollection, TuneCollection $additions)
|
||||
{
|
||||
$collection = clone $masterCollection;
|
||||
|
||||
return $collection->merge($additions);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/Author.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/Author.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Author implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'A') {
|
||||
$this->builder->addAuthor(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/Book.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/Book.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Book implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'B') {
|
||||
$this->builder->addBook(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/Discography.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/Discography.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Discography implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'D') {
|
||||
$this->builder->addDiscography(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
53
src/Domain/Modules/Interpreter/Lexicon/EndOfTune.php
Normal file
53
src/Domain/Modules/Interpreter/Lexicon/EndOfTune.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class EndOfTune implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
// list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($this->isEndOfFile($context) || $this->isEndOfMusic($context, $line)) {
|
||||
$this->builder->handleEndOfMusic();
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
|
||||
protected function isEndOfFile(Context $context)
|
||||
{
|
||||
$key = $context->key();
|
||||
return $context->count() <= $key+1;
|
||||
}
|
||||
|
||||
private function isEndOfMusic(Context $context, string $line)
|
||||
{
|
||||
return $context->isState(Context::MODE_TUNE_BODY)
|
||||
&& preg_match('/^\s*$/', $line);
|
||||
}
|
||||
|
||||
}
|
||||
42
src/Domain/Modules/Interpreter/Lexicon/Filename.php
Normal file
42
src/Domain/Modules/Interpreter/Lexicon/Filename.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Filename implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'F'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
) {
|
||||
$this->builder->addFilename(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/Group.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/Group.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Group implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'G') {
|
||||
$this->builder->addGroup(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
62
src/Domain/Modules/Interpreter/Lexicon/History.php
Normal file
62
src/Domain/Modules/Interpreter/Lexicon/History.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class History implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
* @throws \Enzyme\Collection\CollectionException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'H'
|
||||
&& $context->isState($context::MODE_TUNE_HEADER)
|
||||
) {
|
||||
$this->builder->addHistory(new StringAtom($data));
|
||||
$context->setStateInHistory();
|
||||
} elseif ($context->isState($context::MODE_HISTORY)) {
|
||||
$this->builder->addHistory(new StringAtom($line));
|
||||
|
||||
if ($this->nextLineNotHistory($context)) {
|
||||
$context->setStateInTuneHeader();
|
||||
}
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @return bool
|
||||
* @throws \Enzyme\Collection\CollectionException
|
||||
*/
|
||||
private function nextLineNotHistory(Context $context)
|
||||
{
|
||||
$nextLine = $context->get($context->key() +1);
|
||||
list($key, $data) = $this->getKeyDataFromLine($nextLine);
|
||||
return $key !== '';
|
||||
}
|
||||
}
|
||||
41
src/Domain/Modules/Interpreter/Lexicon/KeySignature.php
Normal file
41
src/Domain/Modules/Interpreter/Lexicon/KeySignature.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class KeySignature implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($context->getState() === $context::MODE_TUNE_HEADER && $key === 'K') {
|
||||
$this->builder->setKey(new StringAtom($data));
|
||||
$context->setStateInTuneBody();
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
42
src/Domain/Modules/Interpreter/Lexicon/Meter.php
Normal file
42
src/Domain/Modules/Interpreter/Lexicon/Meter.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Meter implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'M'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
) {
|
||||
$this->builder->setMeter(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
43
src/Domain/Modules/Interpreter/Lexicon/MusicLine.php
Normal file
43
src/Domain/Modules/Interpreter/Lexicon/MusicLine.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class MusicLine implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($context->getState() === $context::MODE_TUNE_BODY
|
||||
&& $key !== 'K'
|
||||
&& $line !== ''
|
||||
) {
|
||||
$this->builder->appendMusic(new StringAtom($line));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/NoteLength.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/NoteLength.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class NoteLength implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'L') {
|
||||
$this->builder->addNoteLength(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/Notes.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/Notes.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Notes implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'N') {
|
||||
$this->builder->addNote(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/Origin.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/Origin.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Origin implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'O') {
|
||||
$this->builder->addOrigin(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
42
src/Domain/Modules/Interpreter/Lexicon/Parts.php
Normal file
42
src/Domain/Modules/Interpreter/Lexicon/Parts.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Parts implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'P'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
) {
|
||||
$this->builder->setParts(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
42
src/Domain/Modules/Interpreter/Lexicon/Rhythm.php
Normal file
42
src/Domain/Modules/Interpreter/Lexicon/Rhythm.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Rhythm implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'R'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
) {
|
||||
$this->builder->addRhythm(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
42
src/Domain/Modules/Interpreter/Lexicon/Source.php
Normal file
42
src/Domain/Modules/Interpreter/Lexicon/Source.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Source implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'S'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
) {
|
||||
$this->builder->addSource(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/Tempo.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/Tempo.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Tempo implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'Q') {
|
||||
$this->builder->addTempo(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/Transcriber.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/Transcriber.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Transcriber implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'Z') {
|
||||
$this->builder->addTranscriber(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
40
src/Domain/Modules/Interpreter/Lexicon/Words.php
Normal file
40
src/Domain/Modules/Interpreter/Lexicon/Words.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Words implements Lex
|
||||
{
|
||||
use LineKeyDataTrait;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(Builder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'W') {
|
||||
$this->builder->addWords(new StringAtom($data));
|
||||
}
|
||||
|
||||
return $next($context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user