diff --git a/README.org b/README.org index 3074f22..96d7332 100644 --- a/README.org +++ b/README.org @@ -82,7 +82,7 @@ Check out the =builder= script for more subcommands and details. - [[https://github.com/muqsitnawaz/modern-cpp-cheatsheet][Modern C++ Cheatsheet]] * License -Copyright (c) 2019-2021 Sameer Rahmani +Copyright (c) 2019-2022 Sameer Rahmani *Serene* is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/builder b/builder index 45bf9fd..f3e3062 100755 --- a/builder +++ b/builder @@ -1,7 +1,7 @@ #! /bin/bash # Serene Programming Language # -# Copyright (c) 2019-2021 Sameer Rahmani +# Copyright (c) 2019-2022 Sameer Rahmani # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/cmake/tablegen-serene.cmake b/cmake/tablegen-serene.cmake index c628899..9f582d4 100644 --- a/cmake/tablegen-serene.cmake +++ b/cmake/tablegen-serene.cmake @@ -1,6 +1,6 @@ # Serene Programming Language # -# Copyright (c) 2019-2021 Sameer Rahmani +# Copyright (c) 2019-2022 Sameer Rahmani # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/resources/emacs/serene-dev.el b/resources/emacs/serene-dev.el index 9694b4d..76c2d71 100644 --- a/resources/emacs/serene-dev.el +++ b/resources/emacs/serene-dev.el @@ -1,6 +1,6 @@ ;;; serene-dev --- Serene's development lib for Emacs users -*- lexical-binding: t; -*- ;; -;; Copyright (c) 2019-2021 Sameer Rahmani +;; Copyright (c) 2019-2022 Sameer Rahmani ;; ;; Author: Sameer Rahmani ;; URL: https://serene-lang.org diff --git a/src/tests/context_tests.cpp.inc b/src/tests/context_tests.cpp.inc index eb21f12..7705b0c 100644 --- a/src/tests/context_tests.cpp.inc +++ b/src/tests/context_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,20 +22,22 @@ * SOFTWARE. */ -#include "./test_helpers.cpp.inc" #include "serene/context.h" #include "serene/namespace.h" + +#include "./test_helpers.cpp.inc" #include namespace serene { TEST_CASE("Context tests", "[context]") { auto ctx = makeSereneContext(); - auto ns = ctx->getNS("blah"); + auto ns = ctx->getNS("blah"); REQUIRE_FALSE(ns); - auto userNs = makeNamespace(*ctx, "user", llvm::Optional("/some/file")); + auto userNs = makeNamespace(*ctx, "user", + llvm::Optional("/some/file")); CHECK(userNs->name == "user"); REQUIRE(userNs->filename); @@ -46,9 +48,9 @@ TEST_CASE("Context tests", "[context]") { REQUIRE(ns); CHECK(ns->name == userNs->name); - /// Creating new ns with the same name overrides the old one - auto userNs1 = makeNamespace(*ctx, "user", llvm::Optional("/some/other/file")); + auto userNs1 = makeNamespace( + *ctx, "user", llvm::Optional("/some/other/file")); ns = ctx->getNS("user"); @@ -56,12 +58,12 @@ TEST_CASE("Context tests", "[context]") { CHECK(ns->name == userNs1->name); REQUIRE(ns->filename); CHECK(ns->filename.getValue() == "/some/other/file"); - }; TEST_CASE("Get and Set current namespace", "[context]") { - auto ctx = makeSereneContext(); - auto userNs = makeNamespace(*ctx, "user", llvm::Optional("/some/file")); + auto ctx = makeSereneContext(); + auto userNs = makeNamespace(*ctx, "user", + llvm::Optional("/some/file")); auto isSet = ctx->setCurrentNS("user"); diff --git a/src/tests/environment_tests.cpp.inc b/src/tests/environment_tests.cpp.inc index d8019f3..d63244b 100644 --- a/src/tests/environment_tests.cpp.inc +++ b/src/tests/environment_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,20 +22,22 @@ * SOFTWARE. */ -#include "./test_helpers.cpp.inc" #include "serene/environment.h" #include "serene/exprs/expression.h" #include "serene/exprs/symbol.h" -#include "llvm/ADT/StringRef.h" + +#include "./test_helpers.cpp.inc" #include -namespace serene { +#include +namespace serene { TEST_CASE("Environment tests", "[environment]") { std::unique_ptr range(dummyLocation()); - exprs::Node sym = exprs::make(*range.get(), llvm::StringRef("example")); + exprs::Node sym = + exprs::make(*range.get(), llvm::StringRef("example")); Environment e; llvm::Optional result = e.lookup("a"); diff --git a/src/tests/errors/error_tests.cpp.inc b/src/tests/errors/error_tests.cpp.inc index 505d30b..c5e1b13 100644 --- a/src/tests/errors/error_tests.cpp.inc +++ b/src/tests/errors/error_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,25 +22,25 @@ * SOFTWARE. */ -#include "../test_helpers.cpp.inc" -#include "serene/exprs/symbol.h" #include "serene/errors.h" -#include "llvm/Support/Casting.h" +#include "serene/exprs/symbol.h" + +#include "../test_helpers.cpp.inc" #include - +#include namespace serene { namespace errors { - TEST_CASE("Error Expression", "[expression]") { std::unique_ptr range(dummyLocation()); - auto err = exprs::makeAndCast(*range.get(), &DefExpectSymbol, "Something Failed"); + auto err = exprs::makeAndCast(*range.get(), &DefExpectSymbol, + "Something Failed"); CHECK(err->getVariant()->id == E0001); CHECK(err->toString() == ""); }; -} // namespace exprs +} // namespace errors } // namespace serene diff --git a/src/tests/exprs/expression_tests.cpp.inc b/src/tests/exprs/expression_tests.cpp.inc index 37b345b..7aa9e33 100644 --- a/src/tests/exprs/expression_tests.cpp.inc +++ b/src/tests/exprs/expression_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,11 +22,13 @@ * SOFTWARE. */ -#include "../test_helpers.cpp.inc" #include "serene/exprs/expression.h" #include "serene/exprs/list.h" #include "serene/exprs/symbol.h" -#include "llvm/ADT/ArrayRef.h" + +#include "../test_helpers.cpp.inc" + +#include namespace serene { namespace exprs { @@ -36,7 +38,7 @@ TEST_CASE("Public Expression API", "[expression]") { auto sym = make(*range.get(), "example"); REQUIRE(sym->getType() == ExprType::Symbol); - CHECK(sym->toString() == ""); + CHECK(sym->toString() == ""); auto list = makeAndCast(*range.get(), sym); diff --git a/src/tests/exprs/list_tests.cpp.inc b/src/tests/exprs/list_tests.cpp.inc index 1500b96..59366c6 100644 --- a/src/tests/exprs/list_tests.cpp.inc +++ b/src/tests/exprs/list_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,14 @@ * SOFTWARE. */ -#include "../test_helpers.cpp.inc" #include "serene/exprs/expression.h" #include "serene/exprs/list.h" #include "serene/exprs/symbol.h" #include "serene/namespace.h" #include "serene/reader/reader.h" #include "serene/reader/semantics.h" + +#include "../test_helpers.cpp.inc" #include namespace serene { @@ -37,7 +38,7 @@ namespace exprs { TEST_CASE("List Expression", "[expression]") { std::unique_ptr range(dummyLocation()); - Node sym = make(*range.get(), llvm::StringRef("example")); + Node sym = make(*range.get(), llvm::StringRef("example")); Node sym1 = make(*range.get(), llvm::StringRef("example1")); Node list = make(*range.get()); @@ -81,30 +82,30 @@ TEST_CASE("List Expression", "[expression]") { }; TEST_CASE("List semantic analysis of 'def'", "[semantic]") { - auto ctx = makeSereneContext(); - auto ns = makeNamespace(*ctx, "user", llvm::None); - auto ast = reader::read("(def (a) b)"); + auto ctx = makeSereneContext(); + auto ns = makeNamespace(*ctx, "user", llvm::None); + auto ast = reader::read("(def (a) b)"); auto afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE_FALSE(afterAst); // Fetch the first error CHECK(afterAst.getError()[0]->toString() == ""); - ast = reader::read("(def a)"); + ast = reader::read("(def a)"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE_FALSE(afterAst); CHECK(afterAst.getError()[0]->toString() == ""); - ast = reader::read("(def a b c)"); + ast = reader::read("(def a b c)"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE_FALSE(afterAst); CHECK(afterAst.getError()[0]->toString() == ""); - ast = reader::read("(def a b)"); + ast = reader::read("(def a b)"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE(afterAst); CHECK(astToString(&afterAst.getValue()) == " >"); - ast = reader::read("(def a (fn () a))"); + ast = reader::read("(def a (fn () a))"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE(afterAst); CHECK(astToString(&afterAst.getValue()) == @@ -112,73 +113,77 @@ TEST_CASE("List semantic analysis of 'def'", "[semantic]") { } TEST_CASE("List semantic analysis for 'fn'", "[semantic]") { - auto ctx = makeSereneContext(); - auto ns = makeNamespace(*ctx, "user", llvm::None); - auto ast = reader::read("(fn)"); + auto ctx = makeSereneContext(); + auto ns = makeNamespace(*ctx, "user", llvm::None); + auto ast = reader::read("(fn)"); auto afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE_FALSE(afterAst); REQUIRE(afterAst.getError().size() == 1); CHECK(afterAst.getError()[0]->toString() == ""); - ast = reader::read("(fn ())"); + ast = reader::read("(fn ())"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE(afterAst); CHECK(astToString(&afterAst.getValue()) == " to <>>"); - ast = reader::read("(fn (a b c) a a a)"); + ast = reader::read("(fn (a b c) a a a)"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE(afterAst); CHECK(astToString(&afterAst.getValue()) == - " > to >" - ); + " > to " + " >"); - ast = reader::read("(fn () a b)"); + ast = reader::read("(fn () a b)"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE(afterAst); CHECK(astToString(&afterAst.getValue()) == " to >"); - ast = reader::read("(fn (x) (fn (y) x) z)"); + ast = reader::read("(fn (x) (fn (y) x) z)"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE(afterAst); CHECK(astToString(&afterAst.getValue()) == - "> to > to > >" - ); + "> to > " + "to > >"); - ast = reader::read("(fn (x) (def a b) (def b c))"); + ast = reader::read("(fn (x) (def a b) (def b c))"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE(afterAst); CHECK(astToString(&afterAst.getValue()) == - "> to > >>"); + "> to > " + ">>"); } TEST_CASE("Complex semantic analysis", "[semantic]") { auto ctx = makeSereneContext(); - auto ns = makeNamespace(*ctx, "user", llvm::None); + auto ns = makeNamespace(*ctx, "user", llvm::None); auto ast = reader::read("(def a (fn (x) x))\n((def b (fn (x) (fn (y) y))))\n\n"); auto afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE(afterAst); CHECK(astToString(&afterAst.getValue()) == - " > to >> > to > to >>> >"); + " > to >> " + "> to > to " + ">>> >"); - ctx = makeSereneContext(); - ns = makeNamespace(*ctx, "user", llvm::None); - ast = reader::read("((a b))"); + ctx = makeSereneContext(); + ns = makeNamespace(*ctx, "user", llvm::None); + ast = reader::read("((a b))"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE_FALSE(afterAst); auto errs = afterAst.getError(); CHECK(errs[0]->toString() == ""); - ctx = makeSereneContext(); - ns = makeNamespace(*ctx, "user", llvm::None); - ast = reader::read("(def a (fn (x) x)) (a b)"); + ctx = makeSereneContext(); + ns = makeNamespace(*ctx, "user", llvm::None); + ast = reader::read("(def a (fn (x) x)) (a b)"); afterAst = reader::analyze(*ctx, ast.getValue()); REQUIRE(afterAst); CHECK(astToString(&afterAst.getValue()) == - " > to >> > to > >"); + " > to >> > to > >"); } } // namespace exprs } // namespace serene diff --git a/src/tests/exprs/number_tests.cpp.inc b/src/tests/exprs/number_tests.cpp.inc index c160b50..bc15b0b 100644 --- a/src/tests/exprs/number_tests.cpp.inc +++ b/src/tests/exprs/number_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,8 +22,9 @@ * SOFTWARE. */ -#include "../test_helpers.cpp.inc" #include "serene/exprs/number.h" + +#include "../test_helpers.cpp.inc" #include namespace serene { @@ -40,8 +41,8 @@ TEST_CASE("Number Expression", "[expression]") { CHECK(num1->toString() == ""); CHECK(num2->toString() == ""); - CHECK(num3->toString() == ""); - CHECK(num4->toString() == ""); + CHECK(num3->toString() == ""); + CHECK(num4->toString() == ""); }; } // namespace exprs diff --git a/src/tests/exprs/symbol_tests.cpp.inc b/src/tests/exprs/symbol_tests.cpp.inc index ea22dba..bf77562 100644 --- a/src/tests/exprs/symbol_tests.cpp.inc +++ b/src/tests/exprs/symbol_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,10 +22,11 @@ * SOFTWARE. */ -#include "../test_helpers.cpp.inc" #include "serene/exprs/expression.h" #include "serene/exprs/symbol.h" +#include "../test_helpers.cpp.inc" + namespace serene { namespace exprs { @@ -34,7 +35,7 @@ TEST_CASE("Public Symbol API", "[expression]") { auto sym = make(*range.get(), "example"); REQUIRE(sym->getType() == ExprType::Symbol); - CHECK(sym->toString() == ""); + CHECK(sym->toString() == ""); }; } // namespace exprs } // namespace serene diff --git a/src/tests/namespace_tests.cpp.inc b/src/tests/namespace_tests.cpp.inc index 05389d4..64b9ad0 100644 --- a/src/tests/namespace_tests.cpp.inc +++ b/src/tests/namespace_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,19 +22,20 @@ * SOFTWARE. */ -#include "./test_helpers.cpp.inc" #include "serene/context.h" #include "serene/exprs/expression.h" #include "serene/namespace.h" #include "serene/reader/reader.h" + +#include "./test_helpers.cpp.inc" #include namespace serene { TEST_CASE("Namespace tests", "[namespace]") { - auto ctx = makeSereneContext(); - auto userNs = - makeNamespace(*ctx, "user", llvm::Optional("/some/file")); + auto ctx = makeSereneContext(); + auto userNs = makeNamespace(*ctx, "user", + llvm::Optional("/some/file")); auto maybeAst = reader::read("(x 1) (def b a)"); diff --git a/src/tests/reader/reader_tests.cpp.inc b/src/tests/reader/reader_tests.cpp.inc index f95e0f5..e558498 100644 --- a/src/tests/reader/reader_tests.cpp.inc +++ b/src/tests/reader/reader_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,8 +22,9 @@ * SOFTWARE. */ -#include "../test_helpers.cpp.inc" #include "serene/reader/reader.h" + +#include "../test_helpers.cpp.inc" #include namespace serene { @@ -38,7 +39,7 @@ TEST_CASE("Read numbers", "[reader]") { auto ast = std::move(maybeAst).getValue(); REQUIRE_FALSE(ast.empty()); - CHECK(ast.front()->toString() == ""); + CHECK(ast.front()->toString() == ""); maybeAst = reader::read("-34"); @@ -48,7 +49,7 @@ TEST_CASE("Read numbers", "[reader]") { ast = std::move(maybeAst.getValue()); REQUIRE_FALSE(ast.empty()); - CHECK(ast.front()->toString() == ""); + CHECK(ast.front()->toString() == ""); maybeAst = reader::read("-3.5434"); @@ -58,7 +59,7 @@ TEST_CASE("Read numbers", "[reader]") { ast = std::move(maybeAst.getValue()); REQUIRE_FALSE(ast.empty()); - CHECK(ast.front()->toString() == ""); + CHECK(ast.front()->toString() == ""); maybeAst = reader::read("444323 2123 123123"); @@ -68,8 +69,8 @@ TEST_CASE("Read numbers", "[reader]") { ast = std::move(maybeAst.getValue()); REQUIRE(ast.size() == 3); - CHECK(ast.front()->toString() == ""); - CHECK(ast[1]->toString() == "" ); + CHECK(ast.front()->toString() == ""); + CHECK(ast[1]->toString() == ""); CHECK(ast[2]->toString() == ""); }; TEST_CASE("Read Lists and Symbols", "[reader]") { @@ -81,7 +82,7 @@ TEST_CASE("Read Lists and Symbols", "[reader]") { auto ast = std::move(maybeAst.getValue()); REQUIRE_FALSE(ast.empty()); - CHECK(ast.front()->toString() == " >"); + CHECK(ast.front()->toString() == " >"); maybeAst = reader::read("(x (y (z)))"); @@ -91,7 +92,8 @@ TEST_CASE("Read Lists and Symbols", "[reader]") { ast = std::move(maybeAst.getValue()); REQUIRE_FALSE(ast.empty()); - CHECK(ast.front()->toString() == " >>>"); + CHECK(ast.front()->toString() == + " >>>"); maybeAst = reader::read("(x \n y)"); diff --git a/src/tests/test_helpers.cpp.inc b/src/tests/test_helpers.cpp.inc index 0d66223..344dfa7 100644 --- a/src/tests/test_helpers.cpp.inc +++ b/src/tests/test_helpers.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,23 +25,23 @@ #ifndef TEST_HEALPERS_H #define TEST_HEALPERS_H -#include "catch2/catch.hpp" #include "serene/reader/location.h" -namespace serene { +#include +namespace serene { reader::LocationRange *dummyLocation() { reader::Location start; reader::Location end; start.line = 2; - start.col = 20; - start.pos = 40; + start.col = 20; + start.pos = 40; end.line = 3; - end.col = 30; - end.pos = 80; + end.col = 30; + end.pos = 80; return new reader::LocationRange(start, end); }; diff --git a/src/tests/traits_tests.cpp.inc b/src/tests/traits_tests.cpp.inc index 3f95c75..2a7a842 100644 --- a/src/tests/traits_tests.cpp.inc +++ b/src/tests/traits_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,8 +22,9 @@ * SOFTWARE. */ -#include "./test_helpers.cpp.inc" #include "serene/traits.h" + +#include "./test_helpers.cpp.inc" #include namespace serene { @@ -44,9 +45,13 @@ public: std::string Analyze() { return this->Object().Analyze(); } }; -template std::string Print(Printable &t) { return t.Print(); } +template +std::string Print(Printable &t) { + return t.Print(); +} -template std::string Analyze(Analyzable &t) { +template +std::string Analyze(Analyzable &t) { return t.Analyze(); }; diff --git a/src/tests/utils_tests.cpp.inc b/src/tests/utils_tests.cpp.inc index d571622..b29d40c 100644 --- a/src/tests/utils_tests.cpp.inc +++ b/src/tests/utils_tests.cpp.inc @@ -1,7 +1,7 @@ /* -*- C++ -*- * Serene programming language. * - * Copyright (c) 2019-2021 Sameer Rahmani + * Copyright (c) 2019-2022 Sameer Rahmani * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,9 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "./test_helpers.cpp.inc" #include "serene/utils.h" +#include "./test_helpers.cpp.inc" + namespace serene { TEST_CASE("Result Type", "[utils]") { auto r = Result::success(4);