Title image Spring 2018


Current HW

HW 1: Hello World with Numbers

Due Friday 9 February 2018

Pick a language you do not know and write a program in that language that computes the average of three numbers and prints out the result. Run your code and make sure it works.

  • How simple is the code?
  • How readable is the code?
  • How much time did it take to get it running?
  • Is it compiled or interpreted?

Send the professor an email with your code (not as an attachment) and your short answers to the above questions.

HW 2: Grammars and Regular Expressions

Due Friday 23 February 2018

  1. Define a BNF grammar with the alphabet {a, b} that defines strings that start with an a, have one or more b symbols and end with an a.
  2. Define a regular expression for the prior grammar. Note that you can test regular expressions using the terminal command egrep. You canff use the following ABA test file. There are three lines that match the proper specification.
  3. Demonstrate that addition in C is not associative. The following two statements should print significantly different results. You need to figure out appropriate types and values for a, b, and c. Can you do the same with multiplication?
    printf( "%f\n", (a + b) + c );
    printf( "%f\n", a + (b + c) );
  4. Using the Clite syntax, generate both the concrete parse trees and abstract parse trees for the following statements. Feel free to do the concrete tree automatically using flex.

    • a = b * ( 5 + c );
    • if( a == 0 || b > 0 ) 
        b = 0;
        b = a;