Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Compiler Design Project 1: Implement a predictive parser for the example expression grammar 1. Introduction Implement a predictive parser for the example expression grammar. You

Compiler Design Project 1: Implement a predictive parser for the example expression grammar

1. Introduction Implement a predictive parser for the example expression grammar. You need to construct an abstract syntax tree for input expressions. Emit the abstract syntax tree for an input expression in preorder.

::= ::= + | - | ::= * | / | ::= number | id

2. Input-Output specification Input : "input.txt" file that contains expressions - Input expressions only contain variables with a single character alphabet (like a, b, c, x, y, not like var1, length) - Input expressions may contain multiple digit number (like 150, 20, 293...) - Input expression may contains empty spaces within an expression (like 5 +10-x...) - Input expression does not contain brackets - Each expression is separated with a new line character (' ') Output : "output.txt" file that should contain results for each expression in the input file - For a syntactically incorrect expression, print "incorrect syntax" - For a syntactically correct expression, print the syntax tree for the expression in preorder (ex. *+234)

Input, output file example [input.txt] x-2*y a + 35 - b 10+*5 [output.txt] -x*2y -+a35b incorrect syntax

Please help!!!

Thanks a lot!!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Theory And Applications 27th Australasian Database Conference Adc 20 Sydney Nsw September 28 29 20 Proceedings Lncs 9877

Authors: Muhammad Aamir Cheema ,Wenjie Zhang ,Lijun Chang

1st Edition

3319469215, 978-3319469218

More Books

Students also viewed these Databases questions

Question

What does the start( ) method defined by Thread do?

Answered: 1 week ago