Quiz3-result

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Quiz3-result as PDF for free.

More details

  • Words: 548
  • Pages: 2
Quiz 3, Compiler Construction, 18.5.08 : check one ore more, O: check only one in choice Name____________________________________________ Number___________________ 1) Draw the big picture from source program to executable program loaded in memory (compiler, asm, other). Name steps and intermediate results. Fill up the graphic at the right side. (5p) 2) White space is: O not needed during programming X tabs O deleted by the preprocessor

source-program

Look at the slides

3) if a parser gets white space O it get confused X it works with it as defined in the grammar O it ignores it 4) the scanner has to count cr/nl O so he is able to report errors X to report line numbers during later error detction O the scanner does not need to count lines as he deletes cr/nl 5) the parser has to count cr/nl O for reporting errors O to indicate line numbers during error reporting X parser does not need to count lines 6) the scanner needs to look ahead X to identify "=>" X to identifiy variable names  to distinguish between > and <  the scanner does not need to look ahead, only the parser do 7) scanner input buffer is used X for efficiency reasons  for looking ahead  for removing chars from the input  for counting the input lines  for queuing input from preprocessor 8) the scanner is required X to simplify the parser X to tread a constant number string as one token  to minimize the input 9) a reserved word in the java language is X if  old  function X while X do  time

target machine code in loded in memory

Name____________________________________________ Number___________________ 10) 31 + 28 + 59 is converted to O 8 token X 5 token O 12 token O 1 token 11) The string table O holds only variable names O holds only reserved words O is the same as the symbol table X hides string operations from other parts of the compiler 12) is a O reserved word X a token O variable name 13) The scanner treads reserved words as O "reserved word" token O as regular "id" token X as predefined "id" token 14) O is a token without attribute X is a token with one attribute O is a token with two attributes 15) when the scanner is reading a variable name O it stops after he got something different than a letter X it returns the token if the look ahead buffer shows a blank O continues reading until he gets a ";" 16) if a programmer writes "fi" instead of "if" O the scanner recognizes it and reports an error X the parser treads "fi" as a "id" token O the parser generates code which assigns the variable "fi" a value 17) <+> X is a token without attribute O is a token with one attribute O is not a token, it is a operator 18) public class Num extends Token { public final int value; public Num(int v) { super(Tag.NUM); value = v;} } O the constructor assigns the variable name X the constructor sets the type of the token as a number O the constructor calls the constructor of the super class with the value