Quiz 4, Compiler Construction, 1.6.


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

Name____________________________________________ Number___________________ 1) Fill up the picture of tasks creating a scanner using LEX(5p) 2) lexemes can be defined in a simple way using X regular expression O BNF O context free grammars 3) LEX input consists of X declarations of pattern 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 Lex Source program Lex Compil er C Compil er a.out input stream Sequence of




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 shown in the right to recognize LE, NE, LT, EQ, GE, GT (7 P) 11) "= =" and "!=" O are not at the same precedence level X are on a lower precedence level than "%" O are on a higher precedence level than "%" 12) Coercions are done O during calculation of L Values O by the optimizer X during assignment of variables 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 0 < 1 = 2

return ( relop, LE) return ( relop, NE) * return ( relop, LT)

> other = 5 > 6 other =



return ( relop, EQ)

7 *

return ( relop, GE) return ( relop, GT)


Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.