cisc 471 first exam review game questions. overview 1 draw the standard phases of a compiler for...
TRANSCRIPT
![Page 1: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/1.jpg)
CISC 471 First Exam Review Game Questions
![Page 2: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/2.jpg)
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.
![Page 3: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/3.jpg)
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.
![Page 4: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/4.jpg)
Overview 3
• What are the roles of a:– Preprocessor– Assembler– Linker ?
![Page 5: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/5.jpg)
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.
![Page 6: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/6.jpg)
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.
![Page 7: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/7.jpg)
Lexical Analysis 3
• Show the partitioning of the input string below given the following flex spec rule set:
a*bbba+caabab | cInput: abaabbaabaaaabbbccaabbaaba
![Page 8: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/8.jpg)
CFG 1
Show an equivalent Context free grammar for the regular expression:
S -> (A | B)* BA|CA -> DA | wB -> w | xC -> CD | DD -> y
![Page 9: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/9.jpg)
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?
![Page 10: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/10.jpg)
CFG 3
• Show a leftmost derivation for the string (a,a) with the grammar:
S-> (L) | aL-> 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.
![Page 11: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/11.jpg)
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.
![Page 12: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/12.jpg)
Parsing 2
Write the recursive descent routine for the following nonterminal:
D -> D , id | id | ε
![Page 13: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/13.jpg)
Parsing 3
Explain the actions of an LR bottom up parser for:
ShiftReduce
Explain how the parser determines the state to put back on top of the stack after a Reduce.
![Page 14: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/14.jpg)
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.
![Page 15: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/15.jpg)
Semantic Analysis 2
Show the attributed tree for -101 with the rules:
![Page 16: 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](https://reader036.vdocument.in/reader036/viewer/2022081809/56649ea05503460f94ba2cca/html5/thumbnails/16.jpg)
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?