Computer Science 164 - Spring 1997 - Graham - Midterm 1

Computer Science 164 - Spring 1997 - Graham - Midterm 1 -...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS164 Spring 1997 Midterm 1 CS164 Spring 1997 Midterm 1 Prof. S. L. Graham Problem 1 (10 points) Following are some small Flex examples For each one, state what Flex will print for the given input. a. %% ab { printf("1"); } ab* { printf("2"); } %% input: abbbab b. %x STATE2 %% ab { printf("x"); } ab* { printf("y"); } a { BEGIN(STATE2); count=1 } <STATE2>{ a { count++; printf("%d",count); } b { count--; if(count==0) { BEGIN(INITIAL); }; } } %% input: aababbababb c. %% a { printf("a"); } a+ { printf("b"); } a*b { printf("c"); } b* { printf("d"); } . { printf("%s", yytext); } %% input: a+aa+b+ab+abb+abbbb file:///C|/Documents%20and%20Settings/Jason%20Raft. ..20Spring%201997%20-%20Graham%20-%20Midterm%201.htm (1 of 5)1/27/2007 5:34:25 PM
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS164 Spring 1997 Midterm 1 Problem 2 (20 points) Indicate whether each statement is true or false by circling either T or F. For each statement, give a brief explanation (one sentence or an example)justifying your answer. T F Every language can be specified by a context-free grammar. T F If a grammar G is the smallest grammar that generates a given language, then G is reduced. T F Some reduce/reduce conflicts can be eliminated by introduction of Bison-style precedence and/or associativity rules. T F Regular expressions can derive the empty string. T
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/17/2009 for the course CS 164 taught by Professor Staff during the Spring '08 term at University of California, Berkeley.

Page1 / 5

Computer Science 164 - Spring 1997 - Graham - Midterm 1 -...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online