Skip to content

Course Exercise of "Compiler Design" in the summer term of 2012

Notifications You must be signed in to change notification settings

bountin/uebersetzerbau

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a repository for my university lecture 'Uebersetzerbau'. It's about how compilers work and for practice we have to implement our own language with our own compiler. The gesamt part of this repo is the completed project but sadly it has some bugs which I was not able to fix in time.

The university page is at http://www.complang.tuwien.ac.at/andi/185A48

asma is a simple assembler script which implements the following C function:

void asma_ref(unsigned long x[])
{
  unsigned long carry;
  carry = x[1] << 63;
  x[1] = x[1] >> 1;
  x[0] = (x[0] >> 1)|carry;
}

asmb also is a assembler script but it uses a loop oh yeah:

void asmb_ref(unsigned long x[], size_t n)
{
  unsigned long carry=0;
  unsigned long next_carry;
  long i;
  for (i=n-1; i>=0; i--) {
    next_carry = x[i] <<63;
    x[i] = (x[i] >> 1) | carry;
    carry = next_carry;
  }
}

scanner is a lexer for a simple exercise language. It is able to parse some keywords, decimal and hexadecimal numbers and identifiers. For each found token it's printing what it has found. More details are available in German on the practice page: http://www.complang.tuwien.ac.at/ubvl/skriptum/skriptum12.html#x1-180007.3

parser adds a semantical check to the lexical that was implemented before (scanner). It is expecting a single function definition with n parameters and terminated by the keyword end. Its body can contain several operations as well as gotos or ifs. The complete grammar as EBNF is available at http://www.complang.tuwien.ac.at/ubvl/skriptum/skriptum12.html#x1-220007.4

ag implements an attributed grammar which generates symbol tables for variables, labels and parameters.

codea implements actual code generation for a subset of the features. All statements are not implemented except for the return statement which is required for testing ;).

codeb implements missing statements except the function call.

gesamt adds the function call and all stuff which must be kept in mind for it.

About

Course Exercise of "Compiler Design" in the summer term of 2012

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published