Commit 63ae503e authored by Drew's avatar Drew Committed by GitHub

Merge pull request #33 from AnarchyTools/swift-preview-6

Swift preview 6
parents 665cc757 c233fb46
Pipeline #2485 passed with stage
in 1 minute and 16 seconds
Subproject commit f1771b5bfe51d13392aded398012f291534adf89
Subproject commit 0f49f75f602539077f4bdeb4c5f37f999bab61f2
......@@ -23,21 +23,32 @@ public func collectSources(sourceDescriptions: [String], taskForCalculatingPath
for unPrefixedDescription in sourceDescriptions {
let description = (task?.importedPath ?? Path()) + unPrefixedDescription
if unPrefixedDescription.hasSuffix("**.swift") {
let basepath = description.dirname()
do {
let iterator = try FS.iterateItems(path: basepath, recursive: true)
for file in iterator {
if file.path.components.last!.hasSuffix(".swift") {
sources.append(file.path)
}
}
} catch {
fatalError("Error: \(error) for '\(basepath)'")
}
sources.append(contentsOf: findSources(basepath: description.dirname(),extension: ".swift"))
}
else if unPrefixedDescription.hasSuffix("**.c") {
sources.append(contentsOf: findSources(basepath: description.dirname(),extension: ".c"))
}
else if unPrefixedDescription.hasSuffix("**.h") {
sources.append(contentsOf: findSources(basepath: description.dirname(),extension: ".h"))
}
else {
sources.append(description)
}
}
return sources
}
private func findSources(basepath: Path, extension: String) -> [Path] {
var sources: [Path] = []
do {
let iterator = try FS.iterateItems(path: basepath, recursive: true)
for file in iterator {
if file.path.components.last!.hasSuffix(`extension`) {
sources.append(file.path)
}
}
} catch {
fatalError("Error: \(error) for '\(basepath)'")
}
return sources
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
import atfoundation
enum PackageError: ErrorProtocol {
enum PackageError: Error {
case NonVectorImport
case ParserFailed
case NonPackage
......@@ -22,12 +22,11 @@ enum PackageError: ErrorProtocol {
case RequiredOverlayNotPresent([String])
}
private extension Task {
fileprivate extension Task {
/**Apply the overlay to the receiver
- warning: an overlay may itself apply another overlay. In this case, the overlay for the task should be recalculated.
- return: whether the overlay applied another overlay */
@warn_unused_result
private func applyOverlay(name: String, overlay: [String: ParseValue]) -> Bool {
fileprivate func applyOverlay(name: String, overlay: [String: ParseValue]) -> Bool {
precondition(!appliedOverlays.contains(name), "Already applied overlay named \(name)")
for (optionName, optionValue) in overlay {
switch(optionValue) {
......
......@@ -14,7 +14,7 @@
import atfoundation
public enum ParseError: ErrorProtocol {
public enum ParseError: Error {
case InvalidPackageFile
case ExpectedTokenType(TokenType, Token?)
case InvalidTokenForValueType(Token?)
......@@ -111,7 +111,7 @@ final public class Parser {
private func parseKeyValuePairs() throws -> [String:ParseValue] {
var pairs: [String:ParseValue] = [:]
while let token = next() where token.type != .CloseParen && token.type != .CloseBrace {
while let token = next(), token.type != .CloseParen && token.type != .CloseBrace {
lexer.stall()
let key = try parseKey()
......@@ -152,24 +152,24 @@ final public class Parser {
}
private func parseVector() throws -> ParseValue {
if let token = next() where token.type != .OpenBracket { throw ParseError.ExpectedTokenType(.OpenBracket, token) }
if let token = next(),token.type != .OpenBracket { throw ParseError.ExpectedTokenType(.OpenBracket, token) }
var items: [ParseValue] = []
while let token = next() where token.type != .CloseBracket {
while let token = next(), token.type != .CloseBracket {
lexer.stall()
items.append(try parseValue())
}
lexer.stall()
if let token = next() where token.type != .CloseBracket { throw ParseError.ExpectedTokenType(.CloseBracket, token) }
if let token = next(), token.type != .CloseBracket { throw ParseError.ExpectedTokenType(.CloseBracket, token) }
return .Vector(items)
}
private func parseMap() throws -> ParseValue {
if let token = next() where token.type != .OpenBrace { throw ParseError.ExpectedTokenType(.OpenBrace, token) }
if let token = next(), token.type != .OpenBrace { throw ParseError.ExpectedTokenType(.OpenBrace, token) }
let items = try parseKeyValuePairs()
if let token = next() where token.type != .CloseBrace { throw ParseError.ExpectedTokenType(.CloseBrace, token) }
if let token = next(), token.type != .CloseBrace { throw ParseError.ExpectedTokenType(.CloseBrace, token) }
return .Map(items)
}
......
......@@ -94,7 +94,7 @@ final public class Lexer {
scanner.stall()
while let info = scanner.next() where isWhitespace(c: info.character) {}
while let info = scanner.next(), isWhitespace(c: info.character) {}
scanner.stall()
guard let next = scanner.next() else { return Token(type: .EOF) }
......@@ -104,7 +104,7 @@ final public class Lexer {
}
else if isValidIdentifierSignalCharacter(c: next.character) {
var content = String(next.character!)
while let info = scanner.next() where isValidIdenitifierCharacter(c: info.character) {
while let info = scanner.next(), isValidIdenitifierCharacter(c: info.character) {
content.append(info.character!)
}
scanner.stall()
......@@ -137,10 +137,10 @@ final public class Lexer {
let line = scanner.peek()!.line
var comment = ""
while let info = scanner.next() where info.character == ";" {}
while let info = scanner.next(), info.character == ";" {}
scanner.stall()
while let info = scanner.next() where info.character != "\n" {
while let info = scanner.next(), info.character != "\n" {
comment.append(info.character!)
}
......@@ -148,7 +148,7 @@ final public class Lexer {
}
else if next.character == "\"" {
var content = ""
while let info = scanner.next() where info.character != "\"" {
while let info = scanner.next(), info.character != "\"" {
if info.character == "\\" {
let escaped = scanner.next()
let char = escaped?.character
......
......@@ -16,7 +16,7 @@
import atfoundation
extension String : ErrorProtocol {}
extension String : Error {}
enum test {
static func assert(_ condition: Bool, file: String = #file, functionName: String = #function, line: Int = #line) throws {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment