Lexer
in package
Gherkin lexer.
Tags
Table of Contents
Properties
- $allowMultilineArguments : mixed
- $allowSteps : mixed
- $deferredObjects : mixed
- $deferredObjectsCount : mixed
- $eos : mixed
- $featureStarted : mixed
- $inPyString : mixed
- $keywords : mixed
- $keywordsCache : mixed
- $language : mixed
- $line : mixed
- $lineNumber : mixed
- $lines : mixed
- $linesCount : mixed
- $pyStringDelimiter : mixed
- $pyStringSwallow : mixed
- $stashedToken : mixed
- $stepKeywordTypesCache : mixed
- $trimmedLine : mixed
Methods
- __construct() : mixed
- Initializes lexer.
- analyse() : mixed
- Sets lexer input.
- deferToken() : mixed
- Defers token.
- getAdvancedToken() : array<string|int, mixed>
- Returns next token or previously stashed one.
- getLanguage() : string
- Returns current lexer language.
- predictToken() : array<string|int, mixed>
- Predicts the upcoming token without passing over it.
- skipPredictedToken() : void
- Skips over the currently-predicted token, if any.
- takeToken() : array<string|int, mixed>
- Constructs token with specified parameters.
- consumeLine() : mixed
- Consumes line from input & increments line counter.
- consumeLineUntil() : mixed
- Consumes first part of line from input without incrementing the line number
- getDeferredToken() : array<string|int, mixed>|null
- Returns deferred token or null if hasn't.
- getKeywords() : string
- Returns keywords for provided type.
- getNextToken() : array<string|int, mixed>
- Returns next token from input.
- getStashedToken() : array<string|int, mixed>|null
- Returns stashed token or null if hasn't.
- getTrimmedLine() : string
- Returns trimmed version of line.
- scanBackground() : null|array<string|int, mixed>
- Scans Background from input & returns it if found.
- scanComment() : null|array<string|int, mixed>
- Scans Comment from input & returns it if found.
- scanEOS() : null|array<string|int, mixed>
- Scans EOS from input & returns it if found.
- scanExamples() : null|array<string|int, mixed>
- Scans Scenario Outline Examples from input & returns it if found.
- scanFeature() : null|array<string|int, mixed>
- Scans Feature from input & returns it if found.
- scanInput() : null|array<string|int, mixed>
- Scans for token with specified regex.
- scanInputForKeywords() : null|array<string|int, mixed>
- Scans for token with specified keywords.
- scanLanguage() : null|array<string|int, mixed>
- Scans Language specifier from input & returns it if found.
- scanNewline() : null|array<string|int, mixed>
- Scans Newline from input & returns it if found.
- scanOutline() : null|array<string|int, mixed>
- Scans Scenario Outline from input & returns it if found.
- scanPyStringContent() : null|array<string|int, mixed>
- Scans PyString content.
- scanPyStringOp() : null|array<string|int, mixed>
- Scans PyString from input & returns it if found.
- scanScenario() : null|array<string|int, mixed>
- Scans Scenario from input & returns it if found.
- scanStep() : null|array<string|int, mixed>
- Scans Step from input & returns it if found.
- scanTableRow() : null|array<string|int, mixed>
- Scans Table Row from input & returns it if found.
- scanTags() : null|array<string|int, mixed>
- Scans Tags from input & returns it if found.
- scanText() : null|array<string|int, mixed>
- Scans text from input & returns it if found.
- getStepKeywordType() : string
- Returns step type keyword (Given, When, Then, etc.).
Properties
$allowMultilineArguments
private
mixed
$allowMultilineArguments
= false
$allowSteps
private
mixed
$allowSteps
= false
$deferredObjects
private
mixed
$deferredObjects
= array()
$deferredObjectsCount
private
mixed
$deferredObjectsCount
= 0
$eos
private
mixed
$eos
$featureStarted
private
mixed
$featureStarted
= false
$inPyString
private
mixed
$inPyString
= false
$keywords
private
mixed
$keywords
$keywordsCache
private
mixed
$keywordsCache
= array()
$language
private
mixed
$language
$line
private
mixed
$line
$lineNumber
private
mixed
$lineNumber
$lines
private
mixed
$lines
$linesCount
private
mixed
$linesCount
$pyStringDelimiter
private
mixed
$pyStringDelimiter
= null
$pyStringSwallow
private
mixed
$pyStringSwallow
= 0
$stashedToken
private
mixed
$stashedToken
$stepKeywordTypesCache
private
mixed
$stepKeywordTypesCache
= array()
$trimmedLine
private
mixed
$trimmedLine
Methods
__construct()
Initializes lexer.
public
__construct(KeywordsInterface $keywords) : mixed
Parameters
- $keywords : KeywordsInterface
-
Keywords holder
analyse()
Sets lexer input.
public
analyse(string $input[, string $language = 'en' ]) : mixed
Parameters
- $input : string
-
Input string
- $language : string = 'en'
-
Language name
Tags
deferToken()
Defers token.
public
deferToken(array<string|int, mixed> $token) : mixed
Parameters
- $token : array<string|int, mixed>
-
Token to defer
getAdvancedToken()
Returns next token or previously stashed one.
public
getAdvancedToken() : array<string|int, mixed>
Return values
array<string|int, mixed>getLanguage()
Returns current lexer language.
public
getLanguage() : string
Return values
stringpredictToken()
Predicts the upcoming token without passing over it.
public
predictToken() : array<string|int, mixed>
Return values
array<string|int, mixed>skipPredictedToken()
Skips over the currently-predicted token, if any.
public
skipPredictedToken() : void
takeToken()
Constructs token with specified parameters.
public
takeToken(string $type[, string $value = null ]) : array<string|int, mixed>
Parameters
- $type : string
-
Token type
- $value : string = null
-
Token value
Return values
array<string|int, mixed>consumeLine()
Consumes line from input & increments line counter.
protected
consumeLine() : mixed
consumeLineUntil()
Consumes first part of line from input without incrementing the line number
protected
consumeLineUntil(int $trimmedOffset) : mixed
Parameters
- $trimmedOffset : int
getDeferredToken()
Returns deferred token or null if hasn't.
protected
getDeferredToken() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetKeywords()
Returns keywords for provided type.
protected
getKeywords(string $type) : string
Parameters
- $type : string
-
Keyword type
Return values
stringgetNextToken()
Returns next token from input.
protected
getNextToken() : array<string|int, mixed>
Return values
array<string|int, mixed>getStashedToken()
Returns stashed token or null if hasn't.
protected
getStashedToken() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetTrimmedLine()
Returns trimmed version of line.
protected
getTrimmedLine() : string
Return values
stringscanBackground()
Scans Background from input & returns it if found.
protected
scanBackground() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanComment()
Scans Comment from input & returns it if found.
protected
scanComment() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanEOS()
Scans EOS from input & returns it if found.
protected
scanEOS() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanExamples()
Scans Scenario Outline Examples from input & returns it if found.
protected
scanExamples() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanFeature()
Scans Feature from input & returns it if found.
protected
scanFeature() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanInput()
Scans for token with specified regex.
protected
scanInput(string $regex, string $type) : null|array<string|int, mixed>
Parameters
- $regex : string
-
Regular expression
- $type : string
-
Expected token type
Return values
null|array<string|int, mixed>scanInputForKeywords()
Scans for token with specified keywords.
protected
scanInputForKeywords(string $keywords, string $type) : null|array<string|int, mixed>
Parameters
- $keywords : string
-
Keywords (splitted with |)
- $type : string
-
Expected token type
Return values
null|array<string|int, mixed>scanLanguage()
Scans Language specifier from input & returns it if found.
protected
scanLanguage() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanNewline()
Scans Newline from input & returns it if found.
protected
scanNewline() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanOutline()
Scans Scenario Outline from input & returns it if found.
protected
scanOutline() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanPyStringContent()
Scans PyString content.
protected
scanPyStringContent() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanPyStringOp()
Scans PyString from input & returns it if found.
protected
scanPyStringOp() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanScenario()
Scans Scenario from input & returns it if found.
protected
scanScenario() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanStep()
Scans Step from input & returns it if found.
protected
scanStep() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanTableRow()
Scans Table Row from input & returns it if found.
protected
scanTableRow() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanTags()
Scans Tags from input & returns it if found.
protected
scanTags() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>scanText()
Scans text from input & returns it if found.
protected
scanText() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed>getStepKeywordType()
Returns step type keyword (Given, When, Then, etc.).
private
getStepKeywordType(string $native) : string
Parameters
- $native : string
-
Step keyword in provided language