ChoiceRule
public final class ChoiceRule : Rule
A ChoiceRule
will match if one of the child rules is matched. It can be thought of as a logical OR.
-
The behaviour of the rule
Declaration
Swift
public var behaviour: Behaviour
-
Annotations on the rule
Declaration
Swift
public var annotations: RuleAnnotations
-
The acceptable matches that would satisfy this rule
Declaration
Swift
public var choices: [Rule]
-
Creates a new instance of the rule with the specified parameteres.
Declaration
Swift
public init(_ behaviour: Behaviour, and annotations: RuleAnnotations, for choices: [Rule])
Parameters
behaviour
The
Behaviour
for the ruleannotations
The
RuleAnnotations
on the rulechoices
The child rules, any one of which can satisfy this rule
-
The test will be satisfied if any one of the
choices
are satisfied. The child rules are evaluated in order.Declaration
Swift
public func test(with lexer: LexicalAnalyzer, for ir: IntermediateRepresentation) throws
Parameters
lexer
The
LexicalAnalyzer
managing the scan headir
The IR building the AST
-
Creates a new instance with the specified behaviour and annoations overriding the current instance’s if specified
Declaration
Swift
public func rule(with behaviour: Behaviour?, annotations: RuleAnnotations?) -> Rule
Parameters
behaviour
If specified will replace this instance’s behaviour in the new instance
annotations
If specified will replace this instance’s annotations in the new instance
-
A textual description of the rule
Declaration
Swift
public var description: String { get }
-
An abreviated description of the rule
Declaration
Swift
public var shortDescription: String { get }