Question: This program is to parse Tiny programs using JavaCUP. You need to write a JavaCUP file and a JLex file so that a parser for

This program is to parse Tiny programs using JavaCUP. You need to write a JavaCUP file and a JLex file so that a parser for Tiny language can be generated. The parser will be able to tell whether a Tiny program is syntactically correct. You need to rewrite EBNF grammar into CFG that is acceptable by JavaCUP. Comments in Tiny program should be thrown away in the scanner. I will be running the following commands to generate the scanner and the parser. This program is to parse Tiny programs using JavaCUP. You need to If your lex and cup files are correct, all of those command and especially A3User will run smoothly without any error report, and an A3.output file will be created which should consists of one line as follows: write a JavaCUP file and a JLex file so that a parser You need to turn in two files: the JLex file, named A3.lex, which can be used to generate the scanner; the javaCUP file, named A3.cup, which can be used to generate the parser.

> java JLex. Main A3 . lex > java java_cup. Main - parser A3Parser - symbols A3Symbol > javac A3. lex. java A3Parser . java A3Symbol . java A3User . java > java A3User The program A3User invokes the parser. It is defined as below: import java . io.*; class A3User \{ public static void main ( String [] args ) throws Exception \{ File inputFile = new File ("A3. tiny "); A3Parser parser = new A3Parser ( new A3Scanner ( new FileInputStream ( inputFile ))); Integer result =( Integer) parser. parse (). value ; FileWriter fw =new FileWriter ( new File ("A3. output ")); fw. write (" Number of methods : "+ result. intValue ()); fw. close (); \} \} Number of methods : numberDfMehtodsInA2Input

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!