Matcher
internal class Matcher
This class provides the main logic of the Eval framework, performing the pattern matching details
-
The pattern to match against
Declaration
Swift
let pattern: PatternProtocol -
A processor that is able to evaluate the variables with extra information, such as context and interpreter
Declaration
Swift
let processor: VariableProcessorProtocol -
Initialiser of the matcher
Declaration
Swift
init(pattern: PatternProtocol, processor: VariableProcessorProtocol)Parameters
patternThe pattern to match against
processorA processor that is able to evaluate the variables with extra information, such as context and interpreter
-
Undocumented
Declaration
Swift
func match<T>(string: String, from start: String.Index?, connectedRanges: [ClosedRange<String.Index>] = [], renderer: @escaping (_ variables: [String: Any]) -> T?) -> MatchResult<T> -
Determines whether the current character is an
OpenKeyword, so there might be another embedded match laterDeclaration
Swift
func isEmbedded(element: PatternElement, in string: String, at currentPosition: String.Index) -> BoolParameters
elementThe element to check whether it’s an
OpenKeywordinThe input
atThe starting position to check from
Return Value
Whether the element conditions apply and the position is before the last one
-
Determines whether the current character is an
OpenKeywordand fins the position of its appropriateClosingKeywordpairDeclaration
Swift
func positionOfClosingTag(in string: String, from start: String.Index) -> String.Index?Parameters
inThe input
fromThe starting position of the checking range
Return Value
nilif theCloseKeywordpair cannot be found. The position otherwise
View on GitHub
Install in Dash
Matcher Class Reference