Anda di halaman 1dari 2

Quiz 4, Compiler Construction, 1.6.

08 : check one ore more, O: check only one in choice

Name____________________________________________ Number___________________

1) Fill up the picture of tasks creating Lex


a scanner using LEX(5p) Lex Source Compil lex.yy.c
program
er
2) lexemes can be defined in a simple
way using
X regular expression C
O BNF lex.yy.c Compil a.out
O context free grammars er

3) LEX input consists of a.out


X declarations of pattern input stream Sequence of
X %% as a separator
 syntax rules
X declarations of variables
 $$ as a separator
 translation rules, pattern to token
X translation rules, pattern to action
X declaration of auxiliary functions

4) L+ is
X the Kleene closure without L0
O a variable named L which is added to somewhat
O a set with 0 ore more repetitions of L

5) the regexpr matching a float number is


X {digit}+(\.{digit}+)?(E[+-]?{digit})?
O (digit)+(\.(digit)+)?(E[+-]?(digit))?
O {digit}?(E[+-]?{digit})?

6) How is usually the scope of a variable stored?


O using an attribute describing the scope
X chaining symbol tables
O by renaming variables (appending 1, 1.1, 1.1.1…)

7) A while loop during syntax tree construction is stored as


X a special operator object with two parameters
O a special while object without any parameter
O an object with tree parts

8) An L value is an
O index
O value
X address

9) The left side of the assignment "a[i+2]= j*2" contains


O an L value
O an R value
X an L value and an R value
Name____________________________________________ Number___________________

10) Fill up the blanks in START < =


the transition diagram 0 1 2 return (
shown in the right to relop, LE)
recognize LE, NE, LT, EQ, GE, GT >
(7 P) 3 return (
relop, NE)
11) "= =" and "!=" other *
O are not at the same precedence level 4 return ( relop,
X are on a lower precedence level than =
LT)
"%"
O are on a higher precedence level than 5 return ( relop, EQ)
"%" >
=
12) Coercions are done 6 7 return (
O during calculation of L Values relop, GE)
O by the optimizer
X during assignment of variables other *
8 return (
relop, GT)
13) overloading might not work adding an
X string to an integer
O constant to an int
O int to an float

14) if the input does not match any allowed pattern, the scanner
O replaces it by the corresponding input
O stops
X remove successive input chars until it matches something
O Microsoft scanner always finds allowed pattern as it is ahead in technology

15) Buffer pairs are mostly used


X with a "lexemBegin" and a "forward" pointer
X to optimize read operations
X to allow look ahead
X to allow track back
X to have the older input still in place for processing

16) The attribute of a number token contains


O its type
X its value
O its variable

17) LL1 languages


X are good for top down parsing
O needs more than one token look ahead
O work good with left recursion

18) LR1 languages


X cover the largest class of languages
O are not used in practice
O have performance problems

Anda mungkin juga menyukai