Function
public class Function<T> : FunctionProtocol
Functions can process values in given DataTypes, allowing the expressions to be feature-rich
-
Although
Functions typically contain only one pattern, multiple ones can be added, for semantic grouping purposesDeclaration
Swift
public let patterns: [Pattern<T, TypedInterpreter>] -
If multiple patterns are provided use this initialiser. Otherwise, for only one, there is
init(_,matcher:)Declaration
Swift
public init(patterns: [Pattern<T, TypedInterpreter>])Parameters
patternsThe array of patterns to be able to recognise
-
In case there is only one pattern, this initialiser is the preferred one to use
Declaration
Swift
public init(_ elements: [PatternElement], options: PatternOptions = [], matcher: @escaping MatcherBlock<T, TypedInterpreter>)Parameters
elementsContains the pattern that needs to be recognised
optionsOptions that modify the pattern matching algorithm
matcherEnding closure that transforms and processes the recognised value
-
The matching of the input expression of a given
Functionhappens in this method. It only accepts matches from the matcher, that are exact matches.Declaration
Swift
public func convert(input: String, interpreter: TypedInterpreter, context: Context, connectedRanges: [ClosedRange<String.Index>] = []) -> Any?Parameters
inputThe input to convert as a
DataTypevalueinterpreterAn interpreter instance if the content needs any further evaluation
contextThe context - if vaiables need any contextual information
connectedRangesRanges of string indices that are connected with opening-closing tag pairs, respectively
Return Value
A valid value of any
DataTypeornilif it cannot be processed
View on GitHub
Install in Dash
Function Class Reference