Skip to content

Commit

Permalink
Lab 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ddanilyuk committed Oct 1, 2020
1 parent 846e9c5 commit f71b077
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
32 changes: 7 additions & 25 deletions clangCompiler/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
// Errors
let test1 = """
int main() {
return -(3 - 2 / 8)ж
return -(3 - 2 / 8)g
}
"""

Expand Down Expand Up @@ -56,8 +56,8 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
"""

let test6 = """
int main() {
)-3 - 2 / 8;
int main()
return -16 / 7 / 8;
}
"""
// end errors
Expand Down Expand Up @@ -85,45 +85,27 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {

let test10 = """
int main() {
return 16 / 2 / 2 / 2;
return 16.3 / 2 / 02 / 2;
}
"""

let test11 = """
int main() {
return 16 / 2 / 2 / 2;
}
"""

let test12 = """
int main() {
return (-16 - (-2) - 4);
}
"""

let test13 = """
int main() {
return (4 - (-5));
}
"""

let test14 = """
int main() {
return (010 / -2);
}
"""

let _ = [test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, test11, test12, test13]
let _ = [test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, test11]


var code = ""

do {
#if !DEBUG
code = try String(contentsOfFile: "2-07-Swift-IV-82-Danyliuk.txt", encoding: String.Encoding.utf8)
code = try String(contentsOfFile: "2-07-Swift-IV-82-Danyliuk.txt", encoding: String.Encoding.windowsCP1251)
#endif

code = test14
code = test1

print("File text:\n\(code)\n")

Expand Down
1 change: 1 addition & 0 deletions clangCompiler/Main/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ enum Token: Equatable {
throw CompilerError.invalidOperator($0, Token.currentTokenIndex)
}
},

"\\(": { _ in .parensOpen },
"\\)": { _ in .parensClose },
"\\{": { _ in .curlyOpen },
Expand Down

0 comments on commit f71b077

Please sign in to comment.