This commit is contained in:
parent
17f4ebc297
commit
035b98a602
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Daniel's Blog
|
title: Daniel's Blog
|
||||||
|
description: Daniel Fedorin's personal blog, covering topics such as functional programming, compiler development, and more!
|
||||||
---
|
---
|
||||||
## Hello!
|
## Hello!
|
||||||
Welcome to my blog. Here, I write about various subjects, including (but not limited to)
|
Welcome to my blog. Here, I write about various subjects, including (but not limited to)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 0 - Intro
|
title: Compiling a Functional Language Using C++, Part 0 - Intro
|
||||||
date: 2019-08-03T01:02:30-07:00
|
date: 2019-08-03T01:02:30-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this first post of a larger series, we embark on a journey of developing a compiler for a lazily evaluated functional language."
|
||||||
---
|
---
|
||||||
During my last academic term, I was enrolled in a compilers course.
|
During my last academic term, I was enrolled in a compilers course.
|
||||||
We had a final project - develop a compiler for a basic Python subset,
|
We had a final project - develop a compiler for a basic Python subset,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 1 - Tokenizing
|
title: Compiling a Functional Language Using C++, Part 1 - Tokenizing
|
||||||
date: 2019-08-03T01:02:30-07:00
|
date: 2019-08-03T01:02:30-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we tackle the first component of our compiler: tokenizing."
|
||||||
---
|
---
|
||||||
It makes sense to build a compiler bit by bit, following the stages we outlined in
|
It makes sense to build a compiler bit by bit, following the stages we outlined in
|
||||||
the first post of the series. This is because these stages are essentially a pipeline,
|
the first post of the series. This is because these stages are essentially a pipeline,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 2 - Parsing
|
title: Compiling a Functional Language Using C++, Part 2 - Parsing
|
||||||
date: 2019-08-03T01:02:30-07:00
|
date: 2019-08-03T01:02:30-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we combine our compiler's tokenizer with a parser, allowing us to extract structure from input source code."
|
||||||
---
|
---
|
||||||
In the previous post, we covered tokenizing. We learned how to convert an input string into logical segments, and even wrote up a tokenizer to do it according to the rules of our language. Now, it's time to make sense of the tokens, and parse our language.
|
In the previous post, we covered tokenizing. We learned how to convert an input string into logical segments, and even wrote up a tokenizer to do it according to the rules of our language. Now, it's time to make sense of the tokens, and parse our language.
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 3 - Type Checking
|
title: Compiling a Functional Language Using C++, Part 3 - Type Checking
|
||||||
date: 2019-08-06T14:26:38-07:00
|
date: 2019-08-06T14:26:38-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we allow our compiler to throw away invalid programs, detected using a monomorphic typechecking algorithm."
|
||||||
---
|
---
|
||||||
I think tokenizing and parsing are boring. The thing is, looking at syntax
|
I think tokenizing and parsing are boring. The thing is, looking at syntax
|
||||||
is a pretty shallow measure of how interesting a language is. It's like
|
is a pretty shallow measure of how interesting a language is. It's like
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 4 - Small Improvements
|
title: Compiling a Functional Language Using C++, Part 4 - Small Improvements
|
||||||
date: 2019-08-06T14:26:38-07:00
|
date: 2019-08-06T14:26:38-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we take a little break from pushing our compiler forward to make some improvements to the code we've written so far."
|
||||||
---
|
---
|
||||||
We've done quite a big push in the previous post. We defined
|
We've done quite a big push in the previous post. We defined
|
||||||
type rules for our language, implemented unification,
|
type rules for our language, implemented unification,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 5 - Execution
|
title: Compiling a Functional Language Using C++, Part 5 - Execution
|
||||||
date: 2019-08-06T14:26:38-07:00
|
date: 2019-08-06T14:26:38-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we define the rules for a G-machine, the abstract machine that we will target with our compiler."
|
||||||
---
|
---
|
||||||
{{< gmachine_css >}}
|
{{< gmachine_css >}}
|
||||||
We now have trees representing valid programs in our language,
|
We now have trees representing valid programs in our language,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 6 - Compilation
|
title: Compiling a Functional Language Using C++, Part 6 - Compilation
|
||||||
date: 2019-08-06T14:26:38-07:00
|
date: 2019-08-06T14:26:38-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we enable our compiler to convert programs written in our functional language to G-machine instructions."
|
||||||
---
|
---
|
||||||
In the previous post, we defined a machine for graph reduction,
|
In the previous post, we defined a machine for graph reduction,
|
||||||
called a G-machine. However, this machine is still not particularly
|
called a G-machine. However, this machine is still not particularly
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 7 - Runtime
|
title: Compiling a Functional Language Using C++, Part 7 - Runtime
|
||||||
date: 2019-08-06T14:26:38-07:00
|
date: 2019-08-06T14:26:38-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we implement the supporting code that will be shared between all executables our compiler will create."
|
||||||
---
|
---
|
||||||
Wikipedia has the following definition for a __runtime__:
|
Wikipedia has the following definition for a __runtime__:
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 8 - LLVM
|
title: Compiling a Functional Language Using C++, Part 8 - LLVM
|
||||||
date: 2019-10-30T22:16:22-07:00
|
date: 2019-10-30T22:16:22-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we enable our compiler to convert G-machine instructions to LLVM IR, which finally allows us to generate working executables."
|
||||||
---
|
---
|
||||||
|
|
||||||
We don't want a compiler that can only generate code for a single
|
We don't want a compiler that can only generate code for a single
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 9 - Garbage Collection
|
title: Compiling a Functional Language Using C++, Part 9 - Garbage Collection
|
||||||
date: 2020-02-10T19:22:41-08:00
|
date: 2020-02-10T19:22:41-08:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we implement a garbage collector that frees memory no longer used by the executables our compiler creates."
|
||||||
---
|
---
|
||||||
|
|
||||||
> "When will you learn? When will you learn that __your actions have consequences?__"
|
> "When will you learn? When will you learn that __your actions have consequences?__"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 10 - Polymorphism
|
title: Compiling a Functional Language Using C++, Part 10 - Polymorphism
|
||||||
date: 2020-03-25T17:14:20-07:00
|
date: 2020-03-25T17:14:20-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we extend our compiler's typechecking algorithm to implement the Hindley-Milner type system, allowing for polymorphic functions."
|
||||||
---
|
---
|
||||||
|
|
||||||
[In part 8]({{< relref "08_compiler_llvm.md" >}}), we wrote some pretty interesting programs in our little language.
|
[In part 8]({{< relref "08_compiler_llvm.md" >}}), we wrote some pretty interesting programs in our little language.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 11 - Polymorphic Data Types
|
title: Compiling a Functional Language Using C++, Part 11 - Polymorphic Data Types
|
||||||
date: 2020-04-14T19:05:42-07:00
|
date: 2020-04-14T19:05:42-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we enable our compiler to understand polymorphic data types."
|
||||||
---
|
---
|
||||||
[In part 10]({{< relref "10_compiler_polymorphism.md" >}}), we managed to get our
|
[In part 10]({{< relref "10_compiler_polymorphism.md" >}}), we managed to get our
|
||||||
compiler to accept functions that were polymorphically typed. However, a piece
|
compiler to accept functions that were polymorphically typed. However, a piece
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
title: Compiling a Functional Language Using C++, Part 12 - Let/In and Lambdas
|
title: Compiling a Functional Language Using C++, Part 12 - Let/In and Lambdas
|
||||||
date: 2020-04-20T20:15:16-07:00
|
date: 2020-04-20T20:15:16-07:00
|
||||||
tags: ["C and C++", "Functional Languages", "Compilers"]
|
tags: ["C and C++", "Functional Languages", "Compilers"]
|
||||||
|
description: "In this post, we extend our language with let/in expressions and lambda functions."
|
||||||
draft: true
|
draft: true
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#1dc868" />
|
<meta name="theme-color" content="#1dc868">
|
||||||
|
{{ if .Description }}
|
||||||
|
<meta name="description" content="{{ .Description }}">
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inconsolata&family=Raleway&family=Lora&display=swap" media="screen">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inconsolata&family=Raleway&family=Lora&display=swap" media="screen">
|
||||||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" media="screen">
|
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" media="screen">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user