CS200 Lab 6: Midterm Preparation

Overview

This lab helps you prepare for the Midterm
  1. Here are regular expressions used to define floating point (flopo) numbers:
    	  digs  = [0-9]+
    	  flopo = digs (. digs)? (E (+|-)? digs)?
    	
    where (...)? stands for “option”: zero or one of the regular expression inside the parentheses.

    For the following strings, determine whether they are valid flopos:

    	  .5
    	  123
    	  0.5
    	  123E4
    	  123.45E+67
    	
  2. Here is our grammar for arithmetic expressions:
    	   expr = term ( ("+" | "-") term )*
    	   term = factor ( ("*" | "/") factor )*
    	   factor = number | "(" expr ")"
    	   number = [0-9]+
    	
    For the following strings, determine whether they are valid exprs. If they are, show their derivation, either as a complete sequence of derivation steps, or as a parse tree.
    	  1 + -3
    	  2 * 3 - 4
    	  3 * 4 / 5
    	  (3 * 4) / 5
    	  1/2/3/4
    	  1-2/3-4
    	
  3. Go through your quizzes and homework. Study what you did right or wrong, and fix your mistakes. Be ready to ask questions about the topics to be studied.
  4. Study the slides up to and including Lecture 7.