Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename ConstantRegistry::register() to ConstantRegistry::registerLabe…
…l(), allow registering ConstantInfo directly using ConstantRegistry::register()
- Loading branch information
Showing
5 changed files
with
77 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace muqsit\arithmexp\constant; | ||
|
||
use muqsit\arithmexp\Parser; | ||
use muqsit\arithmexp\token\builder\ExpressionTokenBuilderState; | ||
use muqsit\arithmexp\token\IdentifierToken; | ||
|
||
interface ConstantInfo{ | ||
|
||
public function writeExpressionTokens(Parser $parser, string $expression, IdentifierToken $token, ExpressionTokenBuilderState $state) : void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace muqsit\arithmexp\constant; | ||
|
||
use muqsit\arithmexp\expression\token\NumericLiteralExpressionToken; | ||
use muqsit\arithmexp\Parser; | ||
use muqsit\arithmexp\token\builder\ExpressionTokenBuilderState; | ||
use muqsit\arithmexp\token\IdentifierToken; | ||
|
||
final class SimpleConstantInfo implements ConstantInfo{ | ||
|
||
public function __construct( | ||
private int|float $value | ||
){} | ||
|
||
public function writeExpressionTokens(Parser $parser, string $expression, IdentifierToken $token, ExpressionTokenBuilderState $state) : void{ | ||
$state->current_group[$state->current_index] = new NumericLiteralExpressionToken($token->getPos(), $this->value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters