SlideShare a Scribd company logo
1 of 2
Download to read offline
It is a simple program that that parses a simple expression grammar.
The grammar:
P ---> E '$'
E ---> T { ('+' '-') T }
T ---> F { ('/' '*') F }
F ---> '(' E ')' | digit | letter or in BNF
P ---> E '$'
E ---> E + T | E - T | T
T ---> T * F | T / F | F
F ---> '(' E ')' | digit | letter
Your task is to modify the code to add exponentiation and modulus operations
To add these functions we will change the Grammar to be the following:
P ---> E '$'
E ---> E + T | E - T | T
T ---> T * F | T / F | F
F ---> P ^ F | P
P ---> '(' E ')' | digit | letter
The grammars are very similar but the new grammar but has a a minor change to TERM for
modulus a rewrite of FACTOR to handle exponent operation and a completely new method
called PRIMARY that does what the old FACTOR did
To add the modulus you will need to add the modulus operator '%' character
To add the power (exponentiation) operation you will need to again add a character ('^') and then
rewrite the FACTOR NEW method for PRIMARY Comment your code. You should add a
comment ALL the line you add or modify (required) You must use the given code and you are to
change as little as possible (don't rewrite the whole thing or add any additional functionality)
______________________________________________________________________________
________________________________________________________

More Related Content

More from ColinjSWDavidsonn

More from ColinjSWDavidsonn (20)

In a particular hospital- 6 newborn babies were delivered yesterday- H.pdf
In a particular hospital- 6 newborn babies were delivered yesterday- H.pdfIn a particular hospital- 6 newborn babies were delivered yesterday- H.pdf
In a particular hospital- 6 newborn babies were delivered yesterday- H.pdf
 
In Chapter 8 you were introduced to the water-soluble vitamins- includ (1).pdf
In Chapter 8 you were introduced to the water-soluble vitamins- includ (1).pdfIn Chapter 8 you were introduced to the water-soluble vitamins- includ (1).pdf
In Chapter 8 you were introduced to the water-soluble vitamins- includ (1).pdf
 
In Chapter 12- you learned about the distribution and marketing channe.pdf
In Chapter 12- you learned about the distribution and marketing channe.pdfIn Chapter 12- you learned about the distribution and marketing channe.pdf
In Chapter 12- you learned about the distribution and marketing channe.pdf
 
In detail- please discuss the technical structure of the Customs Tarif.pdf
In detail- please discuss the technical structure of the Customs Tarif.pdfIn detail- please discuss the technical structure of the Customs Tarif.pdf
In detail- please discuss the technical structure of the Customs Tarif.pdf
 
In an experiment of rolling a die twce Lel x be random variable to be.pdf
In an experiment of rolling a die twce Lel x be random variable to be.pdfIn an experiment of rolling a die twce Lel x be random variable to be.pdf
In an experiment of rolling a die twce Lel x be random variable to be.pdf
 
In a school- 16- of the students have seen a school counselor about an.pdf
In a school- 16- of the students have seen a school counselor about an.pdfIn a school- 16- of the students have seen a school counselor about an.pdf
In a school- 16- of the students have seen a school counselor about an.pdf
 
In a Poisson distribution- -2-00- (Round your answers to 4 decimal pla.pdf
In a Poisson distribution- -2-00- (Round your answers to 4 decimal pla.pdfIn a Poisson distribution- -2-00- (Round your answers to 4 decimal pla.pdf
In a Poisson distribution- -2-00- (Round your answers to 4 decimal pla.pdf
 
it ingents ford It tacks cell watlls Question 4 Bictaterally symimetri.pdf
it ingents ford It tacks cell watlls Question 4 Bictaterally symimetri.pdfit ingents ford It tacks cell watlls Question 4 Bictaterally symimetri.pdf
it ingents ford It tacks cell watlls Question 4 Bictaterally symimetri.pdf
 
Is this x-lined dominant or recessive inheritance- Write all possible.pdf
Is this x-lined dominant or recessive inheritance- Write all possible.pdfIs this x-lined dominant or recessive inheritance- Write all possible.pdf
Is this x-lined dominant or recessive inheritance- Write all possible.pdf
 
Is the study experimental- observational- or niether- 7) A political p.pdf
Is the study experimental- observational- or niether- 7) A political p.pdfIs the study experimental- observational- or niether- 7) A political p.pdf
Is the study experimental- observational- or niether- 7) A political p.pdf
 
Is Ethnicity a Foreign Concept-.pdf
Is Ethnicity a Foreign Concept-.pdfIs Ethnicity a Foreign Concept-.pdf
Is Ethnicity a Foreign Concept-.pdf
 
is arguably the most important factor currently shaping the world econ.pdf
is arguably the most important factor currently shaping the world econ.pdfis arguably the most important factor currently shaping the world econ.pdf
is arguably the most important factor currently shaping the world econ.pdf
 
Introduction to Parallel Computing Assignment.pdf
Introduction to Parallel Computing  Assignment.pdfIntroduction to Parallel Computing  Assignment.pdf
Introduction to Parallel Computing Assignment.pdf
 
Interrelationships of the financial statements- please in your own wor.pdf
Interrelationships of the financial statements- please in your own wor.pdfInterrelationships of the financial statements- please in your own wor.pdf
Interrelationships of the financial statements- please in your own wor.pdf
 
Internal users of accounting information would not include A- officers.pdf
Internal users of accounting information would not include A- officers.pdfInternal users of accounting information would not include A- officers.pdf
Internal users of accounting information would not include A- officers.pdf
 
int a-0- for {i-0-i-N-i++){ for (j-N-j-i-j){ }a-a+i+j- -} T(n)-.pdf
int a-0- for {i-0-i-N-i++){ for (j-N-j-i-j){ }a-a+i+j- -} T(n)-.pdfint a-0- for {i-0-i-N-i++){ for (j-N-j-i-j){ }a-a+i+j- -} T(n)-.pdf
int a-0- for {i-0-i-N-i++){ for (j-N-j-i-j){ }a-a+i+j- -} T(n)-.pdf
 
Insurance protects and safeguards assets from the financial effects of.pdf
Insurance protects and safeguards assets from the financial effects of.pdfInsurance protects and safeguards assets from the financial effects of.pdf
Insurance protects and safeguards assets from the financial effects of.pdf
 
Insulin (a peptide hormone) stimulates the uptake glucose blood by act.pdf
Insulin (a peptide hormone) stimulates the uptake glucose blood by act.pdfInsulin (a peptide hormone) stimulates the uptake glucose blood by act.pdf
Insulin (a peptide hormone) stimulates the uptake glucose blood by act.pdf
 
INSTRuctions- Rost the fellewing jeurnal entries te the ledrer account.pdf
INSTRuctions- Rost the fellewing jeurnal entries te the ledrer account.pdfINSTRuctions- Rost the fellewing jeurnal entries te the ledrer account.pdf
INSTRuctions- Rost the fellewing jeurnal entries te the ledrer account.pdf
 
Insert a VLOOKUP function in cell C5 to display the ring cos for the f.pdf
Insert a VLOOKUP function in cell C5 to display the ring cos for the f.pdfInsert a VLOOKUP function in cell C5 to display the ring cos for the f.pdf
Insert a VLOOKUP function in cell C5 to display the ring cos for the f.pdf
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

It is a simple program that that parses a simple expression grammar- T.pdf

  • 1. It is a simple program that that parses a simple expression grammar. The grammar: P ---> E '$' E ---> T { ('+' '-') T } T ---> F { ('/' '*') F } F ---> '(' E ')' | digit | letter or in BNF P ---> E '$' E ---> E + T | E - T | T T ---> T * F | T / F | F F ---> '(' E ')' | digit | letter Your task is to modify the code to add exponentiation and modulus operations To add these functions we will change the Grammar to be the following: P ---> E '$' E ---> E + T | E - T | T T ---> T * F | T / F | F F ---> P ^ F | P P ---> '(' E ')' | digit | letter The grammars are very similar but the new grammar but has a a minor change to TERM for modulus a rewrite of FACTOR to handle exponent operation and a completely new method called PRIMARY that does what the old FACTOR did To add the modulus you will need to add the modulus operator '%' character To add the power (exponentiation) operation you will need to again add a character ('^') and then rewrite the FACTOR NEW method for PRIMARY Comment your code. You should add a comment ALL the line you add or modify (required) You must use the given code and you are to change as little as possible (don't rewrite the whole thing or add any additional functionality)