Coder Social home page Coder Social logo

mycompiler's Introduction

PP Final Project:

Prerequisites

Make sure you have installed:

  • Maven. Preferably version 3.8 or later.
  • A Java version. Preferably 11 or 17.

To test if you have these tools set up properly, run the following two commands in the command line:

  • For maven: mvn --version
  • For java: javac --version

If these commands print sensible outputs (e.g. "version so and so"), this boilerplate project should work fine. Otherwise, you will have to install these tools either manually or using your operating system's package manager.

Compiling and Running all tests

Before compiling, In the terminal run:

mvn clean install

This is used because a ParseTree Visitor has been used for Code Generation. The command will compile the program and run all the tests.

Compiling

In a terminal, run:

mvn compile

This first generates parsers for any grammars in src/main/antlr4. Then it compiles code in the src/main/java directory.

Running

In a terminal, run:

mvn exec:java -Dexec.mainClass="ut.pp.Main"

This runs the main method of the class Main, located in the ut.pp package.

Note: exec does not invoke compile, so if changes were made to the code, compile needs to be invoked before exec. These commands can also be combined:

mvn compile exec:java -Dexec.mainClass="ut.pp.Main"

mvn exec:java is part of the maven-exec plugin. For more information about e.g. passing arguments to the main class, we refer you to the plugin documentation.

Tests

In a terminal, run:

mvn test

This will run all test classes in the src/test/java directory which have names starting with "Test".

Intellij Integration

The project can be imported into intellij by opening the pom.xml file in intellij. Then on the right there will be a "Maven" pane. If the "Maven" pane is not there, you might have opened the project directory; be sure to open specifically the file with intellij.

Open the "Maven" pane, and open the tree structure there until you find the "Lifecycle" section. Here you can double-click "compile" and "test" to compile and test your code.

To run your main class, open the main class and click on the green arrow besides the main method. Note: you have to run the "compile" target in the maven pane before running the main class.

To run your a specific test, open the test class and click the green arrows beside the test methods to run the individual tests. Note: you have to run the "test" target in the maven pane before running the individual tests.

For more information on intellij's maven integration, we refer you to the intellij documentation.

##Using the compiler

To use the compiler, you can write code in the src/sample/compiler.txt which is run by the Main class.

If the code contains any errors, they are thrown as an exception and the error messages can be seen, otherwise the generated sprockell code can be found inside ut/pp/compiler/haskell/output.hs and the output can be seen in the Terminal.

mycompiler's People

Contributors

hnm27 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.