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])
Exibir arquivo Open project: behat/gherkin Class Usage Examples

Public Methods

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

Protected Methods

Method 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

Method 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 method

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

acceptTokenType() protected method

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

expectTokenType() protected method

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

parse() public method

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
return Behat\Gherkin\Node\FeatureNode | null

parseBackground() protected method

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

parseComment() protected method

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
return 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 method

Parses examples table node.
protected parseExamples ( ) : Behat\Gherkin\Node\ExampleTableNode
return Behat\Gherkin\Node\ExampleTableNode

parseExpression() protected method

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
return 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 method

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

parseLanguage() protected method

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
return 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 method

Parses next newline & returns \n.
protected parseNewline ( ) : string
return string

parseOutline() protected method

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

parsePyString() protected method

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

parseScenario() protected method

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

parseStep() protected method

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

parseTable() protected method

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

parseTags() protected method

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
return 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 method

Parses next text line & returns it.
protected parseText ( ) : string
return string

popTags() protected method

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

predictTokenType() protected method

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