1
1
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:
Rob Rix 2015-10-09 18:02:25 -04:00
parent cdc1fbb99a
commit 30d594b4a3

View File

@ -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))
}
}