SlideShare a Scribd company logo
Notes on First and Follow
Written by Ashok Kumar Pachauri
ITM Aligarh
Computing Nullable Sets
• Non-terminal X is Nullable only if the
following constraints are satisfied
(computed using iterative analysis)
– base case:
• if (X := ) then X is Nullable
– inductive case:
• if (X := ABC...) and A, B, C, ... are all Nullable then
X is Nullable
Computing First Sets
• First(X) is computed iteratively
– base case:
• if T is a terminal symbol then First (T) = {T}
– inductive case:
• if X is a non-terminal and (X:= ABC...) then
– First (X) = First (X) U First (ABC...)
where First(ABC...) = F1 U F2 U F3 U ... and
» F1 = First (A)
» F2 = First (B), if A is Nullable
» F3 = First (C), if A is Nullable & B is Nullable
» ...
Computing Follow Sets
• Follow(X) is computed iteratively
– base case:
• initially, we assume nothing in particular follows X
– (Follow (X) is initially { })
– inductive case:
• if (Y := s1 X s2) for any strings s1, s2 then
– Follow (X) = First (s2) U Follow (X)
• if (Y := s1 X s2) for any strings s1, s2 then
– Follow (X) = Follow(Y) U Follow (X), if s2 is Nullable
building a predictive parser
Z ::= X Y Z
Z ::= d
Y ::= c
Y ::=
X ::= a
X ::= b Y e
nullable first follow
Z
Y
X
building a predictive parser
Z ::= X Y Z
Z ::= d
Y ::= c
Y ::=
X ::= a
X ::= b Y e
nullable first follow
Z no
Y yes
X no
base case
building a predictive parser
Z ::= X Y Z
Z ::= d
Y ::= c
Y ::=
X ::= a
X ::= b Y e
nullable first follow
Z no
Y yes
X no
after one round of induction, we realize we have reached a fixed point
building a predictive parser
Z ::= X Y Z
Z ::= d
Y ::= c
Y ::=
X ::= a
X ::= b Y e
nullable first follow
Z no d
Y yes c
X no a,b
base case (note, first of Y should include empty string)
building a predictive parser
Z ::= X Y Z
Z ::= d
Y ::= c
Y ::=
X ::= a
X ::= b Y e
nullable first follow
Z no d,a,b
Y yes c
X no a,b
after one round of induction, no fixed point
building a predictive parser
Z ::= X Y Z
Z ::= d
Y ::= c
Y ::=
X ::= a
X ::= b Y e
nullable first follow
Z no d,a,b
Y yes c
X no a,b
after two rounds of induction, no more changes ==> fixed point
building a predictive parser
Z ::= X Y Z
Z ::= d
Y ::= c
Y ::=
X ::= a
X ::= b Y e
nullable first follow
Z no d,a,b { }
Y yes c { }
X no a,b { }
base case
building a predictive parser
Z ::= X Y Z
Z ::= d
Y ::= c
Y ::=
X ::= a
X ::= b Y e
nullable first follow
Z no d,a,b { }
Y yes c e,d,a,b
X no a,b c,d,a,b
after one round of induction, no fixed point
building a predictive parser
Z ::= X Y Z
Z ::= d
Y ::= c
Y ::=
X ::= a
X ::= b Y e
nullable first follow
Z no d,a,b { }
Y yes c e,d,a,b
X no a,b c,d,a,b
after two rounds of induction, fixed point
(but notice, computing Follow(X) before Follow (Y) would have required 3rd
round)

More Related Content

What's hot

Polynomial and thier graphs
Polynomial and thier graphsPolynomial and thier graphs
Polynomial and thier graphs
Jessica Garcia
 
9.3 Intro to Rational Functions
9.3 Intro to Rational Functions9.3 Intro to Rational Functions
9.3 Intro to Rational Functions
Kristen Fouss
 
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygonsLiang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Lahiru Danushka
 
Differential Calculus
Differential CalculusDifferential Calculus
Differential Calculus
anithaselvakumar271
 
Quadratic
QuadraticQuadratic
Quadratic
Iman Izzati
 
Graphing polynomial functions by tabby
Graphing polynomial functions by tabbyGraphing polynomial functions by tabby
Graphing polynomial functions by tabby
paytab75
 
Comp102 lec 5.0
Comp102   lec 5.0Comp102   lec 5.0
Comp102 lec 5.0
Fraz Bakhsh
 
Rational Functions
Rational FunctionsRational Functions
Rational Functions
Jazz0614
 
Graphing Quadratics
Graphing QuadraticsGraphing Quadratics
Graphing Quadratics
swartzje
 
Calc 3.6a
Calc 3.6aCalc 3.6a
Calc 3.6a
hartcher
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
Kuntal Bhowmick
 
X2 T04 05 curve sketching - powers of functions
X2 T04 05 curve sketching - powers of functionsX2 T04 05 curve sketching - powers of functions
X2 T04 05 curve sketching - powers of functions
Nigel Simmons
 
Graph Quadratics
Graph QuadraticsGraph Quadratics
Graph Quadratics
toni dimella
 
Euler method in c
Euler method in cEuler method in c
Euler method in c
Subir Halder
 
Graphs of polynomial functions
Graphs of polynomial functionsGraphs of polynomial functions
Graphs of polynomial functions
Carlos Erepol
 
Angelica curve sketching project
Angelica curve sketching projectAngelica curve sketching project
Angelica curve sketching project
asmith123183
 
Slop lecture
Slop lectureSlop lecture
Slop lecture
AdnanBukhari13
 
Tutorials--Graphs of Rational Functions
Tutorials--Graphs of Rational FunctionsTutorials--Graphs of Rational Functions
Tutorials--Graphs of Rational Functions
Media4math
 
Mathematics 9 Lesson 3: Quadratic Functions
Mathematics 9 Lesson 3: Quadratic FunctionsMathematics 9 Lesson 3: Quadratic Functions
Mathematics 9 Lesson 3: Quadratic Functions
Juan Miguel Palero
 

What's hot (19)

Polynomial and thier graphs
Polynomial and thier graphsPolynomial and thier graphs
Polynomial and thier graphs
 
9.3 Intro to Rational Functions
9.3 Intro to Rational Functions9.3 Intro to Rational Functions
9.3 Intro to Rational Functions
 
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygonsLiang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
 
Differential Calculus
Differential CalculusDifferential Calculus
Differential Calculus
 
Quadratic
QuadraticQuadratic
Quadratic
 
Graphing polynomial functions by tabby
Graphing polynomial functions by tabbyGraphing polynomial functions by tabby
Graphing polynomial functions by tabby
 
Comp102 lec 5.0
Comp102   lec 5.0Comp102   lec 5.0
Comp102 lec 5.0
 
Rational Functions
Rational FunctionsRational Functions
Rational Functions
 
Graphing Quadratics
Graphing QuadraticsGraphing Quadratics
Graphing Quadratics
 
Calc 3.6a
Calc 3.6aCalc 3.6a
Calc 3.6a
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
 
X2 T04 05 curve sketching - powers of functions
X2 T04 05 curve sketching - powers of functionsX2 T04 05 curve sketching - powers of functions
X2 T04 05 curve sketching - powers of functions
 
Graph Quadratics
Graph QuadraticsGraph Quadratics
Graph Quadratics
 
Euler method in c
Euler method in cEuler method in c
Euler method in c
 
Graphs of polynomial functions
Graphs of polynomial functionsGraphs of polynomial functions
Graphs of polynomial functions
 
Angelica curve sketching project
Angelica curve sketching projectAngelica curve sketching project
Angelica curve sketching project
 
Slop lecture
Slop lectureSlop lecture
Slop lecture
 
Tutorials--Graphs of Rational Functions
Tutorials--Graphs of Rational FunctionsTutorials--Graphs of Rational Functions
Tutorials--Graphs of Rational Functions
 
Mathematics 9 Lesson 3: Quadratic Functions
Mathematics 9 Lesson 3: Quadratic FunctionsMathematics 9 Lesson 3: Quadratic Functions
Mathematics 9 Lesson 3: Quadratic Functions
 

Viewers also liked

Compiler First Set Follow Set Brief
Compiler First Set Follow Set BriefCompiler First Set Follow Set Brief
Compiler First Set Follow Set Brief
sallypicnic
 
Parsing example
Parsing exampleParsing example
Parsing example
Shraddha Patel
 
Newolo virtual coach_Amsterdam_09022015
Newolo virtual coach_Amsterdam_09022015Newolo virtual coach_Amsterdam_09022015
Newolo virtual coach_Amsterdam_09022015
Philippe Santraine
 
DfSC
DfSCDfSC
TWO EXTRAORDINARY TIME KEEPERS
TWO EXTRAORDINARY TIME KEEPERSTWO EXTRAORDINARY TIME KEEPERS
TWO EXTRAORDINARY TIME KEEPERS
Cheeco11
 
Mat 10 u1
Mat 10 u1Mat 10 u1
Adil zabroug resume
Adil zabroug resumeAdil zabroug resume
Adil zabroug resume
Adil Edyata
 
Ucaya power point1
Ucaya power point1Ucaya power point1
Presentation2015solvex
Presentation2015solvexPresentation2015solvex
Presentation2015solvex
vsterev
 
Angles pawer point 2 (1) real real 2
Angles pawer point 2 (1) real real 2Angles pawer point 2 (1) real real 2
Angles pawer point 2 (1) real real 2
GENIS3
 
Healthy Travel
Healthy TravelHealthy Travel
Healthy Travel
Leslie Burford
 
Careers_Trainee
Careers_TraineeCareers_Trainee
Careers_Trainee
Chris Ball
 

Viewers also liked (12)

Compiler First Set Follow Set Brief
Compiler First Set Follow Set BriefCompiler First Set Follow Set Brief
Compiler First Set Follow Set Brief
 
Parsing example
Parsing exampleParsing example
Parsing example
 
Newolo virtual coach_Amsterdam_09022015
Newolo virtual coach_Amsterdam_09022015Newolo virtual coach_Amsterdam_09022015
Newolo virtual coach_Amsterdam_09022015
 
DfSC
DfSCDfSC
DfSC
 
TWO EXTRAORDINARY TIME KEEPERS
TWO EXTRAORDINARY TIME KEEPERSTWO EXTRAORDINARY TIME KEEPERS
TWO EXTRAORDINARY TIME KEEPERS
 
Mat 10 u1
Mat 10 u1Mat 10 u1
Mat 10 u1
 
Adil zabroug resume
Adil zabroug resumeAdil zabroug resume
Adil zabroug resume
 
Ucaya power point1
Ucaya power point1Ucaya power point1
Ucaya power point1
 
Presentation2015solvex
Presentation2015solvexPresentation2015solvex
Presentation2015solvex
 
Angles pawer point 2 (1) real real 2
Angles pawer point 2 (1) real real 2Angles pawer point 2 (1) real real 2
Angles pawer point 2 (1) real real 2
 
Healthy Travel
Healthy TravelHealthy Travel
Healthy Travel
 
Careers_Trainee
Careers_TraineeCareers_Trainee
Careers_Trainee
 

Similar to First and follow

algorithm Unit 4
algorithm Unit 4 algorithm Unit 4
algorithm Unit 4
Monika Choudhery
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptx
Kokebe2
 
Bayes 6
Bayes 6Bayes 6
Bayes 6
uddingias
 
Elliptical curve cryptography
Elliptical curve cryptographyElliptical curve cryptography
Elliptical curve cryptography
Barani Tharan
 
Unit 4 jwfiles
Unit 4 jwfilesUnit 4 jwfiles
Unit 4 jwfiles
Nv Thejaswini
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Thirunavukarasu Mani
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Ketan Jani
 
2.3 Operations that preserve convexity & 2.4 Generalized inequalities
2.3 Operations that preserve convexity & 2.4 Generalized inequalities2.3 Operations that preserve convexity & 2.4 Generalized inequalities
2.3 Operations that preserve convexity & 2.4 Generalized inequalities
RyotaroTsukada
 
Truth, deduction, computation lecture g
Truth, deduction, computation   lecture gTruth, deduction, computation   lecture g
Truth, deduction, computation lecture g
Vlad Patryshev
 
Slope intercept form3
Slope intercept form3Slope intercept form3
Slope intercept form3
Ranson IB middle school
 
Slope intercept form2
Slope intercept form2Slope intercept form2
Slope intercept form2
Ranson IB middle school
 
CSE460 Lecture 2.pptx.pdf
CSE460 Lecture 2.pptx.pdfCSE460 Lecture 2.pptx.pdf
CSE460 Lecture 2.pptx.pdf
FarhanFaruk3
 
Pre-Cal 40S March 1, 2009
Pre-Cal 40S March 1, 2009Pre-Cal 40S March 1, 2009
Pre-Cal 40S March 1, 2009
Darren Kuropatwa
 
logarithmic, exponential, trigonometric functions and their graphs.ppt
logarithmic, exponential, trigonometric functions and their graphs.pptlogarithmic, exponential, trigonometric functions and their graphs.ppt
logarithmic, exponential, trigonometric functions and their graphs.ppt
YohannesAndualem1
 
April 7, 2014
April 7, 2014April 7, 2014
April 7, 2014
khyps13
 
Vectors and 3 d
Vectors and 3 dVectors and 3 d
Vectors and 3 d
NeoClassical
 
2.2 Graphs of First Degree Functions
2.2 Graphs of First Degree Functions2.2 Graphs of First Degree Functions
2.2 Graphs of First Degree Functions
math260
 
2 graphs of first degree functions x
2 graphs of first degree functions x2 graphs of first degree functions x
2 graphs of first degree functions x
Tzenma
 
Ch01
Ch01Ch01
11 graphs of first degree functions x
11 graphs of first degree functions x11 graphs of first degree functions x
11 graphs of first degree functions x
math260
 

Similar to First and follow (20)

algorithm Unit 4
algorithm Unit 4 algorithm Unit 4
algorithm Unit 4
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptx
 
Bayes 6
Bayes 6Bayes 6
Bayes 6
 
Elliptical curve cryptography
Elliptical curve cryptographyElliptical curve cryptography
Elliptical curve cryptography
 
Unit 4 jwfiles
Unit 4 jwfilesUnit 4 jwfiles
Unit 4 jwfiles
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
2.3 Operations that preserve convexity & 2.4 Generalized inequalities
2.3 Operations that preserve convexity & 2.4 Generalized inequalities2.3 Operations that preserve convexity & 2.4 Generalized inequalities
2.3 Operations that preserve convexity & 2.4 Generalized inequalities
 
Truth, deduction, computation lecture g
Truth, deduction, computation   lecture gTruth, deduction, computation   lecture g
Truth, deduction, computation lecture g
 
Slope intercept form3
Slope intercept form3Slope intercept form3
Slope intercept form3
 
Slope intercept form2
Slope intercept form2Slope intercept form2
Slope intercept form2
 
CSE460 Lecture 2.pptx.pdf
CSE460 Lecture 2.pptx.pdfCSE460 Lecture 2.pptx.pdf
CSE460 Lecture 2.pptx.pdf
 
Pre-Cal 40S March 1, 2009
Pre-Cal 40S March 1, 2009Pre-Cal 40S March 1, 2009
Pre-Cal 40S March 1, 2009
 
logarithmic, exponential, trigonometric functions and their graphs.ppt
logarithmic, exponential, trigonometric functions and their graphs.pptlogarithmic, exponential, trigonometric functions and their graphs.ppt
logarithmic, exponential, trigonometric functions and their graphs.ppt
 
April 7, 2014
April 7, 2014April 7, 2014
April 7, 2014
 
Vectors and 3 d
Vectors and 3 dVectors and 3 d
Vectors and 3 d
 
2.2 Graphs of First Degree Functions
2.2 Graphs of First Degree Functions2.2 Graphs of First Degree Functions
2.2 Graphs of First Degree Functions
 
2 graphs of first degree functions x
2 graphs of first degree functions x2 graphs of first degree functions x
2 graphs of first degree functions x
 
Ch01
Ch01Ch01
Ch01
 
11 graphs of first degree functions x
11 graphs of first degree functions x11 graphs of first degree functions x
11 graphs of first degree functions x
 

Recently uploaded

Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 

Recently uploaded (20)

Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 

First and follow

  • 1. Notes on First and Follow Written by Ashok Kumar Pachauri ITM Aligarh
  • 2. Computing Nullable Sets • Non-terminal X is Nullable only if the following constraints are satisfied (computed using iterative analysis) – base case: • if (X := ) then X is Nullable – inductive case: • if (X := ABC...) and A, B, C, ... are all Nullable then X is Nullable
  • 3. Computing First Sets • First(X) is computed iteratively – base case: • if T is a terminal symbol then First (T) = {T} – inductive case: • if X is a non-terminal and (X:= ABC...) then – First (X) = First (X) U First (ABC...) where First(ABC...) = F1 U F2 U F3 U ... and » F1 = First (A) » F2 = First (B), if A is Nullable » F3 = First (C), if A is Nullable & B is Nullable » ...
  • 4. Computing Follow Sets • Follow(X) is computed iteratively – base case: • initially, we assume nothing in particular follows X – (Follow (X) is initially { }) – inductive case: • if (Y := s1 X s2) for any strings s1, s2 then – Follow (X) = First (s2) U Follow (X) • if (Y := s1 X s2) for any strings s1, s2 then – Follow (X) = Follow(Y) U Follow (X), if s2 is Nullable
  • 5. building a predictive parser Z ::= X Y Z Z ::= d Y ::= c Y ::= X ::= a X ::= b Y e nullable first follow Z Y X
  • 6. building a predictive parser Z ::= X Y Z Z ::= d Y ::= c Y ::= X ::= a X ::= b Y e nullable first follow Z no Y yes X no base case
  • 7. building a predictive parser Z ::= X Y Z Z ::= d Y ::= c Y ::= X ::= a X ::= b Y e nullable first follow Z no Y yes X no after one round of induction, we realize we have reached a fixed point
  • 8. building a predictive parser Z ::= X Y Z Z ::= d Y ::= c Y ::= X ::= a X ::= b Y e nullable first follow Z no d Y yes c X no a,b base case (note, first of Y should include empty string)
  • 9. building a predictive parser Z ::= X Y Z Z ::= d Y ::= c Y ::= X ::= a X ::= b Y e nullable first follow Z no d,a,b Y yes c X no a,b after one round of induction, no fixed point
  • 10. building a predictive parser Z ::= X Y Z Z ::= d Y ::= c Y ::= X ::= a X ::= b Y e nullable first follow Z no d,a,b Y yes c X no a,b after two rounds of induction, no more changes ==> fixed point
  • 11. building a predictive parser Z ::= X Y Z Z ::= d Y ::= c Y ::= X ::= a X ::= b Y e nullable first follow Z no d,a,b { } Y yes c { } X no a,b { } base case
  • 12. building a predictive parser Z ::= X Y Z Z ::= d Y ::= c Y ::= X ::= a X ::= b Y e nullable first follow Z no d,a,b { } Y yes c e,d,a,b X no a,b c,d,a,b after one round of induction, no fixed point
  • 13. building a predictive parser Z ::= X Y Z Z ::= d Y ::= c Y ::= X ::= a X ::= b Y e nullable first follow Z no d,a,b { } Y yes c e,d,a,b X no a,b c,d,a,b after two rounds of induction, fixed point (but notice, computing Follow(X) before Follow (Y) would have required 3rd round)