PHP Class Behat\Gherkin\Parser

$lexer = new Behat\Gherkin\Lexer($keywords); $parser = new Behat\Gherkin\Parser($lexer); $featuresArray = $parser->parse('/path/to/feature.feature');
Author: Konstantin Kudryashov ([email protected])
Afficher le fichier Open project: behat/gherkin Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( Lexer $lexer ) Initializes parser.
parse ( string $input, string $file = null ) : Behat\Gherkin\Node\FeatureNode | null Parses input & returns features array.

Méthodes protégées

Méthode Description
acceptTokenType ( string $type ) : null | array Returns next token if it's type equals to expected.
expectTokenType ( string $type ) : array Returns next token if it's type equals to expected.
parseBackground ( ) : Behat\Gherkin\Node\BackgroundNode Parses background token & returns it's node.
parseComment ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string Parses next comment token & returns it's string content.
parseExamples ( ) : Behat\Gherkin\Node\ExampleTableNode Parses examples table node.
parseExpression ( ) : string | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\TableNode | Behat\Gherkin\Node\StepNode Parses current expression & returns Node.
parseFeature ( ) : Behat\Gherkin\Node\FeatureNode Parses feature token & returns it's node.
parseLanguage ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string Parses language block and updates lexer configuration based on it.
parseNewline ( ) : string Parses next newline & returns \n.
parseOutline ( ) : Behat\Gherkin\Node\OutlineNode Parses scenario outline token & returns it's node.
parsePyString ( ) : Behat\Gherkin\Node\PyStringNode Parses PyString token & returns it's node.
parseScenario ( ) : Behat\Gherkin\Node\ScenarioNode Parses scenario token & returns it's node.
parseStep ( ) : Behat\Gherkin\Node\StepNode Parses step token & returns it's node.
parseTable ( ) : Behat\Gherkin\Node\TableNode Parses table token & returns it's node.
parseTags ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string Parses tags.
parseText ( ) : string Parses next text line & returns it.
popTags ( ) : array Returns current set of tags and clears tag buffer.
predictTokenType ( ) : string Returns next token type without real input reading (prediction).

Private Methods

Méthode Description
normalizeStepNodeKeywordType ( Behat\Gherkin\Node\StepNode $node, array $steps = [] ) : Behat\Gherkin\Node\StepNode Changes step node type for types But, And to type of previous step if it exists else sets to Given
parseTableRows ( ) : string[][] Parses the rows of a table

Method Details

__construct() public méthode

Initializes parser.
public __construct ( Lexer $lexer )
$lexer Lexer Lexer instance

acceptTokenType() protected méthode

Returns next token if it's type equals to expected.
protected acceptTokenType ( string $type ) : null | array
$type string Token type
Résultat null | array

expectTokenType() protected méthode

Returns next token if it's type equals to expected.
protected expectTokenType ( string $type ) : array
$type string Token type
Résultat array

parse() public méthode

Parses input & returns features array.
public parse ( string $input, string $file = null ) : Behat\Gherkin\Node\FeatureNode | null
$input string Gherkin string document
$file string File name
Résultat Behat\Gherkin\Node\FeatureNode | null

parseBackground() protected méthode

Parses background token & returns it's node.
protected parseBackground ( ) : Behat\Gherkin\Node\BackgroundNode
Résultat Behat\Gherkin\Node\BackgroundNode

parseComment() protected méthode

Parses next comment token & returns it's string content.
protected parseComment ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string
Résultat Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string

parseExamples() protected méthode

Parses examples table node.
protected parseExamples ( ) : Behat\Gherkin\Node\ExampleTableNode
Résultat Behat\Gherkin\Node\ExampleTableNode

parseExpression() protected méthode

Parses current expression & returns Node.
protected parseExpression ( ) : string | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\TableNode | Behat\Gherkin\Node\StepNode
Résultat string | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\TableNode | Behat\Gherkin\Node\StepNode

parseFeature() protected méthode

Parses feature token & returns it's node.
protected parseFeature ( ) : Behat\Gherkin\Node\FeatureNode
Résultat Behat\Gherkin\Node\FeatureNode

parseLanguage() protected méthode

Parses language block and updates lexer configuration based on it.
protected parseLanguage ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string
Résultat Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string

parseNewline() protected méthode

Parses next newline & returns \n.
protected parseNewline ( ) : string
Résultat string

parseOutline() protected méthode

Parses scenario outline token & returns it's node.
protected parseOutline ( ) : Behat\Gherkin\Node\OutlineNode
Résultat Behat\Gherkin\Node\OutlineNode

parsePyString() protected méthode

Parses PyString token & returns it's node.
protected parsePyString ( ) : Behat\Gherkin\Node\PyStringNode
Résultat Behat\Gherkin\Node\PyStringNode

parseScenario() protected méthode

Parses scenario token & returns it's node.
protected parseScenario ( ) : Behat\Gherkin\Node\ScenarioNode
Résultat Behat\Gherkin\Node\ScenarioNode

parseStep() protected méthode

Parses step token & returns it's node.
protected parseStep ( ) : Behat\Gherkin\Node\StepNode
Résultat Behat\Gherkin\Node\StepNode

parseTable() protected méthode

Parses table token & returns it's node.
protected parseTable ( ) : Behat\Gherkin\Node\TableNode
Résultat Behat\Gherkin\Node\TableNode

parseTags() protected méthode

Parses tags.
protected parseTags ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string
Résultat Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string

parseText() protected méthode

Parses next text line & returns it.
protected parseText ( ) : string
Résultat string

popTags() protected méthode

Returns current set of tags and clears tag buffer.
protected popTags ( ) : array
Résultat array

predictTokenType() protected méthode

Returns next token type without real input reading (prediction).
protected predictTokenType ( ) : string
Résultat string