-
-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
106 additions
and
14 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,62 @@ | ||
// | ||
// LEXEMES | ||
// | ||
%token true true | ||
%token false false | ||
%token null null | ||
%token escape_token \\ | ||
%token string .+ | ||
|
||
|
||
// | ||
// RULES | ||
// | ||
value: | ||
string() | ||
|
||
string: | ||
::escape_token:: <string> | <escape_token> | <string> | ||
|
||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
//%skip space \s | ||
//// Scalars. | ||
//%token true true | ||
//%token false false | ||
//%token null null | ||
//// Strings. | ||
//%token quote_ <{ -> string | ||
//%token string:string [^"]+ | ||
//%token string:_quote }> -> default | ||
//// Objects. | ||
//%token brace_ { | ||
//%token _brace } | ||
//// Arrays. | ||
//%token bracket_ \[ | ||
//%token _bracket \] | ||
//// Rest. | ||
//%token colon : | ||
//%token comma , | ||
//%token number \d+ | ||
// | ||
//value: | ||
// <true> | <false> | <null> | string() | object() | array() | number() | ||
// | ||
//string: | ||
// ::quote_:: <string> ::_quote:: | ||
// | ||
//number: | ||
// <number> | ||
// | ||
//#object: | ||
// ::brace_:: pair() ( ::comma:: pair() )* ::_brace:: | ||
// | ||
//#pair: | ||
// string() ::colon:: value() | ||
// | ||
//#array: | ||
// ::bracket_:: value() ( ::comma:: value() )* ::_bracket:: |
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,29 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer; | ||
|
||
use Hoa\Compiler\Llk\Parser as HoaParser; | ||
use Nelmio\Alice\FixtureBuilder\ExpressionLanguage\LexerInterface; | ||
|
||
final class HoaLexer implements LexerInterface | ||
{ | ||
/** | ||
* @var HoaParser | ||
*/ | ||
private $parser; | ||
|
||
public function __construct(HoaParser $parser) | ||
{ | ||
|
||
$this->parser = $parser; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function lex(string $value) | ||
{ | ||
return $this->parser->parse($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
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