Question: JAVA please Consider the following EBNF grammar for a very simple programming language: program-S (statemt) statemt assnmt | ifstmt do | inout | progcall assnmt
JAVA please


Consider the following EBNF grammar for a very simple programming language: program-S (statemt) statemt assnmt | ifstmt do | inout | progcall assnmt -ident exprsn ; ifstmt ::- 1 comp r sn @ {statemt } [% {statemt] & :D (statemt U comprsn E inout iosym ident f, ident ; 1osym progcallC program G comprsn :: oprnd opratr oprnd ) exprsn :factor factorh factoroprnd * oprnd) oprnd integer | ident | bolexprsn) ident letter (char char := letter | digit integerdigit (digith digit bool The tokens are: S 1 D U E R O C GWXYZ01TF.~@%&,()+*=>! Nonterminals are shown as lowercase words. The following characters are NOT tokens (they are EBNF metasymbols): Note that parentheses are TOKENS, not EBNF metasymbols in this particular grammar. Implement a recursive-descent recognizer: Prompt the user for an input stream The user enters an input stream of legal tokens, followed by a $ - You can assume: the user enters no whitespace, the user only enters legal tokens listed above, the user enters one and only one $, at the end The start symbol is *program (as defined above) - Your program should output "legal" or "errors found" (not both! You can report additional information as well, if you want. For example, knowing where your program finds an error could be helpful for me to assign partial credit if it's wrong - Assume the input stream is the TOKEN stream. Assume that any whitespace has already been stripped out by the lexical scanner (i.e., each token is one character - 1exical scanning has been completed) Since the incoming token stream is terminated with a $, you will need to add the to the grammar and incorporate it in your answers to questions #1 and #2 above, where appropriate. - Use Java, C, or C++ or ask your instructor if you wish to use another language. Limit your source code to ONE file. Consider the following EBNF grammar for a very simple programming language: program-S (statemt) statemt assnmt | ifstmt do | inout | progcall assnmt -ident exprsn ; ifstmt ::- 1 comp r sn @ {statemt } [% {statemt] & :D (statemt U comprsn E inout iosym ident f, ident ; 1osym progcallC program G comprsn :: oprnd opratr oprnd ) exprsn :factor factorh factoroprnd * oprnd) oprnd integer | ident | bolexprsn) ident letter (char char := letter | digit integerdigit (digith digit bool The tokens are: S 1 D U E R O C GWXYZ01TF.~@%&,()+*=>! Nonterminals are shown as lowercase words. The following characters are NOT tokens (they are EBNF metasymbols): Note that parentheses are TOKENS, not EBNF metasymbols in this particular grammar. Implement a recursive-descent recognizer: Prompt the user for an input stream The user enters an input stream of legal tokens, followed by a $ - You can assume: the user enters no whitespace, the user only enters legal tokens listed above, the user enters one and only one $, at the end The start symbol is *program (as defined above) - Your program should output "legal" or "errors found" (not both! You can report additional information as well, if you want. For example, knowing where your program finds an error could be helpful for me to assign partial credit if it's wrong - Assume the input stream is the TOKEN stream. Assume that any whitespace has already been stripped out by the lexical scanner (i.e., each token is one character - 1exical scanning has been completed) Since the incoming token stream is terminated with a $, you will need to add the to the grammar and incorporate it in your answers to questions #1 and #2 above, where appropriate. - Use Java, C, or C++ or ask your instructor if you wish to use another language. Limit your source code to ONE file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
