This repository has been archived by the owner on Sep 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from SwiftGen/feature/parser-protocol
Parser protocol to unify parser interfaces.
- Loading branch information
Showing
23 changed files
with
297 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// SwiftGenKit | ||
// Copyright (c) 2017 SwiftGen | ||
// MIT License | ||
// | ||
|
||
import Foundation | ||
import PathKit | ||
|
||
public struct CommandInfo { | ||
public var name: String | ||
public var description: String | ||
public var pathDescription: String | ||
} | ||
|
||
public protocol Parser { | ||
init(options: [String: Any], warningHandler: MessageHandler?) throws | ||
|
||
// Command info | ||
static var commandInfo: CommandInfo { get } | ||
|
||
// Parsing and context generation | ||
func parse(path: Path) throws | ||
func parse(paths: [Path]) throws | ||
func stencilContext() -> [String: Any] | ||
|
||
/// This callback will be called when a Parser want to emit a diagnostics message | ||
/// You can set this on the usage-site to a closure that prints the diagnostics in any way you see fit | ||
/// Arguments are (message, file, line) | ||
typealias MessageHandler = (String, String, UInt) -> Void | ||
var warningHandler: MessageHandler? { get set } | ||
} | ||
|
||
public extension Parser { | ||
func parse(paths: [Path]) throws { | ||
for path in paths { | ||
try parse(path: path) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.