0% found this document useful (0 votes)
11 views3 pages

GG

Uploaded by

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

GG

Uploaded by

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

Compiler Design

● A grammar is ambiguous if it has two different parse trees for any string by using either LMD only or by
using either RMD only.
● If G is an unambiguous grammar then every right sentential form has a unique handle.
● Every DCFL has an unambiguous grammar
● The number of states of CLR is more than all LR parsers.
● Divide by integer verified at semantic analysis phase (NPTEL, GO test)
● The number of states of LR(0), SLR(1), and LALR(1) is the same
● Keywords of a language are recognized during Lexical Analysis phase
● The code-optimization on intermediate code generation will always enhance the portability of the
compiler to target processors. The main reason behind this is, as the intermediate code is independent of
the target processor on which the code will be executed, so the compiler is able to optimize the
intermediate code more conveniently without bothering the underlying architecture of the target
processor.
● The drawback for quadruple representation of 3-address code is it requires more space compared to triple
notation.
● We can convert Regular Grammar into CNF
● S-attributed SDT uses Bottom up parser., If every L attributed is forced to only behave like S attrib, then
it also can be parsed by Bottom up parser.
● Viable prefixes are always present at the stack., They can't contain symbols on the RHS of a handle.
● Theorem: Set of viable prefixes is regular language, recognised by a DFSA.
● Static single assignment is a valid intermediate code representation
● Live variable analysis
Calculate Gen(X) and KILL(X) at each node
Calculate OUT(X) = IN of all the outgoing edges
Calculate IN(X) as GEN(X) union (OUT(x)-KILL(x)) at each node
Move from bottom to upward transitions
Live variable analysis is really very important for register allocation and dead code elimination
● An annotated parse tree is a parse tree showing the values of the attributes at each node. The process of
computing the attribute values at the nodes is called annotating or decorating the parse tree. The
drawback for quadruple representation of 3-address code is it requires more space compared to triple
notation. The drawback of triples is that, in triples form statements cannot be moved, whereas it is
indirect triples which has the drawback that it requires two memory accesses.
● Every LR(0) must be LALR(1) but every LALR(1) need not be LR(0).
● Register Spilling: When the number of live variables exceeds the number of registers, then some of the
values in the registers are stored in the main memory. This concept is known as register spilling.
● Reduce entries decreases error entries increase when we change LR(0) to SLR(1)
● Symbol table entries are only created in the analysis phase i.e. LEX, SYNTAX ANALYSIS and
SEMANTIC ANALYSIS
● Sentinel is a special character which can never be part of the source program, usually put at the end of the
program eg. EOF
● CYK algorithm O(n^3) dynamic programming
● CNF : A->BC or A->a this form of the CFG is known as CNF
● If language is generating epsilon that is fine, but no CNF can generate epsilon on their own S->ϵ is
allowed
● Bottom up parsing requires rightmost derivation in reverse (Gate 2019)
● Handle Pruning: When you are able to reduce something to a Terminal, that RHS is known as handle
● Shift Reduce Parsing :Four possible actions on SR parsers : - shift, reduce, error and accept
● Conflicts in SR parsers: For a conflict to happen, there must be at least a single reduce move.
● LR parsing: Simple LR parser
● LR(k) explained: L - Scan input from left to right, Rightmost derivation in reverse,(K) means lookahead
● LR parsers can detect syntactical errors as soon as it is possible to do on a left to right scan of the input.
● LR(k) is proper superset of LL(k) grammars
● SLR : put reduce moves only in the follow of LHS
● LALR : put reduce moves only in the lookahead after merging the states from CLR
● CLR is more powerful than LALR
● LALR and CLR put Reduce moves only in the lookahead.
● Viable Prefixes: These are the pigeons which always appear on the stack of SR parser. Equivalently, this
means that the set of viable prefixes for a given SLR (1) grammar is a regular language! Viable prefix
depends on what input string you want to parse Whatever is present on the stack, is a set of viable
prefixes.
● Operator precedence parser, Ambiguity is allowed, but i. grammar must not contain ϵ, ii. No two
Terminals should be concatenated without an operator in the middle.
● Syntax directed Translation Scheme : L attributed - inherit from only LHS or left sibling - top down
parsing, S attributed - inherit only from RHS - bottom up, Synthesised Attributes Only S attributed,
Inherited Attributes : Can be both S and L attributed
● Application of SDT: Construction of syntax tree, Infix to Postfix translation
● Intermediate Code generation: DAG,TAC,Quadruples, Indirect triples, Triples, Syntax Tree
● Static Single Assignment (no variable is repeated once used)
● Runtime environment: Stack , Static, Heap, Code
● Heap —> FREE MEMORY <—— Stack
● // They grow towards each other
● Stack: Activation Tree
● Procedure calls and returns are usually managed by a run time stack called the control stack. Each live
activation has an activation record.(frame) having root at the
bottom of the stack. Activation Record Global variables are
allocated static storage
● Basic Blocks and flow graph

You might also like