- 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
2K+ Views
Deterministic means that on each input there is one and only one state to which the automata can have the transition from its current state. In deterministic finite automata, the head can move only in one direction to scan the input tape symbols. But in the case of two-way, finite automata on scanning an input symbol the head of the tape may move in right or left from its current position.A deterministic finite automata is a set of 5 tuples and defined asM = (Q, Σ, δ, q0, F)Q: A non-empty finite set of states present in the finite control ... Read More
5K+ Views
Shift reduce parser is a type of bottom-up parser. It uses a stack to hold grammar symbols. A parser goes on shifting the input symbols onto the stack until a handle comes on the top of the stack. When a handle occurs on the top of the stack, it implements reduction.There are the various steps of Shift Reduce Parsing which are as follows −It uses a stack and an input buffer.Insert $ at the bottom of the stack and the right end of the input string in Input Buffer.Shift: Parser shifts zero or more input symbols onto the stack until ... Read More
904 Views
Bottom-up parsing can be represented as an attempt to reduce the input string ω to the start symbol of a grammar by discovering out the right-most derivation of ω in reverse. This is similar to generating a parse tree for the input string ω by starting with leaves and proceeding toward the root i.e., attempting to generate the parse tree from the bottom-up.This contains searching for the substring that connect the right side of any of the production of the grammar. This substring is restored by the left-hand side nonterminal of the production if this replacement leads to the generation ... Read More
9K+ Views
In top-down parsing, the parse tree is generated from top to bottom, i.e., from root to leaves & expand till all leaves are generated.It generates the parse tree containing root as the starting symbol of the Grammar. It starts derivation from the start symbol of Grammar & performs leftmost derivation at each step.Drawback of Top-Down ParsingTop-down parsing tries to identify the left-most derivation for an input string ω which is similar to generating a parse tree for the input string ω that starts from the root and produce the nodes in a pre-defined order.The reason that top-down parsing follow the ... Read More
10K+ Views
Parsing is known as Syntax Analysis. It contains arranging the tokens as source code into grammatical phases that are used by the compiler to synthesis output generally grammatical phases of the source code are defined by parse tree. There are various types of parsing techniques which are as follows −Top-Down ParserIt generates the Parse Tree from root to leaves. In top-down parsing, the parsin begins from the start symbol and changes it into the input symbol.An example of a Top-Down Parser is Predictive Parsers, Recursive Descent Parser.Predictive Parser − Predictive Parser is also known as Non-Recursive Predictive Parsing. A predictive ... Read More
338 Views
Syntax Analysis or Parser is the second phase of compilation. The parser takes as its input tokens generated from the previous phase, i.e., the Lexical Analyzer phase, and groups them in such a way that their syntax can be recognized.It takes input as tokens & converts them into Parse Tree.Example1 − Statement a = b + c will be converted to a sequence of tokens a, b, c, =, +, and these tokens will be converted to Parse Tree by Parser. The corresponding Parse Tree will be generated as −Example2 − Draw Parse Tree for the statement. (If A = ... Read More
35K+ Views
The lexical analysis is the first phase of the compiler where a lexical analyser operate as an interface between the source code and the rest of the phases of a compiler. It reads the input characters of the source program, groups them into lexemes, and produces a sequence of tokens for each lexeme. The tokens are sent to the parser for syntax analysis.If the lexical analyzer is located as a separate pass in the compiler it can need an intermediate file to locate its output, from which the parser would then takes its input. It can eliminate the need for ... Read More
15K+ Views
A Grammar that makes more than one Leftmost Derivation (or Rightmost Derivation) for the similar sentence is called Ambiguous Grammar.Example − Verify whether the following Grammar is Ambiguous or Not.E → E+E|E $\ast$ E|idSolutionFor string id + id * id, there exist two parse trees.E ⇒lm $\underline{E}$+E ⇒ id+ $\underline{E}$⇒ id+$\underline{E}$ $\ast$ E⇒ id+id $\ast$ $\underline{E}$⇒ id+id $\ast$ idE ⇒lm $\underline{E}$ $\ast$ E⇒ $\underline{E}$+E $\ast$ E⇒ id+ $\underline{E}$ $\ast$ E⇒ id+id $\ast$ $\underline{E}$⇒ id+id $\ast$ idSo, the same string is generated using two different leftmost derivations. Each is having a different parse tree.∴ Two different parse trees exist for string id + id ... Read More
10K+ Views
Derivations mean replacing a given string’s non-terminal by the right-hand side of the production rule. The sequence of applications of rules that makes the completed string of terminals from the starting symbol is known as derivation. The parse tree is the pictorial representation of derivations. Therefore, it is also known as derivation trees. The derivation tree is independent of the other in which productions are used.A parse tree is an ordered tree in which nodes are labeled with the left side of the productions and in which the children of a node define its equivalent right parse tree also known ... Read More
2K+ Views
Derivations mean replacing a given string’s non-terminal by the right-hand side of the production rule. The sequence of applications of rules that makes the completed string of terminals from the starting symbol is known as derivation.It can derive terminal strings, beginning with the start symbol, by repeatedly replacing a variable with some production. The language of CFG is a set of terminal symbols we can derive so. This language is called context Free Language.Derivations are denoted by ⇒.For example, consider a Grammar.G=({S}, {a, b}, P, S), where, P contains following productions −P={S→aSa |bSb | ∈}In the above, S may be ... Read More