System Programming: Design Problem
System Programming: Design Problem
SYSTEM PROGRAMMING
DESIGN PROBLEM
SUBMITTED TO:
SUBMITTED BY :
RUCHI MAM
ANJANI KUNWAR
RA1803A10
10807973
B.TECH(CSE)-H
DESIGN PROBLEM
Else
W[I,J]=X[I,J]+Y[W[K,L]]+Z[I+J]
U[I,J,K]=V[I,J,K,L]
Expectaions:
2.Perform the syntax tree for last two operations used in the program.
4.Evaluate the intermediate code(3 address code) for the given loop.
There are three tasks for the compiler to perform in the lexical analysis phase i.e.
1. To convert the source program into the basic elements; tokens of the
language.
2. To build a literal table and an identifier table.
3. To build a uniform symbol table.
According to the ques. All elements are divided into following categories:-
a) Identifier-it basically uses id as a symbol or token class code for the identifier. Numbers
can be used as per our requirements.
so ,here are all the identifiers and all the corresponding tokens used for them.
SR NO TOKEN
I.A id#1
II.B id#2
III.C id#3
IV.D id#4
V .E id#5
VI.F id#6
VII. G id#7
VIII .W id#8
IX .X id#9
X. Y id#10
XII . Z id#11
XIII .U id#12
XIV .V id#13
XV . I id#14
XVI .J id#15
XVII.K id#16
XVII.L id#17
b).keywords-it is a name that has a special meaning and functionality. It can be also used to
represent symbol or as an operator. In this the class code is a key.
SR NO TOKEN
I .if key#1
II .while key#2
3.operator-their main purpose is to compare between the various variables and identifiers .they
are represented by the symbol (op)
SR NO TOKEN
I .< op#1
IV. OR op#4
V. + op#5
VI. - op#6
VII. * op#7
VIII.== op#8
4.special symbol-these are special notations like array parameter etc…the class code is (ss)
SR NO TOKEN
I.( ss#1
II.) ss#2
III .[ ss#3
IV.] ss#4
V., ss#5
Expressing the TOKENS in EXPRESSION:-
While, A,(,<,C,ADD,B,>,D,OR,E,F,),if, = =, 1,ADD,C,+,*,-,else, W,[,I,J,K,L,],X,Y,Z,U,V
Semantic analysis, where we delve even deeper to check whether they form a sensible set of
instructions in the programming language. Whereas any old noun phrase followed by some verb
phrase makes a syntactically correct English sentence, a semantically correct one has subjectverb
agreement, proper use of gender, and the components go together to express an idea that
makes sense. For a program to be semantically valid, all variables, functions, classes, etc. must
be properly defined, expressions and variables must be used in ways that respect the type system,
access control must be respected, and so forth. Semantic analysis is the front end’s penultimate
phase and the compiler’s last chance to weed out incorrect programs. We need to ensure the
program is sound enough to carry on to code generation.
A large part of semantic analysis consists of tracking variable/function/type declarations and type
checking.
L4: T5 = I+J
T6: X [I, J] + Y [W [K, L]]
T7: T6 + Z [T5]
W [I, J] = T7 goto L1
U [I, J, K] = V [I, J, K, L]
L5: END
Optimization is the field where most compiler research is done today. The tasks of the front-end
(scanning, parsing, semantic analysis) are well understood and unoptimized code generation is
relatively straightforward. Optimization, on the other hand, still retains a sizable measure of
mysticism. High-quality optimization is more of an art than a science. Compilers for mature
languages aren’t judged by how well they parse or analyze the code—you just expect it to do it
right with a minimum of hassle—but instead by the quality of the object code they produce.