Giter VIP home page Giter VIP logo

cool-compiler's Introduction

Stanford CS1/CS143 Compilers Course Project - Cool

Stanford online course of CS143 Compilers: Link

Introduction

The full name of "Cool" is "The Classroom Object-Oriented Language". It is a small language designed for use in an undergraduate compiler course project by Stanford University. Cool has many of the features of modern programming languages, including objects, automatic memory management, and strong static typing. It generates code for a MIPS simulator.

More info:

Installing & Setup

There are two ways to configure the environment. One is to use the provided pre-configured Linux system via VirtualBox VM, the other is to install directly on your own installation of Linux (Debian-based system required). I prefer the second choice because the download is only 5.5MB, otherwise you would need to download the whole VM image which is over 700MB.

Assignments

  • PA2 - Lexical Analysis: Done
  • PA3 - Parsing: Done
  • PA4 - Semantic Analysis: Done
  • PA5 - Code Generation: Skipped

Troubleshooting

spim: No such file or directory

This is because you are running a 64-bit linux, which does not have the 32-bit libc installed.

For Ubuntu 16.04, you can fix it with:

sudo apt-get install libc6-i386

libfl.so: undefined reference to 'yylex'

  • Set the line %option noyywrap in the cool.flex file
  • Remove the -lfl part of the LIB= line in the makefile

cool-compiler's People

Contributors

afterthat97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cool-compiler's Issues

Cycle checking issue in check_inheritance function in PA4

您好,感谢您的代码分享!在check_inheritance函数中似乎有一个问题,判断是否成环不能仅判断一个节点是否最终会返回到自己。比如,D : A, A : B, B : C, C : A的情况,如果从D开始判断的话会死循环。

static void check_inheritance() {
for (ClassTable::iterator it = classTable.begin(); it != classTable.end(); it++)
if (it->first != Object && classTable.find(it->second->getParentName()) == classTable.end()) {
curr_class = it->second;
semant_error(curr_class) << "Class " << it->second->getName() << " inherits from an undefined class " << it->second->getParentName() << ".\n";
}
for (ClassTable::iterator it = classTable.begin(); it != classTable.end(); it++) {
if (it->first == Object) continue;
curr_class = it->second;
Symbol cname = it->first;
Symbol pname = it->second->getParentName();
while (pname != Object) {
if (pname == cname) {
semant_error(curr_class) << "Class " << curr_class->getName() << ", or an ancestor of " << curr_class->getName() << ", is involved in an inheritance cycle.\n";
break;
}
if (classTable.find(pname) == classTable.end())
break;
pname = classTable[pname]->getParentName();
}
}
}

In arm 64Ubuntu i am not able to run

I have made a VM in mac m1 but it is running arm64 ubuntu and on running any ./coolc 1.cl it is showing
./coolc: 33: exec: ./../bin/.i686/coolc: Exec format error

关于i686

你好,请问你是怎么在ubuntu上面运行i686的代码的呀,我这边一直报错

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.