mirror of
https://github.com/github/semantic.git
synced 2024-12-27 00:44:57 +03:00
SyntaxConvertible types can be constructed with shorthands.
This commit is contained in:
parent
cdc1fbb99a
commit
30d594b4a3
@ -111,3 +111,17 @@ public protocol SyntaxConvertible {
|
||||
|
||||
init(syntax: Syntax<RecurType, LeafType>)
|
||||
}
|
||||
|
||||
extension SyntaxConvertible {
|
||||
static func Leaf(value: LeafType) -> Self {
|
||||
return Self(syntax: .Leaf(value))
|
||||
}
|
||||
|
||||
static func Indexed(children: [RecurType]) -> Self {
|
||||
return Self(syntax: .Indexed(children))
|
||||
}
|
||||
|
||||
static func Keyed(children: [String:RecurType]) -> Self {
|
||||
return Self(syntax: .Keyed(children))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user