Predictive parsing is a technique for parsing context-free grammars where the parser predicts the next production to use based on looking ahead at upcoming tokens. It works for LL(1) grammars, where the production can be determined uniquely from the next token. The parsing process involves building a parsing table from the grammar's first and follow sets and using that table to guide the parser's actions. When an error is detected, various recovery techniques like panic mode or inserting error productions can be used to try to continue parsing.
Syntax Analysis: Introduction, Context-Free Grammars, Writing a Grammar, Top-Down Parsing, Bottom-Up Parsing, Introduction to LR Parsing: Simple LR, More Powerful LR Parsers, Using Ambiguous Grammars, Parser Generators.
Syntax Analysis: Introduction, Context-Free Grammars, Writing a Grammar, Top-Down Parsing, Bottom-Up Parsing, Introduction to LR Parsing: Simple LR, More Powerful LR Parsers, Using Ambiguous Grammars, Parser Generators.
This slide is prepared By these following Students of Dept. of CSE JnU, Dhaka. Thanks To: Nusrat Jahan, Arifatun Nesa, Fatema Akter, Maleka Khatun, Tamanna Tabassum.
This slide is prepared By these following Students of Dept. of CSE JnU, Dhaka. Thanks To: Nusrat Jahan, Arifatun Nesa, Fatema Akter, Maleka Khatun, Tamanna Tabassum.
The first “L” stands for scanning input from left to right. The second “L” for producing a leftmost derivation. The “1” for using one input symbol of look-ahead at each step to make parsing decisions.
Stack and its Applications : Data Structures ADTSoumen Santra
Stack is an Abstract Data Type (ADT), Last in First out (LIFO) concept.
Features of Stack: Abstract Data Type (ADT)
C implementations of Stack's Functions like push(), pop(), isEmpty(), isOverflow(), peep()
Stack Applications like Tower of Hanoi, Infix to Postfix Conversion, Postfix Evaluation, Parenthesis Checking etc.
Diagramatic Representation of Tower of Hanoi, Infix to Postfix Conversion & Postfix Evaluation
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSEDuvanRamosGarzon1
AIRCRAFT GENERAL
The Single Aisle is the most advanced family aircraft in service today, with fly-by-wire flight controls.
The A318, A319, A320 and A321 are twin-engine subsonic medium range aircraft.
The family offers a choice of engines
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Democratizing Fuzzing at Scale by Abhishek Aryaabh.arya
Presented at NUS: Fuzzing and Software Security Summer School 2024
This keynote talks about the democratization of fuzzing at scale, highlighting the collaboration between open source communities, academia, and industry to advance the field of fuzzing. It delves into the history of fuzzing, the development of scalable fuzzing platforms, and the empowerment of community-driven research. The talk will further discuss recent advancements leveraging AI/ML and offer insights into the future evolution of the fuzzing landscape.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
2. Predictive Parsing
• Like recursive-descent but parser can “predict” which
production to use
– By looking at the next few tokens (lookahead)
– No backtracking
• Predictive parsers restrict CFGs and accept LL(k)
grammars
– 1st L – The input is scanned from left to right– 1st L – The input is scanned from left to right
– 2nd L – Create left-most derivation
– k – Number of symbols of look-ahead
• Most parsers work with one symbol of look-ahead
[LL(1)]
• Informally, LL(1) has no left-recursion and has been
left-factored.
28-Jan-15 2CS 346 Lecture 5
3. Left Factoring
• At each step, only one choice of production
• Given the grammar:
E T + E | T
T int | int * T | ( E )
• Hard to predict which production to use because of common prefixes.
• We need to left-factor the grammar
• The Left-factored grammar:
E T X
X + E | ɛ
T ( E ) | int Y
Y * T | ɛ
28-Jan-15 3CS 346 Lecture 5
4. LL(1) Parsing
• Left factored Grammar:
E T X T ( E ) | int Y
X + E | ɛ Y * T | ɛ
• LL(1) parsing table: Next input token
int * + ( ) $
E TX TX
X +E ɛ ɛ
T int Y (E)
Y *T ɛ ɛ ɛLeftmost non-terminal RHS of production to use
28-Jan-15 4CS 346 Lecture 5
5. • For the leftmost non-terminal X
• We look at the next input token a
• Makes use of an explicit parsing table of the form M[X, a]
• An explicit external stack records frontier of the parse tree
Predictive Parsing Algorithm
• An explicit external stack records frontier of the parse tree
– Non-terminals that have yet to be expanded
– Terminals that have yet to matched against the input
– Top of stack = leftmost pending terminal or non-terminal
• Reject on reaching error state
• Accept on end of input & empty stack
28-Jan-15 5CS 346 Lecture 5
6. • The parse table entry M[X, a] indicates which production to use if the
top of the stack is a non-terminal ‘X’ and the current input token is ‘a’.
• In that case ‘POP X’ from the stack and ‘PUSH’ all the RHS symbols
of the production M[X, a] in reverse order.
• Assume that '$' is a special token that is at the bottom of the stack and
terminates the input string
Predictive Parsing Algorithm
terminates the input string
if X = a = $ then halt
if X = a $ then pop(x) and ip++
if X is a non terminal
then if M[X, a] = {X UVW}
then begin pop(X); push(W,V,U)
end
else error
28-Jan-15 6CS 346 Lecture 5
7. LL(1) Parsing
STACK INPUT ACTION
E$ int * int $ TX
TX$ int * int $ intY
intYX$ int * int $ Terminal
(match)
YX$ *int$ *T
*TX$ *int$ Terminal
int * + ( ) $
E TX TX
X +E ɛ ɛ
T int Y (E)
Y *T ɛ ɛ ɛ
E*TX$ *int$ Terminal
(match)
TX$ int$ intY
intYX$ int$ Terminal
(match)
YX$ $ ɛ
X$ $ ɛ
$ $ Accept
E
T X
int Y ɛ
* T
int Y
Ɛ28-Jan-15 7CS 346 Lecture 5
8. Construction of Parsing Table
• Given the production A α, and a token t
• M[A, t] = α occurs in two cases:
1. If α *tβ
• α can derive a ‘t’ in the first position in 0 or more moves
• We say that t ϵ First(α)• We say that t ϵ First(α)
– ‘t’ is one of the terminals that can produce in the first position
2. If A α and α *ɛ and X * β Atδ
• Stack has A, input is t, and A cannot derive t
• In this case only option is to get rid of A (by deriving )
• Can work only if ‘t’ follows A in at least one derivation
• We say t ϵ Follow(A)
28-Jan-15 8CS 346 Lecture 5
9. First Sets
• Definition
– First(X) = { t | t is a terminal and X *tα} or {ɛ|X *ɛ}
• To build FIRST(X):
1. If X ϵ terminal, then FIRST(X) is {X}
2. If ((X ɛ) or ((X Y1…Yk) and (ɛ ϵ [Ɐi: 1 < i ≤ k First (Yi)]))
then add ɛ to FIRST(X)
2. If ((X ɛ) or ((X Y1…Yk) and (ɛ ϵ [Ɐi: 1 < i ≤ k First (Yi)]))
then add ɛ to FIRST(X)
3. If ((X Y1Y2…Yk α) and (ɛ ϵ [Ɐi: 1 < i ≤ k First (Yi)]))
then add FIRST(α) to FIRST(X)
• Find the first sets in the grammar:
E TX X + E | ɛ
T ( E ) | int Y Y * T | ɛ
28-Jan-15 9CS 346 Lecture 5
10. E TX X + E | ɛ
T ( E ) | int Y Y * T | ɛ
• First (+)={+}
• First (E)=First(T)
First Sets
• First (*)={*}
• First (()={(}
• First ())={)}
• First (int)={int}
• First (E)=First(T)
• First (T) = {(, int}
• First(X) = {+, ɛ}
• First (Y) = {*, ɛ}
28-Jan-15 10CS 346 Lecture 5
11. Follow Set
• Definition:
– Follow(X) = { t | S * αXtβ}
– ‘t’ is said to follow of ‘X’ if we can obtain a sentential form
where the terminal ‘t’ comes immediately after ‘X’
• Follow set for a given symbol never concerns what the
symbol can generate, but depends on where that symbolsymbol can generate, but depends on where that symbol
can appear in the derivations.
• If (X AB) then
– First(B) is in Follow(A) and
– Follow(X) is in Follow(B)
– If (B *ɛ ) then
• Follow(X) is in Follow(A)
28-Jan-15 11CS 346 Lecture 5
12. • To build FOLLOW(X)
1. Add $ to FOLLOW(S) [ If S is the start symbol]
2. If (A αBβ), then
Add everything in FIRST(β) except ɛ to FOLLOW(B)
3. If ((A αBβ and β *ɛ) or (A αB))
Add everything in FOLLOW(A) to FOLLOW(B)
Follow Set
• ɛ never appears in Follow sets, so Follow sets are just sets
of terminals
• Find the follow sets in the grammar:
E T X X + E | ɛ
T ( E ) | int Y Y * T | ɛ
28-Jan-15 12CS 346 Lecture 5
13. Parsing Table Construction
• for each production A α {
• for each terminal ‘t’ in FIRST(α)
• M[A, t] = α;
• if ɛ is in FIRST(α) , then
• for each terminal ‘b’ (including ‘$’) in Follow (A)• for each terminal ‘b’ (including ‘$’) in Follow (A)
• M[A, b] = α;
}
• Find the follow sets in the grammar:
E T X X + E | ɛ
T ( E ) | int Y Y * T | ɛ
28-Jan-15 13CS 346 Lecture 5
14. Recognizing LL(1) Grammars
• Consider the grammar X Xa | b
• First (X) = {b} Follow(X) = {$, a}
• Parsing Table:
Multiply defined entry:a b $
X b
Xa
Multiply defined entry:
This is how we know that
the grammar is not LL(1)
28-Jan-15 14CS 346 Lecture 5
15. • Formally, a grammar is LL(1) iff:
– It is not left-recursive
– Not ambiguous
– A grammar G is LL(1) iff whenever A u | v are two distinct productions
of G, the following conditions hold:
Recognizing LL(1) Grammars
• For no terminal ‘a’ do both ‘u’ and ‘v’ derive strings beginning with ‘a’ (i.e., FIRST
sets are disjoint)
• At most one of ‘u’ and ‘v’ can derive the empty string
• if v * ɛ then ‘u’ does not derive any string beginning with a terminal in
Follow(A) (i.e., if ɛ ϵ FIRST(v), then FIRST(u) and FOLLOW(A) are disjoint sets)
Most programming languages are not LL(1)
28-Jan-15 15CS 346 Lecture 5
16. Error Handling
• Stop at the first error and print a message
– Compiler writer friendly
– But not user friendly
• Every reasonable compiler must recover from error and
identify as many errors as possible
• However, multiple error messages (cascaded spurious error
messages) due to a single fault must be avoided
• Error recovery methods
– Panic mode
– Phrase level recovery
– Error productions
– Global correction
28-Jan-15 16CS 346 Lecture 5
17. Panic Mode
• Simplest and the most popular method
• Most tools provide for specifying panic mode
recovery in the grammar
• When an error is detected• When an error is detected
– Discard tokens until one with a clear role is found
– Continue from there
• Looking for synchronizing tokens
– Typically the statement or expression terminators
28-Jan-15 17CS 346 Lecture 5
18. • Consider following code
{
a = b + c;
d = m n ;
e = d - f;
Syntax Error
Panic Mode
e = d - f;
}
• The second expression has syntax error
– Skip ahead to next ‘;’ and try to parse the next expression
• It discards one expression and tries to continue parsing
28-Jan-15 18CS 346 Lecture 5
19. Phrase Level Recovery
• Make local correction to the input
– Eg: Fill in the blank entries in the predictive parsing
table with pointers to error routines
• Works only in limited situations
– A common programming error which is easily detected– A common programming error which is easily detected
– For example insert a ‘;’ after closing ‘}’ of a class
definition
• Does not work very well when the actual error has
occurred before the point of detection
28-Jan-15 19CS 346 Lecture 5
20. Error Productions
• Add erroneous constructs as productions in the
grammar
• Works only for most common mistakes which can be
easily identified
• Essentially makes common errors as part of the• Essentially makes common errors as part of the
grammar
• Complicates the grammar and does not work very well
• Eg:
– Write 5 x instead of 5 * x
– Add the production E … | E E
28-Jan-15 20CS 346 Lecture 5
21. Global Corrections
• Idea: find a correct “nearby” program
– Try token insertions and deletions
– Nearness may be measured using certain metric (Edit
Distance)
– Exhaustive search
• PL/C compiler implemented this scheme: anything• PL/C compiler implemented this scheme: anything
could be compiled.
• Disadvantages:
– Complicated - hard to implement
– Slows down parsing of correct programs
– “Nearby” is not necessarily “the intended” program
28-Jan-15 21CS 346 Lecture 5
22. Error Recovery in LL(1) Parser
• Error occurs when a parse table entry M[A, a] is empty or
terminal on stack-top do not match with input.
• Skip symbols in the input until a token in a selected set (synch)
appears
• Place symbols in follow(A) in synch set. Skip tokens until an
element in follow(A) is seen. Pop(A) and continue parsing
• Add symbol in first(A) in synch set. Then it may be possible to
resume parsing according to A if a symbol in first(A) appears
in input.
28-Jan-15 22CS 346 Lecture 5