Problem 14 Consider the following grammar for postfix expressions. (T.pdf

Problem 14: Consider the following grammar for postfix expressions. (The symbol EMPTY in the grammar means that we produce an empty string.) Postfix ::= Number Postfix2 Postfix2 ::= Postfix BinOp Postfix2 | UnOp Postfix2 | EMPTY BinOp ::= '+' | '-' | '*' | '/' UnOp ::= 'neg' | 'sqrt' Number ::= any valid Java double Part (a Draw the parse tree (not the expression tree) for the expression "4 5 + sqrt 3 *" Part (b)Explain why the abstract syntax tree for the expression "4 5 + sqrt 3 *" is the same as it was for the previous problem, even though the grammar has changed. Part (c) Explain why you can write a recursive descent parser for this grammar. Part (d) Write the Java code for the getPostfix() and getPostfix2() methods that would implement a recognizing parser (assume the usual interface to the Tokenizer). private static void getPostfix(Tokenizer tokens) { }//getPostfix() private static void getPostfix2(Tokenizer tokens) { }//getPostfix2().

Problem 14: Consider the following grammar for postfix expressions. (The symbol EMPTY in
the grammar means that we produce an empty string.) Postfix ::= Number Postfix2
Postfix2 ::= Postfix BinOp Postfix2 | UnOp Postfix2 | EMPTY BinOp ::=
'+' | '-' | '*' | '/' UnOp ::= 'neg' | 'sqrt' Number ::= any valid Java double Part (a Draw
the parse tree (not the expression tree) for the expression "4 5 + sqrt 3 *" Part (b)Explain why
the abstract syntax tree for the expression "4 5 + sqrt 3 *" is the same as it was for the previous
problem, even though the grammar has changed. Part (c) Explain why you can write a recursive
descent parser for this grammar. Part (d) Write the Java code for the getPostfix() and
getPostfix2() methods that would implement a recognizing parser (assume the usual interface to
the Tokenizer). private static void getPostfix(Tokenizer tokens) { }//getPostfix()
private static void getPostfix2(Tokenizer tokens) { }//getPostfix2()

Más contenido relacionado

Similar a Problem 14 Consider the following grammar for postfix expressions. (T.pdf

X86 assembly & GDBX86 assembly & GDB
X86 assembly & GDBJian-Yu Li
494 vistas37 diapositivas
Topic 2_revised.pptxTopic 2_revised.pptx
Topic 2_revised.pptxJAYAPRIYAR7
2 vistas70 diapositivas
OpenMPOpenMP
OpenMPZongYing Lyu
585 vistas21 diapositivas

Similar a Problem 14 Consider the following grammar for postfix expressions. (T.pdf(20)

X86 assembly & GDBX86 assembly & GDB
X86 assembly & GDB
Jian-Yu Li494 vistas
Topic 2_revised.pptxTopic 2_revised.pptx
Topic 2_revised.pptx
JAYAPRIYAR72 vistas
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
Programming Homework Help49 vistas
OpenMPOpenMP
OpenMP
ZongYing Lyu585 vistas
6th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...6th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
6th Semester (Dec-2015; Jan-2016) Computer Science and Information Science En...
BGS Institute of Technology, Adichunchanagiri University (ACU)1K vistas
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet Filters
Kernel TLV6.4K vistas
Computer Network Assignment HelpComputer Network Assignment Help
Computer Network Assignment Help
Computer Network Assignment Help32 vistas
AdobeAdobe
Adobe
manpreetduggal88590 vistas
The Stack and Buffer OverflowsThe Stack and Buffer Overflows
The Stack and Buffer Overflows
UTD Computer Security Group159 vistas
5th semester Computer Science and Information Science Engg (2013 December) Qu...5th semester Computer Science and Information Science Engg (2013 December) Qu...
5th semester Computer Science and Information Science Engg (2013 December) Qu...
BGS Institute of Technology, Adichunchanagiri University (ACU)40.5K vistas
Faster Python, FOSDEMFaster Python, FOSDEM
Faster Python, FOSDEM
Victor Stinner1.1K vistas
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
Ganesh Samarthyam8.4K vistas
Shell Script TutorialShell Script Tutorial
Shell Script Tutorial
Quang Minh Đoàn1.3K vistas
Exploitation Crash CourseExploitation Crash Course
Exploitation Crash Course
UTD Computer Security Group110 vistas
cp05.pptxcp05.pptx
cp05.pptx
RehmanRasheed33 vistas
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
Muhammad Sikandar Mustafa719 vistas

Más de kishorchelani123(20)

Último

Universe revised.pdfUniverse revised.pdf
Universe revised.pdfDrHafizKosar
84 vistas26 diapositivas
STERILITY TEST.pptxSTERILITY TEST.pptx
STERILITY TEST.pptxAnupkumar Sharma
102 vistas9 diapositivas
ICANNICANN
ICANNRajaulKarim20
57 vistas13 diapositivas
Dance KS5 BreakdownDance KS5 Breakdown
Dance KS5 BreakdownWestHatch
52 vistas2 diapositivas
Narration lesson plan.docxNarration lesson plan.docx
Narration lesson plan.docxTARIQ KHAN
90 vistas11 diapositivas

Último(20)

Universe revised.pdfUniverse revised.pdf
Universe revised.pdf
DrHafizKosar84 vistas
STERILITY TEST.pptxSTERILITY TEST.pptx
STERILITY TEST.pptx
Anupkumar Sharma102 vistas
ICANNICANN
ICANN
RajaulKarim2057 vistas
Dance KS5 BreakdownDance KS5 Breakdown
Dance KS5 Breakdown
WestHatch52 vistas
Narration lesson plan.docxNarration lesson plan.docx
Narration lesson plan.docx
TARIQ KHAN90 vistas
Women from Hackney’s History: Stoke Newington by Sue DoeWomen from Hackney’s History: Stoke Newington by Sue Doe
Women from Hackney’s History: Stoke Newington by Sue Doe
History of Stoke Newington103 vistas
Material del tarjetero LEES Travesías.docxMaterial del tarjetero LEES Travesías.docx
Material del tarjetero LEES Travesías.docx
Norberto Millán Muñoz57 vistas
ACTIVITY BOOK key water sports.pptxACTIVITY BOOK key water sports.pptx
ACTIVITY BOOK key water sports.pptx
Mar Caston Palacio132 vistas
Education and Diversity.pptxEducation and Diversity.pptx
Education and Diversity.pptx
DrHafizKosar56 vistas
231112 (WR) v1  ChatGPT OEB 2023.pdf231112 (WR) v1  ChatGPT OEB 2023.pdf
231112 (WR) v1 ChatGPT OEB 2023.pdf
WilfredRubens.com100 vistas
Drama KS5 BreakdownDrama KS5 Breakdown
Drama KS5 Breakdown
WestHatch50 vistas
Psychology KS5Psychology KS5
Psychology KS5
WestHatch53 vistas
CWP_23995_2013_17_11_2023_FINAL_ORDER.pdfCWP_23995_2013_17_11_2023_FINAL_ORDER.pdf
CWP_23995_2013_17_11_2023_FINAL_ORDER.pdf
SukhwinderSingh895865467 vistas
Sociology KS5Sociology KS5
Sociology KS5
WestHatch50 vistas
Classification of crude drugs.pptxClassification of crude drugs.pptx
Classification of crude drugs.pptx
GayatriPatra1449 vistas
Narration  ppt.pptxNarration  ppt.pptx
Narration ppt.pptx
TARIQ KHAN62 vistas
Nico Baumbach IMR Media ComponentNico Baumbach IMR Media Component
Nico Baumbach IMR Media Component
InMediaRes1186 vistas

Problem 14 Consider the following grammar for postfix expressions. (T.pdf

  • 1. Problem 14: Consider the following grammar for postfix expressions. (The symbol EMPTY in the grammar means that we produce an empty string.) Postfix ::= Number Postfix2 Postfix2 ::= Postfix BinOp Postfix2 | UnOp Postfix2 | EMPTY BinOp ::= '+' | '-' | '*' | '/' UnOp ::= 'neg' | 'sqrt' Number ::= any valid Java double Part (a Draw the parse tree (not the expression tree) for the expression "4 5 + sqrt 3 *" Part (b)Explain why the abstract syntax tree for the expression "4 5 + sqrt 3 *" is the same as it was for the previous problem, even though the grammar has changed. Part (c) Explain why you can write a recursive descent parser for this grammar. Part (d) Write the Java code for the getPostfix() and getPostfix2() methods that would implement a recognizing parser (assume the usual interface to the Tokenizer). private static void getPostfix(Tokenizer tokens) { }//getPostfix() private static void getPostfix2(Tokenizer tokens) { }//getPostfix2()