Question: 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.
 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!