-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from merkrafter/development
Finished Version 0.1.0
- Loading branch information
Showing
20 changed files
with
1,087 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.