- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 213 Articles for Computer Programming
15K+ Views
The three-address code is a sequence of statements of the form A−=B op C, where A, B, C are either programmer-defined names, constants, or compiler-generated temporary names, the op represents an operator that can be constant or floatingpoint arithmetic operators or a Boolean valued data or a logical operator. The reason for the name “three address code” is that each statement generally includes three addresses, two for the operands, and one for the result.In the three-address code, atmost three addresses are define any statement. Two addresses for operand & one for the result.Hence, op is an operator.An only a single ... Read More
19K+ Views
Parse TreeParse tree is a hierarchical structure that defines the derivation of the grammar to yield input strings. In parsing, the string is derived using the start symbol. The root of the parse tree is that start symbol. It is the graphical description of symbols that can be terminals or non-terminals. Parse tree follows the precedence of operators. The deepest sub-tree traversed first. Therefore, the operator in the parent node has less precedence over the operator in the sub-tree.A Parse Tree for a CFG G = (V, Σ, P, S) is a tree satisfying the following conditions −Root has the ... Read More
21K+ Views
Tree in which each leaf node describes an operand & each interior node an operator. The syntax tree is shortened form of the Parse Tree.Example1 − Draw Syntax Tree for the string a + b ∗ c − d.Rules for constructing a syntax treeEach node in a syntax tree can be executed as data with multiple fields. In the node for an operator, one field recognizes the operator and the remaining field includes a pointer to the nodes for the operands. The operator is known as the label of the node. The following functions are used to create the nodes ... Read More
19K+ Views
The translation of the source code into the object code for the target machine, a compiler can produce a middle-level language code, which is referred to as intermediate code or intermediate text. There are three types of intermediate code representation are as follows −Postfix NotationIn postfix notation, the operator comes after an operand, i.e., the operator follows an operand.ExamplePostfix Notation for the expression (a+b) * (c+d) is ab + cd +*Postfix Notation for the expression (a*b) - (c+d) is ab* + cd + - .Syntax TreeA tree in which each leaf node describes an operand & each interior node an ... Read More
15K+ Views
In postfix notation, the operator appears after the operands, i.e., the operator between operands is taken out & is attached after operands.Example1 − Translate a ∗ d − (b + c) into Postfix form.Solutionad ∗ bc + −Example2 − Convert a + (b ∗⊝ c) is in Postfix form.SolutionHere ⊝ represents the unary minus operator.a b c ⊝ ∗ +Example3 − Convert Postfix Expression into Infix Expression using Stack Implementationa d ∗ bc + −SolutionString SymbolsStackad ∗ bc + −AADad*(a * d)B(a * d)bC(a * d)b c+(a ∗ d)(b + c)-(a ∗ d)-(b + c)Example4 − Calculate the value for ... Read More
19K+ Views
Intermediate code can translate the source program into the machine program. Intermediate code is generated because the compiler can’t generate machine code directly in one pass. Therefore, first, it converts the source program into intermediate code, which performs efficient generation of machine code further. The intermediate code can be represented in the form of postfix notation, syntax tree, directed acyclic graph, three address codes, Quadruples, and triples.If it can divide the compiler stages into two parts, i.e., Front end & Back end, then this phase comes in between.Example of Intermediate Code Generation −Three Address Code− These are statements of form ... Read More
1K+ Views
A syntax-directed translation scheme is a context-free grammar in which attributes are related to the grammar symbol and semantic actions enclosed within braces ({ }). These semantic actions are the subroutines that are known by the parser at the suitable time for translation. The location of the semantic actions on the right side of production denotes the time when it will be known for implementation by the parser.When it can produce a translation scheme, it should provide that an attribute value is available when the action defines it. This needed thatInherited attributes of a symbol on the right side of ... Read More
4K+ Views
There are two types of Syntax directed translation schemes which are as follows −Synthesized TranslationIn this translation, values of variables on L.H.S of a production rule depend on the value of the variable on R.H.S of production rule.For Example, E → E(1) + E(2) {E. VAL = E(1). VAL + E(2). VAL}Here, E on L.H.S of production rule can be computed by the sum of values of E(1) and E(2) which are on R.H.S of a production rule, i.e., L.H.S variable is dependent on R.H.S variables.In synthesized translation, the value of the synthesized attribute at the node is evaluated ... Read More
7K+ Views
In syntax directed translation, along with the grammar it can identify some informal notations and these notations are known as as semantic rules.After implementing the Semantic Analysis, the source program is modified to an intermediate form.There is some information that is required by the Intermediate code generation phase to convert the semantically checked parse tree into intermediate code. But this information or attributes of variables cannot be represented alone by Context- Free Grammar.So, some semantic actions have to be attached with Context-Free grammar which helps the intermediate code generation phase to generate intermediate code.So, Attaching attributes to the variables of ... Read More
5K+ Views
SolutionComputation of FIRSTE → E + T|TSince FIRST (E) does not contain ε.∴ FIRST (E) = FIRST(E + T) = FIRST(E)As, E → T∴ FIRST (E) = {FIRST(T)} (1)T → T ∗ F|FAs FIRST (T) does not contain ε or T does not derive ε.∴ FIRST (T) = FIRST(T ∗ F) = {FIRST(T)}As, T → F (FIRST(T) = {FIRST(F)} (2)F → (E)|id∴ By Rule (3)of FIRSTFIRST (F) = {(, id} ... Read More