Abstract Syntax Trees1 for a very small programming language

See screenshots at the bottom of the page

Order Description

1. Abstract Syntax Trees1 for a very small programming language (only a few types of expressions and statements are modeled). The classes in this hierarchy are sufficient to model the following program: var x; x = 1+2 Each class in the hierarchy overrides the abstract method text() that is defined in interface ASTNode. Calling text() on a node computes a string that reflects the entire subtree rooted at that node. Your task is to implement the class hierarchy, and test it thoroughly. Make sure that all your code is properly documented. The following JUnit test should be included in your test suite, and it should pass. @Test public void test1(){ Exp one = new NumericLiteral(1); Exp three = new NumericLiteral(3); PlusExp exp = new PlusExp(one, three); Stmt decl = new DeclStmt("x"); Stmt assign = new Assignment("x", exp); Stmt seq = new Sequence(decl, assign); assertEquals(seq.text(), "var x; x = 1 + 3"); } Please add more tests to your test suite, and test all different types of nodes. Please ensure that all your code is properly documented. Place your code in a package "ast" and your test suite in a class "ASTTests" in a package “tests”. 2. Making the Design More Flexible Now create a new version of the application created in problem 1 where all nodes are created in a way that enables you to specialize the process of creating nodes that makes it easy: 1. to create specialized types of nodes, and/or 2. to perform additional operations when nodes are being created. Furthermore, your solution should make it easy to vary between different specialized node creation options. Please test your code thoroughly, by updating your tests from the previous question to reflect the new design and adding additional tests as needed. Place your code in a package "ast2 " and your tests in a class "AST2Tests" in package “tests2”. 3. Adding Logging Building off the solution you designed for problem 2, please add a facility for counting the number of instances of each type Node that has been created. A method report() should be provided that prints these numbers to standard output. Please create another version of the previous test suite that uses this factory and that tests all functionality thoroughly. Place your code in a package "ast3 " and your tests in a class "AST3Tests" in package “tests3”. 4. Avoiding duplicates Now create a version of your system that enforces, for at least one class in your system, that at most one object is being created. Please place this version of your system in a package “ast4”, and an appropriately updated version of your test suite in a package “tests4”.

Screenshots