Ofekw / 701A2

Java parser/compiler to support additional syntax keywords and language features

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

##Summary You have learnt the tools needed to parse and compile a real programming language, such as Java. In this project, you will implement semantic analysis and incorporate a new programming feature into Java. This will require you to build a source-to-source compiler. You are required to select one of the following new features and incorporate it into Java. • yield Keyword. Allow a yield keyword in a method denition to allow code to be injected into an existing method. • Map Literals. Allow a new Java expression for initialising maps that requires fewer statements and infers types. • Tuple Return Types. Allow a Java method to return up to two values which can be of dierent types. You are also required to submit a report that justies why your selected new feature should be included in the Java language. This justication must be supported by relevant literature. The report must also discuss the design and implementation of your symbol table. ##Details You will be provided with java_1_5.jj which species the Java grammar for the entire Java language (v1.5). You must modify this .jj le so code which includes your new feature does not throw any ParseExceptions. You will take a *.javax le as input and output a *.java le which can be compiled using a standard Java compiler. Therefore, you will be creating a source-to-source compiler. You must incorporate semantic analysis for your new feature as well as general Java code. You should cover simple semantic cases such as: • Scope • Types • Forward references • Member access However, your compiler does not need to be complete, you can do some hard coding. You should hard code the required primitive types, classes and libraries in your global scope since your compiler will not have access to these. For example, if your input calls the System.out.println method, you can hard code the System class, the out variable and the println method. You should cover commonly used classes (e.g. String, Integer, etc.) and any other classes needed for your feature. You will be given two sample input les to help you test your semantic analysis, but your submission will be marked against many other input les - you must therefore be condent in your semantic analysis when you submit it! You are free to discuss the assignment with other students and to exchange sample input les for testing your semantic analysis. However, each student must implement the semantic analysis and new feature individually. All submitted work will be checked against software plagiarism tools, with heavy penalties in place.

About

Java parser/compiler to support additional syntax keywords and language features


Languages

Language:Java 100.0%