You are here:   ArielOrtiz.com > Compiler Design > Project: Fortran 77 Compiler

Project: Fortran 77 Compiler

Generalities

This project must be developed in teams of up to three members. Using C#, you must implement the different compiler phases for a subset of Fortran 77, exactly as described in the provided “Fortran 77 Tutorial”. Each phase will be evaluated using the following grading criteria:

Concept %
Phase implementation 80%
Version control usage 20%

Version Control Usage

Each team member must create a Bitbucket account. The team leader must create a new repository for the project with these characteristics:

Afterwards, the team leader must send invitations to the other team members (and also to ariel.ortiz@itesm.mx) so that they can all join the repo. Make sure that all members have write privileges.

Tips

Important

All team members are expected to clone the Git repository and to commit and push frequently all code contributions to the project.

Fortran 77 Source Code Examples

Source file Description Date added
hello.f The world famous "Hello World!" program. 31-Aug-2016
largest.f Find the largest of several positive numbers contained in an array. 31-Aug-2016
fizzbuzz.f Solves the classical fizzbuzz programming puzzle. 31-Aug-2016
pi.f Computes pi through numerical integration. 31-Aug-2016
matrix.f Simple big matrix manipulation example. 31-Aug-2016
factorials.f Computes and prints the factorials of numbers from 0 to 10 using iteration and recursion. 31-Aug-2016
stats.f Computes the average and standard deviation of 200 positive integer numbers. 31-Aug-2016
cramer.f Uses Cramer's rule to solve a system of 3 linear equations with 3 unknows. 31-Aug-2016
callex.f Demonstrates the call-by-reference mechanism. 26-Oct-2016
taylor.f Computes Taylor polynomials. 02-Nov-2016
intrinsics.f Using mathematical intrinsic functions. 16-Nov-2016

Semantic Checks

  1. The names of all the programming units (program, function, or subroutine) must be unique.
  2. All labels must appear in columns 1 to 5.
  3. Labels must be unique inside each programming unit (program, function, or subroutine).
  4. Continuation characters (+ and &) must appear only in column 6.
  5. All statements must start in column 7.
  6. All variables must be declared before they are used. Each variable must be declared exactly once in a programming unit (program, function, or subroutine)
  7. The name in a parameter statement must have been previously defined and its type must be compatible with the value being assigned to.
  8. The variable name inside a parameter statement cannot be used in the left-hand side of an assignment statement because it represents a constant.
  9. A defined name can appear in at most one parameter statement.
  10. The parameter statement(s) must come before the first executable statement.
  11. The following arithmetic operators must take two numeric (integer or real) operands: +, -, *, /, **. If both operands are integers, the result must be an integer. If at least one operand is real, the result must be real.
  12. The unary - operator must take a numeric (integer or real) operand. If the operand is an integer, the result must be an integer. If the operand is a real number, the result must also be real.
  13. The left hand side of an assignment must be type compatible with its right hand side. In general, this means that you can only assign a value of type T to a variable that was declared of the same type T. The only exception to this rule is that you may assign an integer value to a real variable, but not the other way around.
  14. The following relational operators must take two numeric (integer or real) operands: .lt., .le., .gt., .ge., .eq., and .ne. . The result must always be a logical (boolean) value.
  15. The following logical operators must take two logical (boolean) operands: .and. and .or. . The .not. operator must only takes one logical operand. These three operators must return a logical (boolean) value.
  16. In an if statement (and also in an if else statement), its expression must evaluate to a logical (boolean) value.
  17. In a goto statement, the target label must be inside the same programming unit (program, function, or subroutine).
  18. In a do statement, the target label must be inside the same programming unit (program, function, or subroutine). The loop control variable must be previously declared as integer. The initial and terminating values must be of type integer. The optional increment must also be of type integer.
  19. Nested do statements must have their labels correctly placed.

    For example, this is OK:

          do 10 i = 1, 5
              do 20 j = 1, 3
                  write(*, *) i, j
    20        continue
    10    continue
    

    But this is not:

          do 10 i = 1, 5
              do 20 j = 1, 3
                  write(*, *) i, j
    10        continue
    20    continue
    
  20. The size of each dimension of an array must be specified during its declaration. The size must be a positive integer constant or a name defined using a parameter statement. Arrays can only have one or two dimensions.
  21. Individual array elements must be accessed (for reading or writing) using the correct number of dimensions. Array indexes must be integer expressions.
  22. The following instrinsic functions must take an integer or real as its only argument and return a real: abs, sqrt, sin, cos, tan, atan, exp, and log. The following instrinsic functions must take two numeric arguments (whatever combination of real or integer) and return a real: min and max.
  23. When declaring a function or subroutine, all their parameters must be properly declared.
  24. The value returned by a function has to be type compatible with the declared function type.
  25. When calling a function, its name should be previously declared as if it was a variable. The number and types of the arguments must match those of the function declaration.
  26. The call statement can only be used for declared subroutines. The number and types of the arguments must match those of the subroutine declaration.
  27. The common statement must appear together with the variable declarations, before the executable statements. Different common blocks must have different names (just like variables). A variable cannot belong to more than one common block. The variables in a common block do not need to have the same names each place they occur, but they must be listed in the same order and have the same type and size.
  28. The number and type of values used in a data statement must match the variables being initialized.

Due Dates

Phase Date Description Exemplar
1 07-Sep-2016 Lexical analysis. buttercup-0.1.tgz
2 12-Oct-2016 Syntactic analysis. buttercup-0.2.tgz
3 26-Oct-2016 AST construction. buttercup-0.3.tgz
4 09-Nov-2016 Semantic analysis. buttercup-0.4.tgz
5 25-Nov-2016 CIL code generation. buttercup-0.5.tgz

All your code should be in the Bitbucket repo, so nothing else needs to be delivered.