Skip to content

fade03/CS143-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro

There are two versions of assignments(Java or C++) for the CS143-Compiler course, this repo is my Java-version solution.

Platform: Ubuntu 18.04

Course resources:

  • This course is available in bilibili.

  • You can download the student-dist in edx.org.

PA

PA2J

This assignment is to write a lexical analyser for COOL, using jlex(Java).

By the way, the jlex framework is a bit outdated, you can install jflex to replace it:

> brew install jfelx
> apt-get install jfelx

Generate lexer:

> jflex --jlex cool.lex
> make lexer
> make dotest

To test if the lexer generated works, you can run diff.sh which compares the output of our own lexer and the standard lexer(./bin/lexer) with all cool files in ./examples as input:

> ./diff.sh

PA3J

The grammar of COOL language has been given in cool-manual.pdf, so all we need to focus on is precedence and error-handing. Besides, do not worry that our own parser and the standard parser output the different line number.

First of all, if you didn't use the virtual machine given by teacher, you should install the CUP in your own machine:

> apt-get install cup

Then modify the PA3J/Makefile and change the CUP path to your own path(if you don't know the path, you can run which cup):

## PA3J/Makefile

JAVAC := javac
# CUP := /usr/class/cs143/bin/java_cup
CUP := /usr/bin/cup

Generate Paser:

> make source
> make parser
> make dotest

About

My solution to the CS143 assignments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published