RuleAnnotation
public enum RuleAnnotation : Hashable, CustomStringConvertible
An annotation that can be associated with any rule influencing how matches are interpretted and providing additional data about the token. The following annotations represent reserved words
, but otherwise you can define any annotations you want.
.token
Override the token to be created when the rule is matched (ignoring theRule
‘sproduces
property- ’.error
A specific error message to generate if the
Rule` is not satisfied - ‘.void’ The match should be completely ignored. This is not a failure but rather a consumption
- ‘.transient’ The match should be made and a
Node
could be created but this token is not significant for the AST - ‘.pinned’ The token should be created with no value even if the
Rule
is not matched in an ignorable failure
-
Token to be created when the rule is matched
Declaration
Swift
case token
-
An error to be generated when the rule is not matched
Declaration
Swift
case error
-
Matches will be completely discarded (no node, no adoption of children by parent)
Declaration
Swift
case void
-
Token will not be preserved in the AST but it’s children should be adopted by the parent node
Declaration
Swift
case transient
-
Nodes will be created for failed optional matches
Declaration
Swift
case pinned
-
The type of the token, used to inform code generation
Declaration
Swift
case type
-
A custom developer defined annotation that your own AST will interpret
Declaration
Swift
case custom(label: String)
-
The searchable hash value of the annotation
Declaration
Swift
public var hashValue: Int { get }
-
Compares two annotations for equality (not values, but keys)
Declaration
Swift
public static func == (lhs: RuleAnnotation, rhs: RuleAnnotation) -> Bool
Parameters
lhs
The first annotation
rhs
The second annotation
Return Value
true
if the annotations are the same,false
otherwise. -
A human readable description of the annotation
Declaration
Swift
public var description: String { get }