Presentation is loading. Please wait.

Presentation is loading. Please wait.

CISC 471 First Exam Review Game Questions. Overview 1 Draw the standard phases of a compiler for compiling a high level language to machine code, showing.

Similar presentations


Presentation on theme: "CISC 471 First Exam Review Game Questions. Overview 1 Draw the standard phases of a compiler for compiling a high level language to machine code, showing."— Presentation transcript:

1 CISC 471 First Exam Review Game Questions

2 Overview 1 Draw the standard phases of a compiler for compiling a high level language to machine code, showing the input and output forms for each phase.

3 Overview 2 State 2 advantages of using an interpreter instead of a compiler for implementing a language. State 2 advantages of using a compiler instead of an interpreter for implementing a language.

4 Overview 3 What are the roles of a: – Preprocessor – Assembler – Linker ?

5 Lexical Analysis 1 Demonstrate that you understand the difference between a token and a lexeme, through an example. Give an example of a language feature that makes scanning nontrivial.

6 Lexical Analysis 2 Give a regular expression that represents exactly the set of decimal numbers that contain at least one digit representing the whole number part, no sign, and if there is a decimal point, then at least one digit to the right of the decimal point. Also, 0. is illegal.

7 Lexical Analysis 3 Show the partitioning of the input string below given the following flex spec rule set: a*b bba+c aaba b | c Input: abaabbaabaaaabbbccaabbaaba

8 CFG 1 Show an equivalent Context free grammar for the regular expression: S -> (A | B)* BA|C A -> DA | w B -> w | x C -> CD | D D -> y

9 CFG 2 Show that E -> E + E | w is an ambiguous grammar. How would you rewrite the grammar to remove the ambiguity if + is left associative?

10 CFG 3 Show a leftmost derivation for the string (a,a) with the grammar: S-> (L) | a L-> L,S | S Explain the difference between an abstract syntax tree and a concrete syntax tree and justify why most compilers use abstract syntax trees.

11 Parsing 1 Explain and show an example of two properties of grammars that cause problems for topdown parsers, and require rewrites or special rules in the yacc file. Name the two different ways that are used to build top-down parsers.

12 Parsing 2 Write the recursive descent routine for the following nonterminal: D -> D, id | id | ε

13 Parsing 3 Explain the actions of an LR bottom up parser for: Shift Reduce Explain how the parser determines the state to put back on top of the stack after a Reduce.

14 Semantic Analysis 1 Give 3 different examples of errors that are caught by semantic analysis and cannot be caught by the first two phases. Explain the difference between inherited and synthesized attributes.

15 Semantic Analysis 2 Show the attributed tree for -101 with the rules:

16 Semantic Analysis 3 Why is it a nice property to have an attribute grammar that has only synthesized attributes? Why is a circular attribute grammar a bad property?


Download ppt "CISC 471 First Exam Review Game Questions. Overview 1 Draw the standard phases of a compiler for compiling a high level language to machine code, showing."

Similar presentations


Ads by Google