Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribed 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: image text in transcribed 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

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 Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions