finished default parser
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user