Skip to content

Commit

Permalink
Merge pull request #5 from merkrafter/development
Browse files Browse the repository at this point in the history
Finished Version 0.1.0
  • Loading branch information
merkrafter authored Nov 18, 2019
2 parents 54f74cb + 2397755 commit a0d012c
Show file tree
Hide file tree
Showing 20 changed files with 1,087 additions and 99 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/Merkompiler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Test with Maven
run: mvn -B test --file pom.xml
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Download artifact
uses: actions/download[email protected]
- name: Upload artifact
uses: actions/upload[email protected]
with:
name: Merkompiler.jar
name: Merkompiler-standalone.jar
path: target/Merkompiler-jar-with-dependencies.jar
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 merkrafter

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Merkompiler
`Merkompiler` is a JavaSST compiler written in Java as a study project.
It is not meant to be used in production, but rather as a template and inspiration for others
that need to solve similar tasks.

## Getting started
These instructions will help you compiling and running Merkompiler on your system.

### JavaSST description
JavaSST is a (pretty) small subset of Java's language features.
A complete description for it can be found in this project's wiki pages.

### Prerequisites
This program is developed under and tested with
- `Apache maven 3.6.0` (you'll only need that if you plan to test and build Merkompiler yourself)
- `Java 1.8`

### Building
In order to compile this project yourself, you simply need to run the following commands.
If you just want to use it, skip to installing.
```bash
$ git clone https://github.com/merkrafter/Merkompiler.git
$ mvn package
```

### Installing
Merkompiler comes as a standalone jar, hence you don't need to do anything other than
building or downloading it from the github repository's releases tab.

## Running the tests
Assuming you downloaded the sources via git clone or equivalent, you only have to run:
```bash
$ mvn test
```

## Contributing
As this is a study project, direct contributing is not allowed.
You are still invited to open an issue if you find a bug or something similar.

## Versioning
This project uses [Semantic Versioning](https://semver.org/).

## License
This project is released under the [MIT license](LICENSE.md).
20 changes: 16 additions & 4 deletions merkompiler.iml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
Expand All @@ -19,5 +23,13 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.4.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.4.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.4.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.4.2" level="project" />
<orderEntry type="library" name="Maven: net.sourceforge.argparse4j:argparse4j:0.8.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.5.2" level="project" />
</component>
</module>
81 changes: 81 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<groupId>Merkompiler</groupId>
<artifactId>Merkompiler</artifactId>
<version>0.1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.argparse4j</groupId>
<artifactId>argparse4j</artifactId>
<version>0.8.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.merkrafter.Merkompiler</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
47 changes: 0 additions & 47 deletions src/com/merkrafter/Merkompiler.java

This file was deleted.

8 changes: 0 additions & 8 deletions src/com/merkrafter/lexing/TokenType.java

This file was deleted.

File renamed without changes.
66 changes: 66 additions & 0 deletions src/main/java/com/merkrafter/Merkompiler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.merkrafter;

import com.merkrafter.config.Config;
import com.merkrafter.config.ErrorCode;
import com.merkrafter.lexing.Scanner;
import com.merkrafter.lexing.TokenType;
import net.sourceforge.argparse4j.inf.ArgumentParserException;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;

public class Merkompiler {

/**
* The main function of this compiler reads in the filename and handles other possible command line
* options. It then runs the compiler on the input file.
*/
public static void main(String[] args) {
// to change the arguments in IntelliJ, press Alt+Shift+F10
try {
final Config config = Config.fromArgs(args);
run(config);
} catch (ArgumentParserException e) {
e.getParser().handleError(e); // prints the help message
System.exit(ErrorCode.ARGUMENTS_UNPARSABLE.id);
} catch (FileNotFoundException e) {
System.err.println(e.getMessage());
System.exit(ErrorCode.FILE_NOT_FOUND.id);
}
}

/**
* Contains the main application logic.
* Passes errors etc. to the calling method which is expected to be main.
*
* @param config configuration data for this program call
* @throws FileNotFoundException if the input or output file could not be found
*/
static void run(final Config config) throws FileNotFoundException {
if (config.isVerbose()) {
System.out.println(config);
}

final File inputFile = new File(config.getInputFile());
final Input input = new Input(inputFile.getAbsolutePath());
final Scanner scanner = new Scanner(input);
if (config.isVerbose()) {
scanner.setFilename(inputFile.getAbsolutePath());
} else {
scanner.setFilename(inputFile.getName());
}

PrintStream out = System.out; // write to stdout by default

// write to output file if given
if (config.getOutputFile() != null) {
out = new PrintStream(config.getOutputFile());
}

do {
scanner.processToken();
out.println(scanner.getSym());
} while (scanner.getSym().getType() != TokenType.EOF);
}
}
Loading

0 comments on commit a0d012c

Please sign in to comment.