1: <?php
2:
3: namespace BN\Compiler\Scanner\Converter;
4:
5: use BN\Compiler\Scanner\LexemeConverter;
6: use BN\Compiler\Token\Token;
7: use BN\Compiler\Token\TokenType;
8:
9: class LexemeToConstant implements LexemeConverter
10: {
11: private $constants = array();
12:
13: public function __construct(array $constants)
14: {
15: $this->constants = $constants;
16: }
17:
18: public function canConvertLexeme($lexeme)
19: {
20: return in_array($lexeme, $this->constants, true);
21: }
22:
23: public function convertLexeme($lexeme)
24: {
25: return new Token(TokenType::CONSTANT, $lexeme);
26: }
27: }
28: