Question: Use Java language for your program Given the grammar for a hypothetical imperative programming language, write a program that analyzes the syntax of input programs

Use Java language for your program

Given the grammar for a hypothetical imperative programming language, write a program that analyzes the syntax of input programs for the language. Your program should read an input test program from a file and then determine whether or not it contains any syntax errors. The program does not have to show where the syntax error occurred or what kind of error it was.

In your program:

  1. Implement a lexical analyzer as a subprogram of your program. Each time the lexical analyzer is called, it should return the next lexeme and its token code.
  2. Implement a parser based on the following EBNF rules. Create a subprogram for each nonterminal symbol which should parse only sentences that can be generated by the nonterminal.

-> program begin end -> {;} -> | | -> = -> identifier (An identifier is a string that begins with a letter followed by 0 or more letters and/or digits) -> { (+|-) } -> {(* | /) } -> identifier | int_constant | () -> if () then -> (< | >) (Assume that logic expressions have only less than or greater than operators) -> loop ()

Upload all your source code and screen dumps of the execution of your program.

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!