Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Academic Advising (https://www.askmehelpdesk.com/forumdisplay.php?f=17)
-   -   Compiler Questions (https://www.askmehelpdesk.com/showthread.php?t=280381)

  • Nov 13, 2008, 04:07 AM
    Leo_645
    Compiler Questions
    1. How can a multi-pass compiler can be reduced to a single pass compiler?Explain.


    2. In the statement IF<expr> THEN statement ENDIF,explain the syntax,static semantics and execution semantics.


    3.Suppose for a moment that c++ did not permit multiple inheritance.In other words,assume that each class can only inherit from one or no other.Describe a scheme for laying out memory at runtime that will enable a compiler to compile such classes.
    In your scheme,describe the solutions to the following problems:
    1.) Where to put additional data object in a derived class.
    2.) How to handle non-virtual functions.
    3.) How to handle virtual functions,inclusing problems due to redefinition in derived classes.



    4. Generate the three-address codes and quadruples for the following c program segment.Assume that two bytes are required to store each element of the array

    sum=0;
    p=0;
    while(p<=20){
    sum=sum+x[p];
    p=p+1;
    }



    5. Explain with an example the simple translation scheme for an assignment statement.


    6. In the statement a=b+c*d,explain what is the syntax,the static semantics and execution semantics.


    7. Construct a non-deterministic finite automata(NFA) for recognizing the following tokens.

    a) a(aa)*
    b) (a+b)*a
    convert the NFA to an equivalent DFA and make the token recognized by each state of DFA.


    8. If a well designed symbol table had a total capacity of around 18,000 and currently contained 10,000 randomly chosen identifiers,approx. how many comparisons would most likely be needed to locate a single identifier inth etable.


    9. Construct the parsing table for the following LL(1) grammar
    S (arrow sign) aA/B
    A (arrow sign) bB/a
    B (arrow sign) c/bAc


    10.Generate code for the following c program
    main()
    {
    int p;
    int x[10];
    while(p<=10)
    x[p]=0;
    }


    11. Construct the directed acyclic graph for the following basic block
    d=b*c
    e=a+b
    b=b*c
    a=e-d



    12. Which phase of the compiling process would be expected to be the first discover an error in the following program and why?


    int mail@(){return 0;}


    13. Factor loop-invariant expressions in the following loop

    while(x>y){
    sub=x*Is+d/e;
    b[sub]=(a-c)*(x-y);
    x--;
    }

    14.Three advantages and disadvantages of single pass compiler and multi compiler.
  • Nov 13, 2008, 04:16 AM
    Curlyben
    Thank you for taking the time to copy your homework to AMHD.
    Please refer to this announcement: Ask Me Help Desk - Announcements in Forum : Homework Help

  • All times are GMT -7. The time now is 04:32 AM.