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
pattern
The pattern to match against
processor
A 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) -> Bool
Parameters
element
The element to check whether it’s an
OpenKeyword
in
The input
at
The 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
OpenKeyword
and fins the position of its appropriateClosingKeyword
pairDeclaration
Swift
func positionOfClosingTag(in string: String, from start: String.Index) -> String.Index?
Parameters
in
The input
from
The starting position of the checking range
Return Value
nil
if theCloseKeyword
pair cannot be found. The position otherwise