Parser
in package
Gherkin parser.
$lexer = new Behat\Gherkin\Lexer($keywords); $parser = new Behat\Gherkin\Parser($lexer); $featuresArray = $parser->parse('/path/to/feature.feature');
Tags
Table of Contents
Properties
- $file : mixed
- $input : mixed
- $languageSpecifierLine : mixed
- $lexer : mixed
- $passedNodesStack : mixed
- $tags : mixed
Methods
- __construct() : mixed
- Initializes parser.
- parse() : FeatureNode|null
- Parses input & returns features array.
- acceptTokenType() : null|array<string|int, mixed>
- Returns next token if it's type equals to expected.
- expectTokenType() : array<string|int, mixed>
- Returns next token if it's type equals to expected.
- guardTags() : mixed
- Checks the tags fit the required format
- parseBackground() : BackgroundNode
- Parses background token & returns it's node.
- parseExamples() : ExampleTableNode
- Parses examples table node.
- parseExpression() : string|FeatureNode|BackgroundNode|ScenarioNode|OutlineNode|TableNode|StepNode
- Parses current expression & returns Node.
- parseFeature() : FeatureNode
- Parses feature token & returns it's node.
- parseLanguage() : BackgroundNode|FeatureNode|OutlineNode|ScenarioNode|StepNode|TableNode|string
- Parses language block and updates lexer configuration based on it.
- parseNewline() : string
- Parses next newline & returns \n.
- parseOutline() : OutlineNode
- Parses scenario outline token & returns it's node.
- parsePyString() : PyStringNode
- Parses PyString token & returns it's node.
- parseScenario() : ScenarioNode
- Parses scenario token & returns it's node.
- parseStep() : StepNode
- Parses step token & returns it's node.
- parseTable() : TableNode
- Parses table token & returns it's node.
- parseTags() : BackgroundNode|FeatureNode|OutlineNode|ScenarioNode|StepNode|TableNode|string
- Parses tags.
- parseText() : string
- Parses next text line & returns it.
- popTags() : array<string|int, mixed>
- Returns current set of tags and clears tag buffer.
- predictTokenType() : string
- Returns next token type without real input reading (prediction).
- normalizeStepNodeKeywordType() : StepNode
- Changes step node type for types But, And to type of previous step if it exists else sets to Given
- parseTableRows() : array<string|int, array<string|int, string>>
- Parses the rows of a table
- rethrowNodeException() : void
Properties
$file
private
mixed
$file
$input
private
mixed
$input
$languageSpecifierLine
private
mixed
$languageSpecifierLine
$lexer
private
mixed
$lexer
$passedNodesStack
private
mixed
$passedNodesStack
= array()
$tags
private
mixed
$tags
= array()
Methods
__construct()
Initializes parser.
public
__construct(Lexer $lexer) : mixed
Parameters
- $lexer : Lexer
-
Lexer instance
parse()
Parses input & returns features array.
public
parse(string $input[, string $file = null ]) : FeatureNode|null
Parameters
- $input : string
-
Gherkin string document
- $file : string = null
-
File name
Tags
Return values
FeatureNode|nullacceptTokenType()
Returns next token if it's type equals to expected.
protected
acceptTokenType(string $type) : null|array<string|int, mixed>
Parameters
- $type : string
-
Token type
Return values
null|array<string|int, mixed>expectTokenType()
Returns next token if it's type equals to expected.
protected
expectTokenType(string $type) : array<string|int, mixed>
Parameters
- $type : string
-
Token type
Tags
Return values
array<string|int, mixed>guardTags()
Checks the tags fit the required format
protected
guardTags(array<string|int, string> $tags) : mixed
Parameters
- $tags : array<string|int, string>
parseBackground()
Parses background token & returns it's node.
protected
parseBackground() : BackgroundNode
Tags
Return values
BackgroundNodeparseExamples()
Parses examples table node.
protected
parseExamples() : ExampleTableNode
Return values
ExampleTableNodeparseExpression()
Parses current expression & returns Node.
protected
parseExpression() : string|FeatureNode|BackgroundNode|ScenarioNode|OutlineNode|TableNode|StepNode
Tags
Return values
string|FeatureNode|BackgroundNode|ScenarioNode|OutlineNode|TableNode|StepNodeparseFeature()
Parses feature token & returns it's node.
protected
parseFeature() : FeatureNode
Tags
Return values
FeatureNodeparseLanguage()
Parses language block and updates lexer configuration based on it.
protected
parseLanguage() : BackgroundNode|FeatureNode|OutlineNode|ScenarioNode|StepNode|TableNode|string
Tags
Return values
BackgroundNode|FeatureNode|OutlineNode|ScenarioNode|StepNode|TableNode|stringparseNewline()
Parses next newline & returns \n.
protected
parseNewline() : string
Return values
stringparseOutline()
Parses scenario outline token & returns it's node.
protected
parseOutline() : OutlineNode
Tags
Return values
OutlineNodeparsePyString()
Parses PyString token & returns it's node.
protected
parsePyString() : PyStringNode
Return values
PyStringNodeparseScenario()
Parses scenario token & returns it's node.
protected
parseScenario() : ScenarioNode
Tags
Return values
ScenarioNodeparseStep()
Parses step token & returns it's node.
protected
parseStep() : StepNode
Return values
StepNodeparseTable()
Parses table token & returns it's node.
protected
parseTable() : TableNode
Return values
TableNodeparseTags()
Parses tags.
protected
parseTags() : BackgroundNode|FeatureNode|OutlineNode|ScenarioNode|StepNode|TableNode|string
Return values
BackgroundNode|FeatureNode|OutlineNode|ScenarioNode|StepNode|TableNode|stringparseText()
Parses next text line & returns it.
protected
parseText() : string
Return values
stringpopTags()
Returns current set of tags and clears tag buffer.
protected
popTags() : array<string|int, mixed>
Return values
array<string|int, mixed>predictTokenType()
Returns next token type without real input reading (prediction).
protected
predictTokenType() : string
Return values
stringnormalizeStepNodeKeywordType()
Changes step node type for types But, And to type of previous step if it exists else sets to Given
private
normalizeStepNodeKeywordType(StepNode $node[, array<string|int, StepNode> $steps = array() ]) : StepNode
Parameters
Return values
StepNodeparseTableRows()
Parses the rows of a table
private
parseTableRows() : array<string|int, array<string|int, string>>
Return values
array<string|int, array<string|int, string>>rethrowNodeException()
private
rethrowNodeException(NodeException $e) : void
Parameters
- $e : NodeException