Finally make a clean sweep and delete / organize old files. Add skeleton for LaTeX formal writeup in doc/ and change license (since this is all new code from the past few years) to BSD-2-Clause-Patent
This commit is contained in:
9
doc/.gitignore
vendored
Normal file
9
doc/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
*.swp
|
||||
*.zip
|
||||
*.aux
|
||||
*.bbl
|
||||
*.blg
|
||||
*.log
|
||||
*.out
|
||||
*.pdf
|
||||
|
||||
345
doc/Manual.tex
345
doc/Manual.tex
@@ -1,345 +0,0 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Kraken Documentation
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
%----------------------------------------------------------------------------------------
|
||||
% PACKAGES AND DOCUMENT CONFIGURATIONS
|
||||
%----------------------------------------------------------------------------------------
|
||||
|
||||
\documentclass{article}
|
||||
|
||||
\usepackage{graphicx} % Required for the inclusion of images
|
||||
\usepackage{amsmath} % Required for some math elements
|
||||
\renewcommand{\labelenumi}{\alph{enumi}.} % Make numbering in the enumerate environment by letter rather than number (e.g. section 6)
|
||||
|
||||
\usepackage{times}
|
||||
\usepackage{listings}
|
||||
\usepackage{color}
|
||||
%----------------------------------------------------------------------------------------
|
||||
% DOCUMENT INFORMATION
|
||||
%----------------------------------------------------------------------------------------
|
||||
|
||||
\title{Kraken Programming Guide v0.0} % Title
|
||||
|
||||
\author{Jack \textsc{Sparrow}} % Author name
|
||||
|
||||
\date{\today} % Date for the report
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle % Insert the title, author and date
|
||||
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION Compiling
|
||||
%----------------------------------------------------------------------------------------
|
||||
\section{Compiling}
|
||||
Kraken compilation currently only supports building the compiler from source.
|
||||
You can clone the repository from a terminal using:
|
||||
\begin{lstlisting}
|
||||
git clone https://github.com/Limvot/kraken.git
|
||||
\end{lstlisting}
|
||||
Once you have the repository, run the following commands:
|
||||
\begin{lstlisting}
|
||||
mkdir build %Create a build directory
|
||||
cd build
|
||||
cmake .. %Requires cmake to build the compiler
|
||||
make %Create the compiler executable
|
||||
\end{lstlisting}
|
||||
This will create a kraken executable, which is how we will call the compiler.
|
||||
Kraken supports several ways of invoking the compiler. These include:
|
||||
\begin{lstlisting}
|
||||
kraken source.krak
|
||||
kraken source.krak outputExe
|
||||
kraken grammarFile.kgm source.krak outputExe
|
||||
\end{lstlisting}
|
||||
The grammar file is a file specific to the compiler, and should be included
|
||||
in the github repository. When you run the compile command, a new directory
|
||||
with the name of the outputExe you specified will be created. In this directory
|
||||
is a shell script, which will compile the created C file into a binary executable.
|
||||
This binary exectuable can then be run as a normal C executable.
|
||||
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION Variables
|
||||
%----------------------------------------------------------------------------------------
|
||||
|
||||
\section{Variables}
|
||||
\label{sec:var}
|
||||
Kraken has automatic type deduction. This is sort of like the duck typing of
|
||||
Python. The difference is that variables cannot change types. In this way, it
|
||||
is much more like an implicit "auto" keyword in C++. Unlike C++, semicolons are
|
||||
optional after declarations.
|
||||
|
||||
\subsection{Variable Declaration}
|
||||
\begin{lstlisting}[language=C++]
|
||||
var A: int; //A is unitialized int
|
||||
var B = 1; //B is integer
|
||||
var C = 2.0; //C is double
|
||||
var D: double = 3.14 //D is double
|
||||
|
||||
\end{lstlisting}
|
||||
\subsection{Primitive Types}
|
||||
The primitive types found in kraken are:
|
||||
\begin{enumerate}
|
||||
\item int
|
||||
\item float
|
||||
\item double
|
||||
\item char
|
||||
\item bool
|
||||
\item void
|
||||
\end{enumerate}
|
||||
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION 2: Functions
|
||||
%----------------------------------------------------------------------------------------
|
||||
\section{Functions}
|
||||
\begin{lstlisting}[language=C++]
|
||||
fun FunctionName(arg1 : arg1_type, arg2 : arg2_type) : returnType {
|
||||
var result = arg1 + arg2;
|
||||
return result;
|
||||
}
|
||||
\end{lstlisting}
|
||||
|
||||
Functions are declared using the {\bf{fun}} keyword. If you pass in
|
||||
variables as shown, there will be passed by value, not by reference.
|
||||
Therefore if you pass a variable in, it will not be modified outside the
|
||||
function.
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION I/O
|
||||
%----------------------------------------------------------------------------------------
|
||||
\section{Input and Output}
|
||||
In order to print to a terminal or file, the {\bf{io}} library must be
|
||||
imported. There are a few different functions you can use to print to the
|
||||
terminal.
|
||||
The print() function will print out to the terminal without a newline
|
||||
character. Like java, there is a println() function that will print whatever
|
||||
you pass in, as well as a newline. There are also functions that can print
|
||||
colors in a unix terminal. The color will continue when you print until
|
||||
you call the function Reset().
|
||||
\begin{enumerate}
|
||||
\item {\color{red}{BoldRed()}}
|
||||
\item {\color{green}{BoldGreen()}}
|
||||
\item {\color{yellow}{BoldYellow()}}
|
||||
\item {\color{blue}{BoldBlue()}}
|
||||
\item {\color{magenta}{BoldMagneta()}}
|
||||
\item {\color{cyan}{BoldCyan()}}
|
||||
\end{enumerate}
|
||||
|
||||
\begin{lstlisting}[language=C++]
|
||||
io::print(3.2); //print without a newline character
|
||||
io::println(varA); //print variable A with a newline character
|
||||
io::BoldRed();
|
||||
io::println("This line is printed Red");
|
||||
io::Reset();
|
||||
io::println("This line is printed black");
|
||||
\end{lstlisting}
|
||||
|
||||
You can also use kraken to read and write to files. The functions are as
|
||||
follows:
|
||||
\begin{lstlisting}[language=C++]
|
||||
//returns true if file exists
|
||||
var ifExists = io::file_exists("/usr/bin/clang");
|
||||
|
||||
//read file into string
|
||||
var fileString = io::read_file("~/Documents/file.txt");
|
||||
|
||||
//write a string to the file
|
||||
io::write_file("/",SteamString);
|
||||
|
||||
//read file into vector of chars
|
||||
var charVec = io::read_file_binary("~/Documents/file2.txt");
|
||||
|
||||
//write a vector of chars to a file
|
||||
io::write_file_binary("/",md5checkSum);
|
||||
\end{lstlisting}
|
||||
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION Memory Management
|
||||
%----------------------------------------------------------------------------------------
|
||||
\section{Memory Management}
|
||||
\subsection{Pointers}
|
||||
Pointers in kraken work like they do in C. The notation is the
|
||||
{\bf{*}} symbol. This is a dereference operator. This means that it
|
||||
operates on a pointer, and gives the variable pointed to. For
|
||||
instance:
|
||||
\begin{lstlisting}[language=C++]
|
||||
var B: *int = 4; //B is a pointer to an integer 4
|
||||
*B = 3; //B is now equal to 3
|
||||
print(B); //would print an address, like "0xFFA3"
|
||||
\end{lstlisting}
|
||||
\subsection{References}
|
||||
References are a way to create "automatic" pointers. If a function
|
||||
takes in a reference, the variable is passed by reference, instead of by
|
||||
value. This means that no copy of the variable is made, and any changes
|
||||
made to the variable in the function will remain after the end of the
|
||||
function. References also allow left-handed assignment. This means that
|
||||
an array indexed on the left hand of an equal sign can have its value
|
||||
changed.
|
||||
\begin{lstlisting}[language=C++]
|
||||
fun RefFunction(arg1: ref int): ref int{
|
||||
return arg1 + 1;
|
||||
}
|
||||
|
||||
var a = 6;
|
||||
var b = RefFunction(a);
|
||||
println(a); //a is now equal to 6
|
||||
println(b); //b is now equal to 6
|
||||
RefFunction(b) = 15;
|
||||
println(b); //b is now equal to 15
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{Dynamic Memory Allocation}
|
||||
In order to allocate memory on the heap instead of the stack, dynamic
|
||||
memory allocation must be used. The data must be explicitly allocated with
|
||||
the {\bf{new}} keyword, and deleted with the {\bf{delete}} keyword. The
|
||||
size in both instances must be provided.
|
||||
\begin{lstlisting}[language=C++]
|
||||
var data = new<int>(8); //Allocate 8 integers on the heap
|
||||
delete(data,8); //Free the memory when its no longer used.
|
||||
\end{lstlisting}
|
||||
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION Classes
|
||||
%----------------------------------------------------------------------------------------
|
||||
|
||||
\section{Classes}
|
||||
\subsection{Constructors}
|
||||
As with most of kraken, classes are based on their C++ counterparts, with
|
||||
a few key differences. Constructors in kraken are not called by default.
|
||||
You must actually call the constructor function. The constructor must return
|
||||
a pointer to the object, which is denoted by the {\bf{this}} keyword.
|
||||
The destructor is automatically called when the object goes out of scope,
|
||||
and is just called destruct(). An example class is shown below:
|
||||
\begin{lstlisting}[language=C++]
|
||||
obj MyObject (Object) {
|
||||
var variable1: int;
|
||||
var variable2: vector::vector<double>;
|
||||
|
||||
fun construct(): *MyObject {
|
||||
variable1 = 42;
|
||||
variable2.construct();
|
||||
return this;
|
||||
}
|
||||
|
||||
//Could also pass by reference???
|
||||
fun copy_construct(old: *MyObject): void {
|
||||
variable1 = &old->variable1;
|
||||
variable2.copy_construct(&old->variable2);
|
||||
}
|
||||
|
||||
fun destruct() {
|
||||
variable2.destruct();
|
||||
}
|
||||
}
|
||||
\end{lstlisting}
|
||||
\subsection{Operator Overloading}
|
||||
Operator overloading allows you to use operators for syntactic sugar, and
|
||||
make your code look nicer. This again borrow mostly from C++, and you can
|
||||
overload most of the operators that you can in C++. An example is shown
|
||||
below:
|
||||
\begin{lstlisting}
|
||||
//Inside a class
|
||||
|
||||
//overload the assignment operator
|
||||
fun operator=(other: SampleObject): void{
|
||||
destruct();
|
||||
copy_construct(&other);
|
||||
}
|
||||
|
||||
//overload the equality operator
|
||||
fun operator==(other: SampleObject): bool{
|
||||
return EqualTest == other.EqualTest;
|
||||
}
|
||||
\end{lstlisting}
|
||||
\subsection{Traits}
|
||||
Currently, Kraken has no notion of inheritance. Instead, objects can be
|
||||
intialized with traits. These give special properties to the object. For
|
||||
instance, if the object is defined with the {\bf{Object}} trait, then its
|
||||
destructor will be called when the object goes out of scope. The second trait
|
||||
that kraken has is the {\bf{Serializable}} trait. This allows it to be used
|
||||
with the {\bf{serialize}} class, which serializes it into a vector of bytes.
|
||||
This stream of bytes could then be used to send messages over TCP, etc.
|
||||
\begin{lstlisting}
|
||||
//Object has both Object and Serializable traits
|
||||
obj Hermes (Object, Serializable) {
|
||||
var RedBull: vector::vector<string>;
|
||||
|
||||
fun construct(): *Hermes {
|
||||
RedBull = "gives you wings";
|
||||
}
|
||||
|
||||
fun serialize(): vector::vector<char> {
|
||||
//String already has a serialize member function
|
||||
var toReturn = RedBull.serialize();
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
fun unserialize(it: ref vector::vector<char>, pos: int): int {
|
||||
pos = RedBull.unserialize(it,pos);
|
||||
return pos;
|
||||
}
|
||||
|
||||
fun destruct(): void {
|
||||
io::println("I must return to my people");
|
||||
}
|
||||
|
||||
\end{lstlisting}
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION Templates
|
||||
%----------------------------------------------------------------------------------------
|
||||
|
||||
\section{Templates}
|
||||
Templates are a very important part of C++, but are also one of the reasons
|
||||
people do not like the language. They are extremely useful, but also fairly
|
||||
hard to use properly. If you make an error while using templates, the bug is
|
||||
often extremely difficult to find. Kraken templates aim to prevent that problem.
|
||||
\\
|
||||
Templates are a way of writing something once for any type. At compile time,
|
||||
the compiler will see what types you are using with the template, and substitute
|
||||
those types in. This is not duck typing, since the types cannot change once they
|
||||
are assigned. It is more like how you can initialize variables in kraken, with
|
||||
the use of {\bf{var}}. This is extremely useful for something like a container.
|
||||
The vector class in kraken uses templates, so you can put any type, including
|
||||
custom objects, into a vector. \\
|
||||
The convention is to use {\bf{T}} for a template, and if there are two,
|
||||
{\bf{U}}. The following example, taken from the vector implementation,
|
||||
demonstrates templates.
|
||||
\begin{lstlisting}[language=C++]
|
||||
//Can have a vector of any type, with <T>
|
||||
obj vector<T> (Object, Serializable) {
|
||||
//data can be an array of any type
|
||||
var data: *T;
|
||||
//size and available are just primitive ints
|
||||
var size: int;
|
||||
var available: int;
|
||||
...
|
||||
}
|
||||
\end{lstlisting}
|
||||
|
||||
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION Standard Library
|
||||
%----------------------------------------------------------------------------------------
|
||||
|
||||
\section{Standard Library}
|
||||
\subsection{Import Statements}
|
||||
\subsection{Vector}
|
||||
\subsection{String}
|
||||
\subsection{Regex}
|
||||
\subsection{Util}
|
||||
\subsection{Data Structures}
|
||||
\subsubsection{Stack}
|
||||
\subsubsection{Queue}
|
||||
\subsubsection{Set}
|
||||
\subsubsection{Map}
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION Understanding Kraken Errors
|
||||
%----------------------------------------------------------------------------------------
|
||||
\section{Understanding Kraken Errors}
|
||||
Section error
|
||||
%----------------------------------------------------------------------------------------
|
||||
% SECTION C Passthrough
|
||||
%----------------------------------------------------------------------------------------
|
||||
\section{C Passthrough}
|
||||
|
||||
\end{document}
|
||||
11
doc/cited-paper.bib
Normal file
11
doc/cited-paper.bib
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
@phdthesis{shutt2010fexprs,
|
||||
title={Fexprs as the basis of Lisp function application or \$vau: the ultimate abstraction},
|
||||
author={Shutt, John N},
|
||||
year={2010}
|
||||
}
|
||||
@article{kearsleyimplementing,
|
||||
title={Implementing a Vau-based Language With Multiple Evaluation Strategies},
|
||||
author={Kearsley, Logan}
|
||||
}
|
||||
|
||||
2
doc/make_paper.sh
Executable file
2
doc/make_paper.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
touch writeup.pdf && rm writeup.aux writeup.bbl writeup.blg writeup.log writeup.out writeup.pdf && pdflatex writeup && bibtex writeup && pdflatex writeup && bibtex writeup && pdflatex writeup && bibtex writeup && evince writeup.pdf
|
||||
38
doc/nix/sources.json
Normal file
38
doc/nix/sources.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"niv": {
|
||||
"branch": "master",
|
||||
"description": "Easy dependency management for Nix projects",
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"owner": "nmattia",
|
||||
"repo": "niv",
|
||||
"rev": "65a61b147f307d24bfd0a5cd56ce7d7b7cc61d2e",
|
||||
"sha256": "17mirpsx5wyw262fpsd6n6m47jcgw8k2bwcp1iwdnrlzy4dhcgqh",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/niv/archive/65a61b147f307d24bfd0a5cd56ce7d7b7cc61d2e.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"branch": "master",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": "",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "2b65a74aba274a06a673dfb6f28b96cbe0b032fb",
|
||||
"sha256": "0f62z6q00dpxnf4c5ip8362kzzcmnlhx6fbia6dr97a21fzbc8aq",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/2b65a74aba274a06a673dfb6f28b96cbe0b032fb.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs-mozilla": {
|
||||
"branch": "master",
|
||||
"description": "mozilla related nixpkgs (extends nixos/nixpkgs repo)",
|
||||
"homepage": "",
|
||||
"owner": "mozilla",
|
||||
"repo": "nixpkgs-mozilla",
|
||||
"rev": "0510159186dd2ef46e5464484fbdf119393afa58",
|
||||
"sha256": "1c6r5ldkh71v6acsfhni7f9sxvi7xrqzshcwd8w0hl2rrqyzi58w",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/0510159186dd2ef46e5464484fbdf119393afa58.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
||||
174
doc/nix/sources.nix
Normal file
174
doc/nix/sources.nix
Normal file
@@ -0,0 +1,174 @@
|
||||
# This file has been generated by Niv.
|
||||
|
||||
let
|
||||
|
||||
#
|
||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||
#
|
||||
|
||||
fetch_file = pkgs: name: spec:
|
||||
let
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
||||
|
||||
fetch_tarball = pkgs: name: spec:
|
||||
let
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
||||
|
||||
fetch_git = name: spec:
|
||||
let
|
||||
ref =
|
||||
if spec ? ref then spec.ref else
|
||||
if spec ? branch then "refs/heads/${spec.branch}" else
|
||||
if spec ? tag then "refs/tags/${spec.tag}" else
|
||||
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
||||
in
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
|
||||
|
||||
fetch_local = spec: spec.path;
|
||||
|
||||
fetch_builtin-tarball = name: throw
|
||||
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
||||
|
||||
fetch_builtin-url = name: throw
|
||||
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=file -a builtin=true'';
|
||||
|
||||
#
|
||||
# Various helpers
|
||||
#
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
||||
sanitizeName = name:
|
||||
(
|
||||
concatMapStrings (s: if builtins.isList s then "-" else s)
|
||||
(
|
||||
builtins.split "[^[:alnum:]+._?=-]+"
|
||||
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
||||
)
|
||||
);
|
||||
|
||||
# The set of packages used when specs are fetched using non-builtins.
|
||||
mkPkgs = sources: system:
|
||||
let
|
||||
sourcesNixpkgs =
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||
in
|
||||
if builtins.hasAttr "nixpkgs" sources
|
||||
then sourcesNixpkgs
|
||||
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> {}
|
||||
else
|
||||
abort
|
||||
''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
|
||||
# The actual fetching function.
|
||||
fetch = pkgs: name: spec:
|
||||
|
||||
if ! builtins.hasAttr "type" spec then
|
||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||
else if spec.type == "file" then fetch_file pkgs name spec
|
||||
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
||||
else if spec.type == "git" then fetch_git name spec
|
||||
else if spec.type == "local" then fetch_local spec
|
||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
||||
else if spec.type == "builtin-url" then fetch_builtin-url name
|
||||
else
|
||||
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
|
||||
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
||||
# the path directly as opposed to the fetched source.
|
||||
replace = name: drv:
|
||||
let
|
||||
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
||||
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
||||
in
|
||||
if ersatz == "" then drv else
|
||||
# this turns the string into an actual Nix path (for both absolute and
|
||||
# relative paths)
|
||||
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
|
||||
|
||||
# Ports of functions for older nix versions
|
||||
|
||||
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||
mapAttrs = builtins.mapAttrs or (
|
||||
f: set: with builtins;
|
||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||
);
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
||||
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
||||
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||
concatMapStrings = f: list: concatStrings (map f list);
|
||||
concatStrings = builtins.concatStringsSep "";
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
||||
optionalAttrs = cond: as: if cond then as else {};
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
# fetchurl version that is compatible between all the versions of Nix
|
||||
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchurl attrs;
|
||||
|
||||
# Create the final "sources" from the config
|
||||
mkSources = config:
|
||||
mapAttrs (
|
||||
name: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
||||
) config.sources;
|
||||
|
||||
# The "config" used by the fetchers
|
||||
mkConfig =
|
||||
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
||||
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, system ? builtins.currentSystem
|
||||
, pkgs ? mkPkgs sources system
|
||||
}: rec {
|
||||
# The sources, i.e. the attribute set of spec name to spec
|
||||
inherit sources;
|
||||
|
||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||
inherit pkgs;
|
||||
};
|
||||
|
||||
in
|
||||
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
||||
11
doc/shell.nix
Normal file
11
doc/shell.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
let
|
||||
sources = import ./nix/sources.nix;
|
||||
pkgs = import sources.nixpkgs { };
|
||||
in
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
texlive.combined.scheme-full
|
||||
evince
|
||||
];
|
||||
}
|
||||
|
||||
269
doc/writeup.tex
Normal file
269
doc/writeup.tex
Normal file
@@ -0,0 +1,269 @@
|
||||
%%
|
||||
%% This is file `sample-acmsmall.tex',
|
||||
%% generated with the docstrip utility.
|
||||
%%
|
||||
%% The original source files were:
|
||||
%%
|
||||
%% samples.dtx (with options: `acmsmall')
|
||||
%%
|
||||
%% IMPORTANT NOTICE:
|
||||
%%
|
||||
%% For the copyright see the source file.
|
||||
%%
|
||||
%% Any modified versions of this file must be renamed
|
||||
%% with new filenames distinct from sample-acmsmall.tex.
|
||||
%%
|
||||
%% For distribution of the original source see the terms
|
||||
%% for copying and modification in the file samples.dtx.
|
||||
%%
|
||||
%% This generated file may be distributed as long as the
|
||||
%% original source files, as listed above, are part of the
|
||||
%% same distribution. (The sources need not necessarily be
|
||||
%% in the same archive or directory.)
|
||||
%%
|
||||
%%
|
||||
%% Commands for TeXCount
|
||||
%TC:macro \cite [option:text,text]
|
||||
%TC:macro \citep [option:text,text]
|
||||
%TC:macro \citet [option:text,text]
|
||||
%TC:envir table 0 1
|
||||
%TC:envir table* 0 1
|
||||
%TC:envir tabular [ignore] word
|
||||
%TC:envir displaymath 0 word
|
||||
%TC:envir math 0 word
|
||||
%TC:envir comment 0 0
|
||||
%%
|
||||
%%
|
||||
%% The first command in your LaTeX source must be the \documentclass command.
|
||||
\documentclass[acmsmall]{acmart}
|
||||
|
||||
%%
|
||||
%% \BibTeX command to typeset BibTeX logo in the docs
|
||||
\AtBeginDocument{%
|
||||
\providecommand\BibTeX{{%
|
||||
\normalfont B\kern-0.5em{\scshape i\kern-0.25em b}\kern-0.8em\TeX}}}
|
||||
|
||||
%% Rights management information. This information is sent to you
|
||||
%% when you complete the rights form. These commands have SAMPLE
|
||||
%% values in them; it is your responsibility as an author to replace
|
||||
%% the commands and values with those provided to you when you
|
||||
%% complete the rights form.
|
||||
\setcopyright{acmcopyright}
|
||||
\copyrightyear{2022}
|
||||
\acmYear{2022}
|
||||
\acmDOI{10.1145/1122445.1122456}
|
||||
|
||||
|
||||
%%
|
||||
%% These commands are for a JOURNAL article.
|
||||
\acmJournal{JACM}
|
||||
\acmVolume{37}
|
||||
\acmNumber{4}
|
||||
\acmArticle{111}
|
||||
\acmMonth{8}
|
||||
|
||||
%%
|
||||
%% Submission ID.
|
||||
%% Use this when submitting an article to a sponsored event. You'll
|
||||
%% receive a unique submission ID from the organizers
|
||||
%% of the event, and this ID should be used as the parameter to this command.
|
||||
\acmSubmissionID{123-A56-BU3}
|
||||
|
||||
%%
|
||||
%% The majority of ACM publications use numbered citations and
|
||||
%% references. The command \citestyle{authoryear} switches to the
|
||||
%% "author year" style.
|
||||
%%
|
||||
%% If you are preparing content for an event
|
||||
%% sponsored by ACM SIGGRAPH, you must use the "author year" style of
|
||||
%% citations and references.
|
||||
%% Uncommenting
|
||||
%% the next command will enable that style.
|
||||
%%\citestyle{acmauthoryear}
|
||||
|
||||
%%
|
||||
%% end of the preamble, start of the body of the document source.
|
||||
\begin{document}
|
||||
|
||||
%%
|
||||
%% The "title" command has an optional parameter,
|
||||
%% allowing the author to define a "short title" to be used in page headers.
|
||||
\title{Efficient compilation of a functional Lisp based on Vau calculus}
|
||||
|
||||
%%
|
||||
%% The "author" command and its associated commands are used to define
|
||||
%% the authors and their affiliations.
|
||||
%% Of note is the shared affiliation of the first two authors, and the
|
||||
%% "authornote" and "authornotemark" commands
|
||||
%% used to denote shared contribution to the research.
|
||||
\author{Nathan Braswell}
|
||||
\email{nathan.braswell@gtri.@gatech.edu}
|
||||
%%\orcid{1234-5678-9012}
|
||||
%%\author{G.K.M. Tobin}
|
||||
%%\authornotemark[1]
|
||||
%%\email{webmaster@marysville-ohio.com}
|
||||
\affiliation{%
|
||||
\institution{Georgia Tech}
|
||||
%%\streetaddress{P.O. Box 1212}
|
||||
\city{Atlanta}
|
||||
\state{GA}
|
||||
\country{USA}
|
||||
%%\postcode{43017-6221}
|
||||
}
|
||||
|
||||
%%\author{Lars Th{\o}rv{\"a}ld}
|
||||
%%\affiliation{%
|
||||
%% \institution{The Th{\o}rv{\"a}ld Group}
|
||||
%% \streetaddress{1 Th{\o}rv{\"a}ld Circle}
|
||||
%% \city{Hekla}
|
||||
%% \country{Iceland}}
|
||||
%%\email{larst@affiliation.org}
|
||||
|
||||
%%\author{Valerie B\'eranger}
|
||||
%%\affiliation{%
|
||||
%% \institution{Inria Paris-Rocquencourt}
|
||||
%% \city{Rocquencourt}
|
||||
%% \country{France}
|
||||
%%}
|
||||
|
||||
%%\author{Aparna Patel}
|
||||
%%\affiliation{%
|
||||
%% \institution{Rajiv Gandhi University}
|
||||
%% \streetaddress{Rono-Hills}
|
||||
%% \city{Doimukh}
|
||||
%% \state{Arunachal Pradesh}
|
||||
%% \country{India}}
|
||||
|
||||
%%\author{Huifen Chan}
|
||||
%%\affiliation{%
|
||||
%% \institution{Tsinghua University}
|
||||
%% \streetaddress{30 Shuangqing Rd}
|
||||
%% \city{Haidian Qu}
|
||||
%% \state{Beijing Shi}
|
||||
%% \country{China}}
|
||||
|
||||
%%\author{Charles Palmer}
|
||||
%%\affiliation{%
|
||||
%% \institution{Palmer Research Laboratories}
|
||||
%% \streetaddress{8600 Datapoint Drive}
|
||||
%% \city{San Antonio}
|
||||
%% \state{Texas}
|
||||
%% \country{USA}
|
||||
%% \postcode{78229}}
|
||||
%%\email{cpalmer@prl.com}
|
||||
|
||||
%%\author{John Smith}
|
||||
%%\affiliation{%
|
||||
%% \institution{The Th{\o}rv{\"a}ld Group}
|
||||
%% \streetaddress{1 Th{\o}rv{\"a}ld Circle}
|
||||
%% \city{Hekla}
|
||||
%% \country{Iceland}}
|
||||
%%\email{jsmith@affiliation.org}
|
||||
|
||||
%%\author{Julius P. Kumquat}
|
||||
%%\affiliation{%
|
||||
%% \institution{The Kumquat Consortium}
|
||||
%% \city{New York}
|
||||
%% \country{USA}}
|
||||
%%\email{jpkumquat@consortium.net}
|
||||
|
||||
%%
|
||||
%% By default, the full list of authors will be used in the page
|
||||
%% headers. Often, this list is too long, and will overlap
|
||||
%% other information printed in the page headers. This command allows
|
||||
%% the author to define a more concise list
|
||||
%% of authors' names for this purpose.
|
||||
%%\renewcommand{\shortauthors}{Trovato and Tobin, et al.}
|
||||
|
||||
%%
|
||||
%% The abstract is a short summary of the work to be presented in the
|
||||
%% article.
|
||||
\begin{abstract}
|
||||
Naively executing a language using Vau and Fexprs instead of macros
|
||||
is slow.
|
||||
\end{abstract}
|
||||
|
||||
%%
|
||||
%% The code below is generated by the tool at http://dl.acm.org/ccs.cfm.
|
||||
%% Please copy and paste the code instead of the example below.
|
||||
%%
|
||||
%%\begin{CCSXML}
|
||||
%%<ccs2012>
|
||||
%% <concept>
|
||||
%% <concept_id>10010520.10010553.10010562</concept_id>
|
||||
%% <concept_desc>Computer systems organization~Embedded systems</concept_desc>
|
||||
%% <concept_significance>500</concept_significance>
|
||||
%% </concept>
|
||||
%% <concept>
|
||||
%% <concept_id>10010520.10010575.10010755</concept_id>
|
||||
%% <concept_desc>Computer systems organization~Redundancy</concept_desc>
|
||||
%% <concept_significance>300</concept_significance>
|
||||
%% </concept>
|
||||
%% <concept>
|
||||
%% <concept_id>10010520.10010553.10010554</concept_id>
|
||||
%% <concept_desc>Computer systems organization~Robotics</concept_desc>
|
||||
%% <concept_significance>100</concept_significance>
|
||||
%% </concept>
|
||||
%% <concept>
|
||||
%% <concept_id>10003033.10003083.10003095</concept_id>
|
||||
%% <concept_desc>Networks~Network reliability</concept_desc>
|
||||
%% <concept_significance>100</concept_significance>
|
||||
%% </concept>
|
||||
%%</ccs2012>
|
||||
%%\end{CCSXML}
|
||||
|
||||
%%\ccsdesc[500]{Computer systems organization~Embedded systems}
|
||||
%%\ccsdesc[300]{Computer systems organization~Redundancy}
|
||||
%%\ccsdesc{Computer systems organization~Robotics}
|
||||
%%\ccsdesc[100]{Networks~Network reliability}
|
||||
|
||||
%%
|
||||
%% Keywords. The author(s) should pick words that accurately describe
|
||||
%% the work being presented. Separate the keywords with commas.
|
||||
\keywords{partial evaluation, vau, fexprs, WebAssembly}
|
||||
|
||||
|
||||
%%
|
||||
%% This command processes the author and affiliation and title
|
||||
%% information and builds the first part of the formatted document.
|
||||
%%\maketitle
|
||||
|
||||
\section{Introduction and Motivation}
|
||||
Vaus \cite{shutt2010fexprs} (at \url{https://web.wpi.edu/Pubs/ETD/Available/etd-090110-124904/unrestricted/jshutt.pdf})
|
||||
All code available at \url{https://github.com/limvot/kraken}
|
||||
|
||||
\section{Prior Work}
|
||||
\begin{itemize}
|
||||
\item{} Axis of Eval rundown of attempted implmentations - \url{https://axisofeval.blogspot.com/2011/09/kernel-underground.html} \\
|
||||
\item{} Lambda The Ultimate small discussion of partial eval for Vau/Kernel - \url{http://lambda-the-ultimate.org/node/4346} \\
|
||||
\item{} Implementing a Vau-based Language With Multiple Evaluation Strategies - \cite{kearsleyimplementing} \\
|
||||
Talks about how partial evaluation could make efficient, doesn't do it.
|
||||
\item{} Google Groups email thread by Andres Navarro - \url{https://groups.google.com/g/klisp/c/Dva-Le8Hr-g/m/pyl1Ufu-vksJ} \\
|
||||
Andres Navarro talks about his experimental fklisp which is a "very simple functional dialect of Kernel" with no mutation or first class continuations.
|
||||
It doesn't compile anything, but prints out the partially evalauted expression. Was a work in progress, ran into performance problems, seems abandond.
|
||||
\end{itemize}
|
||||
|
||||
\subsection{Issues}
|
||||
Slow.
|
||||
\section{Solution}
|
||||
Purely functional.
|
||||
Tricky partial evaluation.
|
||||
|
||||
\begin{verbatim}
|
||||
((wrap (vau (let1)
|
||||
|
||||
(let1 lambda (vau se (p b1) (wrap (eval (array vau p b1) se)))
|
||||
(lambda (n) (* n 2))
|
||||
)
|
||||
|
||||
; impl of let1
|
||||
)) (vau de (s v b) (eval (array (array vau (array s) b) (eval v de)) de)))
|
||||
\end{verbatim}
|
||||
|
||||
\bibliographystyle{ACM-Reference-Format}
|
||||
\bibliography{cited-paper}
|
||||
|
||||
\end{document}
|
||||
\endinput
|
||||
%%
|
||||
%% End of file `sample-acmsmall.tex'.
|
||||
Reference in New Issue
Block a user