From 30d594b4a38187998c72eb986908347c8262d36a Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 9 Oct 2015 18:02:25 -0400 Subject: [PATCH] SyntaxConvertible types can be constructed with shorthands. --- prototype/Doubt/Syntax.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/prototype/Doubt/Syntax.swift b/prototype/Doubt/Syntax.swift index 353302f47..675f5e2a6 100644 --- a/prototype/Doubt/Syntax.swift +++ b/prototype/Doubt/Syntax.swift @@ -111,3 +111,17 @@ public protocol SyntaxConvertible { init(syntax: Syntax) } + +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)) + } +}