0% found this document useful (0 votes)
37 views

Compiler Assignment-1

Compiler the misfit

Uploaded by

ansh20u
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Compiler Assignment-1

Compiler the misfit

Uploaded by

ansh20u
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SESSION: 2024-25

(ACSE0504)
Assignment- Unit 1&2
SEM/SEC:
V(A+B+C+D+E)
Assignment Given Date: 19/09/2024 Maximum Points: 10
Assignment Submission Date: 2/10/2024 Weightage in University Exam: 10 Marks
Faculty Name: ROHIT CHAUDHARY

1.Illustrate the phases of compiler with following Example .(Sum= old Sum+rate*50) [CO1]

2. Let G be a Context Free Grammar for which the production Rules are given below:
[CO1]
S -> aB|bA
A -> a|aS|bAA
B -> b|bS|aBB
Drive the string “aaabbabbba” using the above grammar (using Left Most Derivation and Right
most Derivation and draw the parse tree.

3. Count the No of tokens in the program [CO1]


a)
Int main ()
{
Int a=20, b=30;
If( a<b)
Return (b);
Else
Return (a);
}
b)
printf(“ i=%d, & i=%x”, i,&i);
C)
main()
{
a= b+++ ---- +++ ==;
printf(“ %d%d, a, b);
4. Write a short note on: [CO1]
a. Translator with difference
b. Pass
c. Bootstrapping and Cross Compiler
d. LEX Compiler and YACC
e. Tokens, Patterns and Lexemes
5) Define finite automata and construct a DFA which accept a language of all strings input
{a.b} [CO1]
a) Containing ‘a’
b) End with ‘a’
c) Second and fourth symbol is 1 with ∑(0,1)
d) . Construct NON Deterministic Finite Automata to accept the regular expression.
(0+1)*1(0+1)
6.a) Describe and Differentiate between Top down and Bottom-up parser with example.
b) Identify the rule for left recursion and Left factoring. Is the following grammar left recursive?

E → E+E | E*E| a| b

7) Consider the following grammar: [CO2]


a) S→B|SabS, B→bB| ε Compute FOLLOW(B) and first (S), (B)
b) Compute first and follow. [CO2]
S → aBDh

C → bC / ∈
B → cC

D → EF
E→g/∈
F→f/∈
8) Write Basic operations about shift-reduce parsing and parse the string Using S-R parser.
[CO2]
Consider the grammar
E –> 2E2
E –> 3E3
E –> 4
Perform Shift Reduce parsing for input string “32423”

9) Construct predictive parse table for the following grammar. [CO2]


E → E + T/T

T →T *F/F
F →F /a/b

10) ( a) Give Operator –precedence parsing algorithm. Consider the following grammar
and build up operator precedence table. Also parse the input string (id+(id*id))
[CO2]
EE+T|T
TT*F|F
F(E)|id
(b) Construct the parsing table for the following grammar: S→AA, A→aA|b [CO2]
a) LR(0)
b) SLR(1)
c) CLR (1)
d) LALR

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy