Fix the license header

This commit is contained in:
Sameer Rahmani 2022-02-08 17:56:15 +00:00
parent 7dc587ecbc
commit f663ba0c25
16 changed files with 118 additions and 96 deletions

View File

@ -82,7 +82,7 @@ Check out the =builder= script for more subcommands and details.
- [[https://github.com/muqsitnawaz/modern-cpp-cheatsheet][Modern C++ Cheatsheet]] - [[https://github.com/muqsitnawaz/modern-cpp-cheatsheet][Modern C++ Cheatsheet]]
* License * License
Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
*Serene* is free software; you can redistribute it and/or modify *Serene* is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
#! /bin/bash #! /bin/bash
# Serene Programming Language # Serene Programming Language
# #
# Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> # Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
# Serene Programming Language # Serene Programming Language
# #
# Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> # Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
;;; serene-dev --- Serene's development lib for Emacs users -*- lexical-binding: t; -*- ;;; 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 <lxsameer@gnu.org> ;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://serene-lang.org ;; URL: https://serene-lang.org

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,9 +22,10 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "./test_helpers.cpp.inc"
#include "serene/context.h" #include "serene/context.h"
#include "serene/namespace.h" #include "serene/namespace.h"
#include "./test_helpers.cpp.inc"
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
namespace serene { namespace serene {
@ -35,7 +36,8 @@ TEST_CASE("Context tests", "[context]") {
REQUIRE_FALSE(ns); REQUIRE_FALSE(ns);
auto userNs = makeNamespace(*ctx, "user", llvm::Optional<llvm::StringRef>("/some/file")); auto userNs = makeNamespace(*ctx, "user",
llvm::Optional<llvm::StringRef>("/some/file"));
CHECK(userNs->name == "user"); CHECK(userNs->name == "user");
REQUIRE(userNs->filename); REQUIRE(userNs->filename);
@ -46,9 +48,9 @@ TEST_CASE("Context tests", "[context]") {
REQUIRE(ns); REQUIRE(ns);
CHECK(ns->name == userNs->name); CHECK(ns->name == userNs->name);
/// Creating new ns with the same name overrides the old one /// Creating new ns with the same name overrides the old one
auto userNs1 = makeNamespace(*ctx, "user", llvm::Optional<llvm::StringRef>("/some/other/file")); auto userNs1 = makeNamespace(
*ctx, "user", llvm::Optional<llvm::StringRef>("/some/other/file"));
ns = ctx->getNS("user"); ns = ctx->getNS("user");
@ -56,12 +58,12 @@ TEST_CASE("Context tests", "[context]") {
CHECK(ns->name == userNs1->name); CHECK(ns->name == userNs1->name);
REQUIRE(ns->filename); REQUIRE(ns->filename);
CHECK(ns->filename.getValue() == "/some/other/file"); CHECK(ns->filename.getValue() == "/some/other/file");
}; };
TEST_CASE("Get and Set current namespace", "[context]") { TEST_CASE("Get and Set current namespace", "[context]") {
auto ctx = makeSereneContext(); auto ctx = makeSereneContext();
auto userNs = makeNamespace(*ctx, "user", llvm::Optional<llvm::StringRef>("/some/file")); auto userNs = makeNamespace(*ctx, "user",
llvm::Optional<llvm::StringRef>("/some/file"));
auto isSet = ctx->setCurrentNS("user"); auto isSet = ctx->setCurrentNS("user");

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,20 +22,22 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "./test_helpers.cpp.inc"
#include "serene/environment.h" #include "serene/environment.h"
#include "serene/exprs/expression.h" #include "serene/exprs/expression.h"
#include "serene/exprs/symbol.h" #include "serene/exprs/symbol.h"
#include "llvm/ADT/StringRef.h"
#include "./test_helpers.cpp.inc"
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
namespace serene { #include <llvm/ADT/StringRef.h>
namespace serene {
TEST_CASE("Environment tests", "[environment]") { TEST_CASE("Environment tests", "[environment]") {
std::unique_ptr<reader::LocationRange> range(dummyLocation()); std::unique_ptr<reader::LocationRange> range(dummyLocation());
exprs::Node sym = exprs::make<exprs::Symbol>(*range.get(), llvm::StringRef("example")); exprs::Node sym =
exprs::make<exprs::Symbol>(*range.get(), llvm::StringRef("example"));
Environment<llvm::StringRef, exprs::Node> e; Environment<llvm::StringRef, exprs::Node> e;
llvm::Optional<exprs::Node> result = e.lookup("a"); llvm::Optional<exprs::Node> result = e.lookup("a");

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,25 +22,25 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "../test_helpers.cpp.inc"
#include "serene/exprs/symbol.h"
#include "serene/errors.h" #include "serene/errors.h"
#include "llvm/Support/Casting.h" #include "serene/exprs/symbol.h"
#include "../test_helpers.cpp.inc"
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
#include <llvm/Support/Casting.h>
namespace serene { namespace serene {
namespace errors { namespace errors {
TEST_CASE("Error Expression", "[expression]") { TEST_CASE("Error Expression", "[expression]") {
std::unique_ptr<reader::LocationRange> range(dummyLocation()); std::unique_ptr<reader::LocationRange> range(dummyLocation());
auto err = exprs::makeAndCast<Error>(*range.get(), &DefExpectSymbol, "Something Failed"); auto err = exprs::makeAndCast<Error>(*range.get(), &DefExpectSymbol,
"Something Failed");
CHECK(err->getVariant()->id == E0001); CHECK(err->getVariant()->id == E0001);
CHECK(err->toString() == "<Error E1: Something Failed>"); CHECK(err->toString() == "<Error E1: Something Failed>");
}; };
} // namespace exprs } // namespace errors
} // namespace serene } // namespace serene

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,11 +22,13 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "../test_helpers.cpp.inc"
#include "serene/exprs/expression.h" #include "serene/exprs/expression.h"
#include "serene/exprs/list.h" #include "serene/exprs/list.h"
#include "serene/exprs/symbol.h" #include "serene/exprs/symbol.h"
#include "llvm/ADT/ArrayRef.h"
#include "../test_helpers.cpp.inc"
#include <llvm/ADT/ArrayRef.h>
namespace serene { namespace serene {
namespace exprs { namespace exprs {

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,13 +22,14 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "../test_helpers.cpp.inc"
#include "serene/exprs/expression.h" #include "serene/exprs/expression.h"
#include "serene/exprs/list.h" #include "serene/exprs/list.h"
#include "serene/exprs/symbol.h" #include "serene/exprs/symbol.h"
#include "serene/namespace.h" #include "serene/namespace.h"
#include "serene/reader/reader.h" #include "serene/reader/reader.h"
#include "serene/reader/semantics.h" #include "serene/reader/semantics.h"
#include "../test_helpers.cpp.inc"
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
namespace serene { namespace serene {
@ -130,8 +131,8 @@ TEST_CASE("List semantic analysis for 'fn'", "[semantic]") {
afterAst = reader::analyze(*ctx, ast.getValue()); afterAst = reader::analyze(*ctx, ast.getValue());
REQUIRE(afterAst); REQUIRE(afterAst);
CHECK(astToString(&afterAst.getValue()) == CHECK(astToString(&afterAst.getValue()) ==
"<Fn ___fn___1 <List <Symbol a> <Symbol b> <Symbol c>> to <Symbol a> <Symbol a> <Symbol a>>" "<Fn ___fn___1 <List <Symbol a> <Symbol b> <Symbol c>> to <Symbol a> "
); "<Symbol a> <Symbol a>>");
ast = reader::read("(fn () a b)"); ast = reader::read("(fn () a b)");
afterAst = reader::analyze(*ctx, ast.getValue()); afterAst = reader::analyze(*ctx, ast.getValue());
@ -143,14 +144,15 @@ TEST_CASE("List semantic analysis for 'fn'", "[semantic]") {
afterAst = reader::analyze(*ctx, ast.getValue()); afterAst = reader::analyze(*ctx, ast.getValue());
REQUIRE(afterAst); REQUIRE(afterAst);
CHECK(astToString(&afterAst.getValue()) == CHECK(astToString(&afterAst.getValue()) ==
"<Fn ___fn___4 <List <Symbol x>> to <Fn ___fn___3 <List <Symbol y>> to <Symbol x>> <Symbol z>>" "<Fn ___fn___4 <List <Symbol x>> to <Fn ___fn___3 <List <Symbol y>> "
); "to <Symbol x>> <Symbol z>>");
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()); afterAst = reader::analyze(*ctx, ast.getValue());
REQUIRE(afterAst); REQUIRE(afterAst);
CHECK(astToString(&afterAst.getValue()) == CHECK(astToString(&afterAst.getValue()) ==
"<Fn ___fn___5 <List <Symbol x>> to <Def a -> <Symbol b>> <Def b -> <Symbol c>>>"); "<Fn ___fn___5 <List <Symbol x>> to <Def a -> <Symbol b>> <Def b -> "
"<Symbol c>>>");
} }
TEST_CASE("Complex semantic analysis", "[semantic]") { TEST_CASE("Complex semantic analysis", "[semantic]") {
@ -161,7 +163,9 @@ TEST_CASE("Complex semantic analysis", "[semantic]") {
auto afterAst = reader::analyze(*ctx, ast.getValue()); auto afterAst = reader::analyze(*ctx, ast.getValue());
REQUIRE(afterAst); REQUIRE(afterAst);
CHECK(astToString(&afterAst.getValue()) == CHECK(astToString(&afterAst.getValue()) ==
"<Def a -> <Fn a <List <Symbol x>> to <Symbol x>>> <Call <Def b -> <Fn b <List <Symbol x>> to <Fn ___fn___1 <List <Symbol y>> to <Symbol y>>>> >"); "<Def a -> <Fn a <List <Symbol x>> to <Symbol x>>> <Call <Def b -> "
"<Fn b <List <Symbol x>> to <Fn ___fn___1 <List <Symbol y>> to "
"<Symbol y>>>> >");
ctx = makeSereneContext(); ctx = makeSereneContext();
ns = makeNamespace(*ctx, "user", llvm::None); ns = makeNamespace(*ctx, "user", llvm::None);
@ -178,7 +182,8 @@ TEST_CASE("Complex semantic analysis", "[semantic]") {
REQUIRE(afterAst); REQUIRE(afterAst);
CHECK(astToString(&afterAst.getValue()) == CHECK(astToString(&afterAst.getValue()) ==
"<Def a -> <Fn a <List <Symbol x>> to <Symbol x>>> <Call <Fn a <List <Symbol x>> to <Symbol x>> <Symbol b>>"); "<Def a -> <Fn a <List <Symbol x>> to <Symbol x>>> <Call <Fn a <List "
"<Symbol x>> to <Symbol x>> <Symbol b>>");
} }
} // namespace exprs } // namespace exprs
} // namespace serene } // namespace serene

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,8 +22,9 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "../test_helpers.cpp.inc"
#include "serene/exprs/number.h" #include "serene/exprs/number.h"
#include "../test_helpers.cpp.inc"
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
namespace serene { namespace serene {

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,10 +22,11 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "../test_helpers.cpp.inc"
#include "serene/exprs/expression.h" #include "serene/exprs/expression.h"
#include "serene/exprs/symbol.h" #include "serene/exprs/symbol.h"
#include "../test_helpers.cpp.inc"
namespace serene { namespace serene {
namespace exprs { namespace exprs {

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,19 +22,20 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "./test_helpers.cpp.inc"
#include "serene/context.h" #include "serene/context.h"
#include "serene/exprs/expression.h" #include "serene/exprs/expression.h"
#include "serene/namespace.h" #include "serene/namespace.h"
#include "serene/reader/reader.h" #include "serene/reader/reader.h"
#include "./test_helpers.cpp.inc"
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
namespace serene { namespace serene {
TEST_CASE("Namespace tests", "[namespace]") { TEST_CASE("Namespace tests", "[namespace]") {
auto ctx = makeSereneContext(); auto ctx = makeSereneContext();
auto userNs = auto userNs = makeNamespace(*ctx, "user",
makeNamespace(*ctx, "user", llvm::Optional<llvm::StringRef>("/some/file")); llvm::Optional<llvm::StringRef>("/some/file"));
auto maybeAst = reader::read("(x 1) (def b a)"); auto maybeAst = reader::read("(x 1) (def b a)");

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,8 +22,9 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "../test_helpers.cpp.inc"
#include "serene/reader/reader.h" #include "serene/reader/reader.h"
#include "../test_helpers.cpp.inc"
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
namespace serene { namespace serene {
@ -91,7 +92,8 @@ TEST_CASE("Read Lists and Symbols", "[reader]") {
ast = std::move(maybeAst.getValue()); ast = std::move(maybeAst.getValue());
REQUIRE_FALSE(ast.empty()); REQUIRE_FALSE(ast.empty());
CHECK(ast.front()->toString() == "<List <Symbol x> <List <Symbol y> <List <Symbol z>>>>"); CHECK(ast.front()->toString() ==
"<List <Symbol x> <List <Symbol y> <List <Symbol z>>>>");
maybeAst = reader::read("(x \n y)"); maybeAst = reader::read("(x \n y)");

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -25,11 +25,11 @@
#ifndef TEST_HEALPERS_H #ifndef TEST_HEALPERS_H
#define TEST_HEALPERS_H #define TEST_HEALPERS_H
#include "catch2/catch.hpp"
#include "serene/reader/location.h" #include "serene/reader/location.h"
namespace serene { #include <catch2/catch.hpp>
namespace serene {
reader::LocationRange *dummyLocation() { reader::LocationRange *dummyLocation() {
reader::Location start; reader::Location start;

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -22,8 +22,9 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include "./test_helpers.cpp.inc"
#include "serene/traits.h" #include "serene/traits.h"
#include "./test_helpers.cpp.inc"
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
namespace serene { namespace serene {
@ -44,9 +45,13 @@ public:
std::string Analyze() { return this->Object().Analyze(); } std::string Analyze() { return this->Object().Analyze(); }
}; };
template <typename T> std::string Print(Printable<T> &t) { return t.Print(); } template <typename T>
std::string Print(Printable<T> &t) {
return t.Print();
}
template <typename T> std::string Analyze(Analyzable<T> &t) { template <typename T>
std::string Analyze(Analyzable<T> &t) {
return t.Analyze(); return t.Analyze();
}; };

View File

@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
* Serene programming language. * Serene programming language.
* *
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org> * Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
#include "./test_helpers.cpp.inc"
#include "serene/utils.h" #include "serene/utils.h"
#include "./test_helpers.cpp.inc"
namespace serene { namespace serene {
TEST_CASE("Result Type", "[utils]") { TEST_CASE("Result Type", "[utils]") {
auto r = Result<int>::success(4); auto r = Result<int>::success(4);