Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

E i = T | T + E | T : = N | N * * T | N : = D | -

Ei=T|T+E|
T:=N|N**T|
N:=D|-D|
D:=0|1|2|3|4|5|6|7|8|9|
Where E,T,N and D are non-terminals, and E is the start symbol. The +,?**--,0,1,2,3,4,5,6,7,8,9 are the terminals. The "||" used in the grammar is neither terminal or non-terminal, simply interpret it as "or" in English.
Implement a front-end recursive-descent parser in Golang language that accepts strings from standard input (one per line) until EOF and determines whether each string is in the language defined by this grammar. First, develop a Scanner part into your program that leaves out the whitespace(s) of the input string and creates a list of lexical units to be parsed. Your program then should validate if each of the lexical units are lexemes (valid lexical units) according to the grammar (Section 2).
Hints: In Golang, the Fields 0 function associated with string breaks a string around each instance of one or more consecutive white space characters into an Array. For example, myArray:= strings: Fields(myEtring) splits mystring into characters separated by whitespace(s). Java, you may have used mystring.trimo solit ("s+") where "st' represents the regular expression for one or more whitespace, tab, etc characters.
image text in transcribed

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions