Skip to content

Commit

Permalink
First version of CC VT17
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgerdes committed Mar 17, 2017
1 parent 97830f7 commit e821a6c
Show file tree
Hide file tree
Showing 28 changed files with 2,185 additions and 169 deletions.
11 changes: 8 additions & 3 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Global styling */
body {
font-family: sans-serif;
font-family: 'Fira Sans', sans-serif;
}

h1 {
Expand Down Expand Up @@ -30,6 +30,11 @@ li {
padding: 0.5em;
}

/* logo */
#logo {
margin-top: 40px;
width: 140px;
}

/* The left sidebar and menu */
#sidebar {
Expand Down Expand Up @@ -107,15 +112,15 @@ li {
#sidebarheading {
list-style: none;
text-align: left;
font-family: verdana;
font-family: 'Fira Sans';
text-align: center;
margin-left: -4em;
}

#menu {
margin-top: 2em;
margin-bottom: 2em;
font-family: verdana;
font-family: 'Fira Sans';
list-style: none;
}

Expand Down
130 changes: 130 additions & 0 deletions files/Javalette.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
-- programs ------------------------------------------------

entrypoints Prog ;

Program. Prog ::= [TopDef] ;

FnDef. TopDef ::= Type Ident "(" [Arg] ")" Blk ;

separator nonempty TopDef "" ;

Argument. Arg ::= Type Ident;

separator Arg "," ;

-- statements ----------------------------------------------

Block. Blk ::= "{" [Stmt] "}" ;

separator Stmt "" ;

Empty. Stmt ::= ";" ;

BStmt. Stmt ::= Blk ;

Decl. Stmt ::= Type [Item] ";" ;

NoInit. Item ::= Ident ;

Init. Item ::= Ident "=" Expr ;

separator nonempty Item "," ;

Ass. Stmt ::= Ident "=" Expr ";" ;

Incr. Stmt ::= Ident "++" ";" ;

Decr. Stmt ::= Ident "--" ";" ;

Ret. Stmt ::= "return" Expr ";" ;

VRet. Stmt ::= "return" ";" ;

Cond. Stmt ::= "if" "(" Expr ")" Stmt ;

CondElse. Stmt ::= "if" "(" Expr ")" Stmt "else" Stmt ;

While. Stmt ::= "while" "(" Expr ")" Stmt ;

SExp. Stmt ::= Expr ";" ;

-- Types ---------------------------------------------------

Int. Type ::= "int" ;

Doub. Type ::= "double" ;

Bool. Type ::= "boolean" ;

Void. Type ::= "void" ;

internal Fun. Type ::= Type "(" [Type] ")" ;

separator Type "," ;

-- Expressions ---------------------------------------------

EVar. Expr6 ::= Ident ;

ELitInt. Expr6 ::= Integer ;

ELitDoub. Expr6 ::= Double;

ELitTrue. Expr6 ::= "true" ;

ELitFalse. Expr6 ::= "false" ;

EApp. Expr6 ::= Ident "(" [Expr] ")" ;

EString. Expr6 ::= String ;

Neg. Expr5 ::= "-" Expr6 ;

Not. Expr5 ::= "!" Expr6 ;

EMul. Expr4 ::= Expr4 MulOp Expr5 ;

EAdd. Expr3 ::= Expr3 AddOp Expr4 ;

ERel. Expr2 ::= Expr2 RelOp Expr3 ;

EAnd. Expr1 ::= Expr2 "&&" Expr1 ;

EOr. Expr ::= Expr1 "||" Expr ;

coercions Expr 6 ;

separator Expr "," ;

-- operators -----------------------------------------------

Plus. AddOp ::= "+" ;

Minus. AddOp ::= "-" ;

Times. MulOp ::= "*" ;

Div. MulOp ::= "/" ;

Mod. MulOp ::= "%" ;

LTH. RelOp ::= "<" ;

LE. RelOp ::= "<=" ;

GTH. RelOp ::= ">" ;

GE. RelOp ::= ">=" ;

EQU. RelOp ::= "==" ;

NE. RelOp ::= "!=" ;

-- comments ------------------------------------------------

comment "#" ;

comment "//" ;

comment "/*" "*/" ;

75 changes: 75 additions & 0 deletions files/evenodd.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@evenstring = global [7 x i8] c"Even!\0A\00"
@oddstring = global [6 x i8] c"Odd!\0A\00"

declare void @printString(i8*)

define i1 @even(i32 %n) {
entry:
%n.addr = alloca i32
store i32 %n, i32* %n.addr
%z.addr = alloca i32
store i32 0, i32* %z.addr
%0 = load i32* %z.addr
%t = load i32* %n.addr
%cmp = icmp eq i32 %0, %t
br i1 %cmp, label %if.then, label %if.else

if.then:
ret i1 1

if.else:
%1 = load i32* %n.addr
%sub = sub nsw i32 %1, 1
%call = call i1 @odd(i32 %sub)
ret i1 %call

if.end:
unreachable
}

define i1 @odd(i32 %n) {
entry:
%n.addr = alloca i32
store i32 %n, i32* %n.addr
%z.addr = alloca i32
store i32 0, i32* %z.addr
%0 = load i32* %z.addr
%t = load i32* %n.addr
%cmp = icmp eq i32 %0, %t
br i1 %cmp, label %if.then, label %if.else

if.then:
ret i1 0

if.else:
%1 = load i32* %n.addr
%sub = sub nsw i32 %1, 1
%call = call i1 @even(i32 %sub)
ret i1 %call

if.end:
unreachable
}

define i32 @main() {
entry:
%n = alloca i32
store i32 20, i32* %n
%t = load i32* %n
%b = call i1 @even(i32 %t)
br i1 %b, label %if.then, label %if.else

if.then:
%strp = getelementptr [7 x i8]* @evenstring, i32 0, i32 0
call void @printString(i8* %strp)
br label %if.end

if.else:
%strp1 = getelementptr [6 x i8]* @oddstring, i32 0, i32 0
call void @printString(i8* %strp1)
br label %if.end

if.end:
ret i32 0

}
Binary file added files/guest_lecture_myreen-6up.pdf
Binary file not shown.
Binary file added files/lect01-6up.pdf
Binary file not shown.
Binary file added files/lect02-6up.pdf
Binary file not shown.
Binary file added files/lect03-6up.pdf
Binary file not shown.
Binary file added files/lect04-6up.pdf
Binary file not shown.
Binary file added files/lect05-6up.pdf
Binary file not shown.
Binary file added files/lect06-6up.pdf
Binary file not shown.
Binary file added files/lect07-6up.pdf
Binary file not shown.
Binary file added files/lect08-6up.pdf
Binary file not shown.
Binary file added files/lect09-6up.pdf
Binary file not shown.
42 changes: 42 additions & 0 deletions files/runtime.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@dnl = internal constant [4 x i8] c"%d\0A\00"
@fnl = internal constant [6 x i8] c"%.1f\0A\00"
@d = internal constant [3 x i8] c"%d\00"
@lf = internal constant [4 x i8] c"%lf\00"

declare i32 @printf(i8*, ...)
declare i32 @scanf(i8*, ...)
declare i32 @puts(i8*)

define void @printInt(i32 %x) {
entry: %t0 = getelementptr [4 x i8]* @dnl, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %t0, i32 %x)
ret void
}

define void @printDouble(double %x) {
entry: %t0 = getelementptr [6 x i8]* @fnl, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %t0, double %x)
ret void
}

define void @printString(i8* %s) {
entry: call i32 @puts(i8* %s)
ret void
}

define i32 @readInt() {
entry: %res = alloca i32
%t1 = getelementptr [3 x i8]* @d, i32 0, i32 0
call i32 (i8*, ...)* @scanf(i8* %t1, i32* %res)
%t2 = load i32* %res
ret i32 %t2
}

define double @readDouble() {
entry: %res = alloca double
%t1 = getelementptr [4 x i8]* @lf, i32 0, i32 0
call i32 (i8*, ...)* @scanf(i8* %t1, double* %res)
%t2 = load double* %res
ret double %t2
}

Binary file added files/state.tar.gz
Binary file not shown.
Binary file added files/tester.tar.gz
Binary file not shown.
Binary file modified images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 33 additions & 23 deletions pages/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@ menuorder: 1
About the Course
================


<a name="course_syllabus"></a>

Course Syllabus
---------------

The course has a practical goal: learning to create a course website
using CCWF.
The course has a practical goal: the participants will build a compiler for a
small programming language called Javalette. Javalette is an imperative
language, a subset of C and of Java.

The complete project will include one front end (lexer, parser and type-checker)
and at least one backend, generating LLVM code. Optional extensions include
source language extensions and a native x86 backend.

The official syllabus can be found
[here](\$syllabus\$).
To reach this goal, quite a few theories and techniques are necessary: grammars,
lexers, parsers, abstract syntax, type systems, syntax-directed translation,
code analysis, register allocation, optimization, etc. Many of these techniques
are supported by tools used in all state-of-the-art compiler construction.
Mastering these techniques will help the participants to achieve the practical
goal efficiently and reliably. The mastery of them is also useful for many
other programming tasks in industry and in academia.

The official syllabus can be found [here]($syllabus$).


<a name="teachers"></a>
Expand Down Expand Up @@ -81,40 +92,39 @@ Assistants
</ul>


General questions concerning the course, including examination issues
(deadline extensions, etc) should be directed to \$teacher\$.

The assistants are responsible for grading and supervising labs.
General questions concerning the course, including examination issues (deadline
extensions, etc) should be directed to \$teacher\$. Supervision for the project
is also offered by \$teacher\$ during office hours. The teachers and assistants are
responsible for grading and supervising labs.


<a name="submissions"></a>

Submitting assignments
----------------------

In this course we use the web-based Fire system for lab submission.
Any web browser should be usable for submissions.
In this course we use the web-based [Fire](\$submissions\$) system for lab
submission. Any web browser should be usable for submissions.

### Registration

When you first come to Fire, you must register in the system. Follow the
instructions on screen. Your login id in the system is your email address, but
you must also give your name and personnummer, so that we can report your
result when you have finished all your assignments.
Note that an email is sent to you during registration; registration is
completed by following a link included in that mail.
This email address is also used to send you an email when your submissions
have been graded.

After registration, you will come to your Fire home page, where you submit
assignments. On the top of this page you are asked to join a group.
Even if you do your project alone you must create a (one-person) group.
you must also give your name and personnummer, so that we can report your result
when you have finished all your assignments. Note that an email is sent to you
during registration; registration is completed by following a link included in
that mail. This email address is also used to send you an email when your
submissions have been graded.

After registration, you will come to your [Fire](\$submissions\$) home page,
where you submit assignments. On the top of this page you are asked to join a
group. Even if you do your project alone you must create a (one-person) group.
Only groups can submit.

### Submitting

The assignments are linked from your Fire home page.
To submit an assignment, click on the link for that assignment and follow
The assignments are linked from your [Fire](\$submissions\$) home page. To
submit an assignment, click on the link for that assignment and follow
instructions. Two things should be noted:

* Your solution will include several files, in different directories.
Expand Down
Loading

0 comments on commit e821a6c

Please sign in to comment.