Skip to content

Jeff-Rowell/compilers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 

Repository files navigation

CS143 - Compilers

This repo contains my work and notes as I progress through Stanford's CS 143 - Compilers

Resources

  1. Cool Programming Language Reference Manual
  2. Cool Programming Language Support Code
  3. Lexical Analysis with Flex Manual
  4. Bison Manual
  5. Cool Programming Language Runtime
  6. SPIM Manual

Resource Installation & Environment Set-Up

I set up the environment on Linux using the steps below.

Install packages (If you only intend to use the C++ version, you don't need the jdk):

sudo apt-get install flex-old bison build-essential csh openjdk-17-jdk libxaw7-dev wget

Make the /usr/class directory:

sudo mkdir -p /usr/class/cs143/cool

Make the directory owned by you:

sudo chown $USER /usr/class/cs143/cool

Go to /usr/class and download the tarball:

cd /usr/class/cs143/cool
wget "https://courses.edx.org/asset-v1:StanfordOnline+SOE.YCSCS1+1T2020+type@[email protected]" -O student-dist.tar.gz

Untar:

tar -xf student-dist.tar.gz

Add a symlink to your home directory:

ln -s /usr/class/cs143/cool ~/cool

Add the bin directory to your .profile:

vi ~/.profile

Add the following line inside:

export PATH=/usr/class/cs143/cool/bin:$PATH

Source the file for changes to take effect:

source ~/.profile

Confirm that coolc is available now:

which coolc

Compile one of the example programs to test everything works:

cd /usr/class/cs143/cool/examples/
coolc cool.cl

Test running the compiled file with spim:

spim /usr/class/cs143/cool/examples/cool.s

If you get the following error:

line82: /usr/class/cs143/cool/bin/../bin/.i686/spim: No such file or directory

To fix this, we need to add the i386 architecture to run 32-bit executable files:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install gcc-multilib

Lectures

  1. Course Overview
  2. Cool: The Course Project
  3. Lexical Analysis
  4. Implementation of Lexical Analysis
  5. Introduction to Parsing
  6. Syntax-Directed Translation
  7. Top-Down Parsing
  8. Bottom-Up Parsing
  9. Semantic Analysis & Type Checking I
  10. Type Checking II
  11. Run-time Environments
  12. Code Generation
  13. Operational Semantics
  14. Intermediate Code & Local Optimization
  15. Global Optimization
  16. Register Allocation
  17. Automatic Memory Management
  18. Fast Runtime Compilation

Assignments

Programming Assignments

  1. Programming Assignment 1
  2. Programming Assignment 2
  3. Programming Assignment 3
  4. Programming Assignment 4
  5. Programming Assignment 5

Written Assignments

  1. Written Assignment 1 (LaTeX template/pdf)
  2. Written Assignment 2 (LaTeX template/pdf)
  3. Written Assignment 3 (LaTeX template/pdf)
  4. Written Assignment 4 (LaTeX template/pdf)

About

Stanford's CS143 Compiler Course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published