predictive parsing and ll(1) - compiler design - dr. d. p. sharma - nitk surathkal by wahid311
DESCRIPTION
Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311TRANSCRIPT
![Page 1: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/1.jpg)
1
Nonrecursive Predictive Nonrecursive Predictive ParsingParsingNonrecursive Predictive Nonrecursive Predictive ParsingParsing It is possible to build a
nonrecursive predictive parser
This is done by maintaining an explicit stack
![Page 2: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/2.jpg)
2
Nonrecursive Predictive Nonrecursive Predictive ParsingParsingNonrecursive Predictive Nonrecursive Predictive ParsingParsing It is possible to build a
nonrecursive predictive parser
This is done by maintaining an explicit stack
![Page 3: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/3.jpg)
3
Table-driven ParsersTable-driven ParsersTable-driven ParsersTable-driven Parsers The nonrecursive LL(1)
parser looks up the production to apply by looking up a parsing table
![Page 4: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/4.jpg)
4
Table-driven ParsersTable-driven ParsersTable-driven ParsersTable-driven ParsersLL(1) table: One dimension for current
non-terminal to expand One dimension for next token Table entry contains one
production
![Page 5: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/5.jpg)
5
Table-driven ParsersTable-driven ParsersTable-driven ParsersTable-driven ParsersLL(1) table: One dimension for current
non-terminal to expand
One dimension for next token
Table entry contains one production
![Page 6: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/6.jpg)
6
Table-driven ParsersTable-driven ParsersTable-driven ParsersTable-driven ParsersLL(1) table: One dimension for current
non-terminal to expand One dimension for next token Table entry contains one
production
![Page 7: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/7.jpg)
7
Consider the expression grammar
1 E → T E' 2 E' → + T E' 3 | 4 T → F T' 5 T' → * F T' 6 | 7 F → ( E )8 | id
![Page 8: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/8.jpg)
8
Predictive Parsing TablePredictive Parsing TablePredictive Parsing TablePredictive Parsing Tableid + * ( ) $
E E →TE' E →TE'
E' E' → +TE'
E' → E' →
T T →FT' T →FT'
T' T' → T →*FT' T' → T' →
F F → id F →(E )
Rows for current non-terminal to expandColumns for next token
![Page 9: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/9.jpg)
9
Predictive Parsing TablePredictive Parsing TablePredictive Parsing TablePredictive Parsing Tableid + * ( ) $
E E →TE' E →TE'
E' E' → +TE'
E' → E' →
T T →FT' T →FT'
T' T' → T →*FT' T' → T' →
F F → id F →(E )
Table entries are productionsBlank entries are errors
![Page 10: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/10.jpg)
10
Predictive ParsersPredictive ParsersPredictive ParsersPredictive Parsers The predictive parser uses
an explicit stack to keep track of pending non-terminals
It can thus be implemented without recursion.
![Page 11: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/11.jpg)
11
Predictive ParsersPredictive ParsersPredictive ParsersPredictive Parsers The predictive parser uses
an explicit stack to keep track of pending non-terminals
It can thus be implemented without recursion.
![Page 12: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/12.jpg)
12
Predictive ParsersPredictive ParsersPredictive ParsersPredictive Parsers
a + b $
Predictive parser
stackXYZ$
Parsing table M
input
output
![Page 13: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/13.jpg)
13
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm The input buffer contains
the string to be parsed; $ is the end-of-input marker
The stack contains a sequence of grammar symbols
![Page 14: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/14.jpg)
14
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
Initially, the stack contains the start symbol of the grammar on the top of $.
![Page 15: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/15.jpg)
15
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
The parser is controlled by a program that behaves as follows:
![Page 16: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/16.jpg)
16
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
The program considers X, the symbol on top of the stack, and a, the current input symbol.
![Page 17: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/17.jpg)
17
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
These two symbols, X and a determine the action of the parser.
There are three possibilities.
![Page 18: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/18.jpg)
18
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
These two symbols, X and a determine the action of the parser.
There are three possibilities.
![Page 19: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/19.jpg)
19
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
1. X a $, the parser halts and annouces successful completion.
![Page 20: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/20.jpg)
20
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
2. X a $the parser pops X off the stack and advances input pointer to next input symbol
![Page 21: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/21.jpg)
21
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
3. If X is a nonterminal, the program consults entry M[X,a] of parsing table M.
![Page 22: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/22.jpg)
22
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
If the entry is a production M[X,a] = {X → UVW }the parser replaces X on top of the stack by WVU (with U on top).
![Page 23: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/23.jpg)
23
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmAs output, the parser just prints the production used: X → UVW
However, any other code could be executed here.
![Page 24: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/24.jpg)
24
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
If M[X,a] =error, the parser calls an error recovery routine
![Page 25: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/25.jpg)
25
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm
Example:
Let’s parse the input string
id+ididusing the nonrecursive LL(1) parser
![Page 26: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/26.jpg)
26
id
E
+ id id
$
$
stack Parsing Table M
![Page 27: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/27.jpg)
27
Predictive Parsing TablePredictive Parsing TablePredictive Parsing TablePredictive Parsing Table
id + * ( ) $
E E →TE' E →TE'
E' E' → +TE'
E' → E' →
T T →FT' T →FT'
T' T' → T →*FT' T' → T' →
F F → id F →(E )
![Page 28: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/28.jpg)
28
id
E
+ id id
$
$
stack Parsing Table M
E →T E'
![Page 29: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/29.jpg)
29
id + id id
$
$
stack Parsing Table M
T →
TE'
F T'
![Page 30: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/30.jpg)
30
T'
id + id id
$
$
stack Parsing Table M
→
E'
F
F id
![Page 31: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/31.jpg)
31
T'
id + id id
$
$
stack Parsing Table M
E'
id
![Page 32: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/32.jpg)
32
T'
+ id id
$
$
stack Parsing Table M
→
E'
T'
id
![Page 33: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/33.jpg)
33
+ id id
$
$
stack Parsing Table M→
E'
E' +
id
E'T
![Page 34: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/34.jpg)
34
+ id id
$
$
stack Parsing Table M
E'
+
id
T
![Page 35: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/35.jpg)
35
Stack Input Ouput$E id+idid$
$E' T id+idid$ E →TE'
$E' T' F id+idid$ T →FT'$E'T' id id+idid$ F → id
$E' T' +idid$$E' +idid$ T' →$E' T + +idid$ E' → +TE'
![Page 36: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/36.jpg)
36
Stack Input Ouput$E' T idid$ $E' T' F idid$ T →FT'$E' T' id idid$ F → id$E' T' id$$E' T' F id$ T → FT'$E' T' F id$$E'T' id id$ F → id
![Page 37: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/37.jpg)
37
Stack Input Ouput
$E' T' $ $E' $ T' →$ $ E' →
![Page 38: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/38.jpg)
38
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm Note that productions output
are tracing out a lefmost derivation
The grammar symbols on the stack make up left-sentential forms
![Page 39: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/39.jpg)
39
LL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing AlgorithmLL(1) Parsing Algorithm Note that productions output
are tracing out a lefmost derivation
The grammar symbols on the stack make up left-sentential forms
![Page 40: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/40.jpg)
40
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
Top-down parsing expands a parse tree from the start symbol to the leaves
Always expand the leftmost non-terminal
![Page 41: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/41.jpg)
41
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
Top-down parsing expands a parse tree from the start symbol to the leaves
Always expand the leftmost non-terminal
![Page 42: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/42.jpg)
42
id+idid
E
T E'
F
id
T'
E'T+
and so on ....
![Page 43: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/43.jpg)
43
E
T E'
F
id
T'
E'T+
The leaves at any point form a stringA
![Page 44: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/44.jpg)
44
E
T E'
F
id
T'
E'T+
only contains terminals
![Page 45: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/45.jpg)
45
E
T E'
F
id
T'
+ E'Tid + id id b
input string is bThe prefix matchesNext token is b
![Page 46: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/46.jpg)
46
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction Consider the state
S → Awith b the next token and we are trying to match b
There are two possibilities
![Page 47: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/47.jpg)
47
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction Consider the state
S → Awith b the next token and we are trying to match b
There are two possibilities
![Page 48: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/48.jpg)
48
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
1. b belongs to an expansion of A
Any A → can be used if b can start a string derived from
![Page 49: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/49.jpg)
49
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
1. b belongs to an expansion of A
Any A → can be used if b can start a string derived from
![Page 50: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/50.jpg)
50
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
In this case we say that b FIRST()
![Page 51: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/51.jpg)
51
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
2. b does not belong to an expansion of A
Expansion of A is empty, i.e.,
A → and b belongs an expansion of , e.g., b
![Page 52: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/52.jpg)
52
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
2. b does not belong to an expansion of A
Expansion of A is empty, i.e.,
A → and b belongs an expansion of , e.g., b
![Page 53: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/53.jpg)
53
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
which means that b can appear after A in a derivation of the form S → Ab
![Page 54: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/54.jpg)
54
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
We say that b FOLLOW(A)
![Page 55: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/55.jpg)
55
LL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table ConstructionLL(1) Table Construction
Any A → can be used if expands to
We say that FIRST(A) in this case
![Page 56: Predictive Parsing and LL(1) - Compiler Design - Dr. D. P. Sharma - NITK Surathkal by wahid311](https://reader036.vdocuments.us/reader036/viewer/2022081518/551758234979592e228b4906/html5/thumbnails/56.jpg)
56
ComputingComputing FIRST FIRST Sets SetsComputingComputing FIRST FIRST Sets Sets
DefinitionFIRST(X) =
{ b | X → ba }
{ | X → }