SlideShare a Scribd company logo
Non-recursive predictive parsing
Our recursive descent parser encodes state information in its run-time stack, or call stack.Using
recursive procedure calls to implement a stack abstraction may not be particularly efficient.
This suggests other implementation methods:
• Explicit stack, hand-coded parser
• Stack-based, table-driven parser
Algorithm: Table-driven predictive parsing.
INPUT: A string w and a parsing table M for grammar G.
OUTPUT: If w is in L(G), a leftmost derivation of w; otherwise, an
error indication.
METHOD: Initially, the parser is in a configuration with w$ in the input buffer and the
start symbol S of G on top of the stack, above $. The program in uses the predictive
parsing table M to produce a predictive parse for the input.
Set I p to point to the first symbol of w;
Set X to the top stack symbol;
W h i le (X $) {/* stack is not empty */
If (X is a) pop the stack and advance ip;
Else if (X is a terminal) error Q;
Else if (M[X, a] is an error entry) error Q;
Else if (M[X, a] = X -> Y1Y2 •••Yk) {
Set X to the top stack symbol;
}
Note that the sentential forms in this derivation correspond to the input that has already
been matched (in column M A T C H E D) followed by the stack contents. The matched
input is shown only to highlight the correspondence. For the same reason, the top of the
stack is to the left; when we consider bottom-up parsing, it will be more natural to show
the top of the stack to the right. The input pointer points to the leftmost symbol of the
string in the INPUT column.
Non- recusive

More Related Content

What's hot

Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
Dr. Loganathan R
 
Assignment6
Assignment6Assignment6
Assignment6
Sunita Milind Dol
 
Questions typedef and macros
Questions typedef and macrosQuestions typedef and macros
Questions typedef and macros
Mohammed Sikander
 
Assignment10
Assignment10Assignment10
Assignment10
Sunita Milind Dol
 
Predictive parser
Predictive parserPredictive parser
Predictive parser
Jothi Lakshmi
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
Dr. Loganathan R
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
kinan keshkeh
 
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
Neil Mathew
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
Sabik T S
 
Assignment12
Assignment12Assignment12
Assignment12
Sunita Milind Dol
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
Dr. Loganathan R
 
Sql cheat sheet
Sql cheat sheetSql cheat sheet
Sql cheat sheet
Rajesh Nayudu
 
CP Handout#6
CP Handout#6CP Handout#6
CP Handout#6
trupti1976
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
ASHOK KUMAR REDDY
 
C language flowcharat
C language flowcharatC language flowcharat
C language flowcharat
cprogram
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using Stack
Soumen Santra
 

What's hot (20)

Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
 
Assignment6
Assignment6Assignment6
Assignment6
 
Questions typedef and macros
Questions typedef and macrosQuestions typedef and macros
Questions typedef and macros
 
Assignment10
Assignment10Assignment10
Assignment10
 
Predictive parser
Predictive parserPredictive parser
Predictive parser
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
 
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Loop Statements [5] M
Loop Statements [5] MLoop Statements [5] M
Loop Statements [5] M
 
week-11x
week-11xweek-11x
week-11x
 
week-18x
week-18xweek-18x
week-18x
 
Assignment12
Assignment12Assignment12
Assignment12
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
Sql cheat sheet
Sql cheat sheetSql cheat sheet
Sql cheat sheet
 
CP Handout#6
CP Handout#6CP Handout#6
CP Handout#6
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
C language flowcharat
C language flowcharatC language flowcharat
C language flowcharat
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using Stack
 

Similar to Non- recusive

Parsing
ParsingParsing
push down automata
push down automatapush down automata
push down automata
Christopher Chizoba
 
stack (1).pptx
stack (1).pptxstack (1).pptx
stack (1).pptx
CrazyKiller4
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
Tanzeela_Hussain
 
Stacks
StacksStacks
lecture10trsgfchjvxgfzfdchgdchgcgshyjh.ppt
lecture10trsgfchjvxgfzfdchgdchgcgshyjh.pptlecture10trsgfchjvxgfzfdchgdchgcgshyjh.ppt
lecture10trsgfchjvxgfzfdchgdchgcgshyjh.ppt
partho5958
 
PARSING.ppt
PARSING.pptPARSING.ppt
PARSING.ppt
ayyankhanna6480086
 
LL(1) parsing
LL(1) parsingLL(1) parsing
LL(1) parsing
KHYATI PATEL
 
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptxSTACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
KALPANAC20
 
Stacks
StacksStacks
Stacks
Sadaf Ismail
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo
JinTaek Seo
 
Theory of automata and formal language lab manual
Theory of automata and formal language lab manualTheory of automata and formal language lab manual
Theory of automata and formal language lab manual
Nitesh Dubey
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
maamir farooq
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
A. S. M. Shafi
 
Data Structures: Stacks (Part 1)
Data Structures: Stacks (Part 1)Data Structures: Stacks (Part 1)
Data Structures: Stacks (Part 1)Ramachandra Adiga G
 
Unit iv
Unit ivUnit iv
Unit iv
TPLatchoumi
 
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
haaamin01
 
11CS10033.pptx
11CS10033.pptx11CS10033.pptx
11CS10033.pptx
ssuser0be977
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 

Similar to Non- recusive (20)

Parsing
ParsingParsing
Parsing
 
push down automata
push down automatapush down automata
push down automata
 
stack (1).pptx
stack (1).pptxstack (1).pptx
stack (1).pptx
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
 
Stacks
StacksStacks
Stacks
 
lecture10trsgfchjvxgfzfdchgdchgcgshyjh.ppt
lecture10trsgfchjvxgfzfdchgdchgcgshyjh.pptlecture10trsgfchjvxgfzfdchgdchgcgshyjh.ppt
lecture10trsgfchjvxgfzfdchgdchgcgshyjh.ppt
 
PARSING.ppt
PARSING.pptPARSING.ppt
PARSING.ppt
 
LL(1) parsing
LL(1) parsingLL(1) parsing
LL(1) parsing
 
Cd2 [autosaved]
Cd2 [autosaved]Cd2 [autosaved]
Cd2 [autosaved]
 
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptxSTACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
STACK AND ITS OPERATIONS IN DATA STRUCTURES.pptx
 
Stacks
StacksStacks
Stacks
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo
 
Theory of automata and formal language lab manual
Theory of automata and formal language lab manualTheory of automata and formal language lab manual
Theory of automata and formal language lab manual
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Data Structures: Stacks (Part 1)
Data Structures: Stacks (Part 1)Data Structures: Stacks (Part 1)
Data Structures: Stacks (Part 1)
 
Unit iv
Unit ivUnit iv
Unit iv
 
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
 
11CS10033.pptx
11CS10033.pptx11CS10033.pptx
11CS10033.pptx
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 

More from alldesign

Vb lecture
Vb lectureVb lecture
Vb lecture
alldesign
 
Vb lecture notes
Vb lecture notesVb lecture notes
Vb lecture notes
alldesign
 
Color model
Color modelColor model
Color model
alldesign
 
Computer graphics circle
Computer graphics   circleComputer graphics   circle
Computer graphics circle
alldesign
 
Getstart graphic
Getstart graphicGetstart graphic
Getstart graphic
alldesign
 
Image types,raster and vector graphics
Image types,raster and vector graphicsImage types,raster and vector graphics
Image types,raster and vector graphics
alldesign
 
Graphics c
Graphics cGraphics c
Graphics c
alldesign
 
Image types,raster and vector graphics
Image types,raster and vector graphicsImage types,raster and vector graphics
Image types,raster and vector graphics
alldesign
 
Graphics display devices
Graphics display devicesGraphics display devices
Graphics display devices
alldesign
 
Circles graphic
Circles graphicCircles graphic
Circles graphic
alldesign
 
Cg applications
Cg applicationsCg applications
Cg applications
alldesign
 
Types of cards
Types of cardsTypes of cards
Types of cards
alldesign
 
External types of hardware
External types of hardwareExternal types of hardware
External types of hardware
alldesign
 
Devices of computer
Devices of computerDevices of computer
Devices of computer
alldesign
 
Internal computer hardware
Internal computer hardwareInternal computer hardware
Internal computer hardware
alldesign
 
Computer hardware
Computer hardwareComputer hardware
Computer hardware
alldesign
 
Types of slots
Types of slotsTypes of slots
Types of slots
alldesign
 
Application of computer graphic
Application of computer graphicApplication of computer graphic
Application of computer graphic
alldesign
 
What is computer graphics
What is computer graphicsWhat is computer graphics
What is computer graphics
alldesign
 
Types of rom
Types of romTypes of rom
Types of rom
alldesign
 

More from alldesign (20)

Vb lecture
Vb lectureVb lecture
Vb lecture
 
Vb lecture notes
Vb lecture notesVb lecture notes
Vb lecture notes
 
Color model
Color modelColor model
Color model
 
Computer graphics circle
Computer graphics   circleComputer graphics   circle
Computer graphics circle
 
Getstart graphic
Getstart graphicGetstart graphic
Getstart graphic
 
Image types,raster and vector graphics
Image types,raster and vector graphicsImage types,raster and vector graphics
Image types,raster and vector graphics
 
Graphics c
Graphics cGraphics c
Graphics c
 
Image types,raster and vector graphics
Image types,raster and vector graphicsImage types,raster and vector graphics
Image types,raster and vector graphics
 
Graphics display devices
Graphics display devicesGraphics display devices
Graphics display devices
 
Circles graphic
Circles graphicCircles graphic
Circles graphic
 
Cg applications
Cg applicationsCg applications
Cg applications
 
Types of cards
Types of cardsTypes of cards
Types of cards
 
External types of hardware
External types of hardwareExternal types of hardware
External types of hardware
 
Devices of computer
Devices of computerDevices of computer
Devices of computer
 
Internal computer hardware
Internal computer hardwareInternal computer hardware
Internal computer hardware
 
Computer hardware
Computer hardwareComputer hardware
Computer hardware
 
Types of slots
Types of slotsTypes of slots
Types of slots
 
Application of computer graphic
Application of computer graphicApplication of computer graphic
Application of computer graphic
 
What is computer graphics
What is computer graphicsWhat is computer graphics
What is computer graphics
 
Types of rom
Types of romTypes of rom
Types of rom
 

Recently uploaded

MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 

Recently uploaded (20)

MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 

Non- recusive

  • 1. Non-recursive predictive parsing Our recursive descent parser encodes state information in its run-time stack, or call stack.Using recursive procedure calls to implement a stack abstraction may not be particularly efficient. This suggests other implementation methods: • Explicit stack, hand-coded parser • Stack-based, table-driven parser Algorithm: Table-driven predictive parsing. INPUT: A string w and a parsing table M for grammar G. OUTPUT: If w is in L(G), a leftmost derivation of w; otherwise, an error indication. METHOD: Initially, the parser is in a configuration with w$ in the input buffer and the start symbol S of G on top of the stack, above $. The program in uses the predictive parsing table M to produce a predictive parse for the input. Set I p to point to the first symbol of w; Set X to the top stack symbol; W h i le (X $) {/* stack is not empty */ If (X is a) pop the stack and advance ip;
  • 2. Else if (X is a terminal) error Q; Else if (M[X, a] is an error entry) error Q; Else if (M[X, a] = X -> Y1Y2 •••Yk) { Set X to the top stack symbol; } Note that the sentential forms in this derivation correspond to the input that has already been matched (in column M A T C H E D) followed by the stack contents. The matched input is shown only to highlight the correspondence. For the same reason, the top of the stack is to the left; when we consider bottom-up parsing, it will be more natural to show the top of the stack to the right. The input pointer points to the leftmost symbol of the string in the INPUT column.