changes for jar build
This commit is contained in:
parent
c24a483880
commit
192dfae94b
7
.idea/encodings.xml
generated
Normal file
7
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
4
.idea/misc.xml
generated
4
.idea/misc.xml
generated
@ -24,7 +24,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/target" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@ -3,7 +3,6 @@
|
|||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/NichtHaskell.iml" filepath="$PROJECT_DIR$/NichtHaskell.iml" />
|
<module fileurl="file://$PROJECT_DIR$/NichtHaskell.iml" filepath="$PROJECT_DIR$/NichtHaskell.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/src/NichtHaskell1.iml" filepath="$PROJECT_DIR$/src/NichtHaskell1.iml" />
|
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -2,7 +2,10 @@
|
|||||||
<module version="4">
|
<module version="4">
|
||||||
<component name="AdditionalModuleElements">
|
<component name="AdditionalModuleElements">
|
||||||
<content url="file://$MODULE_DIR$" dumb="true">
|
<content url="file://$MODULE_DIR$" dumb="true">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/Source" 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>
|
</content>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
34
pom.xml
34
pom.xml
@ -4,25 +4,45 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>Clippit.org</groupId>
|
<groupId>Clippit.org</groupId>
|
||||||
<artifactId>NichtHaskell</artifactId>
|
<artifactId>NichtHaskell</artifactId>
|
||||||
<version>1</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>20</maven.compiler.source>
|
<java.version>22</java.version>
|
||||||
<maven.compiler.target>20</maven.compiler.target>
|
<maven.compiler.source>22</maven.compiler.source>
|
||||||
|
<maven.compiler.target>22</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>2.22.2</version>
|
<version>3.7.1</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>Compiler</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>make-assembly</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import abstractSyntaxTree.Class.RefType;
|
import TypeCheck.TypeCheckException;
|
||||||
import abstractSyntaxTree.Program;
|
import abstractSyntaxTree.Program;
|
||||||
import astGenerator.ASTGenerator;
|
import astGenerator.ASTGenerator;
|
||||||
import gen.DecafLexer;
|
import gen.DecafLexer;
|
||||||
@ -18,32 +18,44 @@ public class Compiler {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception{
|
public static void main(String[] args) throws Exception{
|
||||||
|
|
||||||
Path filePath = Paths.get("src/main/java/TestClass.java");
|
// todo code für jar
|
||||||
|
// if (args.length < 1) {
|
||||||
|
// System.out.println("Usage: java -jar Compiler.jar <file_path> [--suppress-details]");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//String filePath = args[0];
|
||||||
|
String filePath = "src/main/java/TestClass.java";
|
||||||
|
// TODO false setzen für jar-Build
|
||||||
|
boolean suppressDetails = true;
|
||||||
|
|
||||||
// todo remove this debug info
|
if (args.length > 1 && args[1].equals("--suppress-details")) {
|
||||||
Path absolutePath = filePath.toAbsolutePath();
|
suppressDetails = true;
|
||||||
System.out.println("Processing input: " + absolutePath);
|
}
|
||||||
|
|
||||||
String content;
|
Path path = Paths.get(filePath);
|
||||||
try {
|
|
||||||
content = Files.readString(filePath);
|
if (!Files.exists(path)) {
|
||||||
}catch (java.nio.file.NoSuchFileException e){
|
System.out.println("Your input file was not found: " + path);
|
||||||
System.out.println("File not found");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!suppressDetails)
|
||||||
|
System.out.println("Processing input: " + path);
|
||||||
|
|
||||||
System.out.println("--- print content ---");
|
String content = Files.readString(path);
|
||||||
System.out.println(content);
|
|
||||||
|
if(!suppressDetails)
|
||||||
|
System.out.println("The content of your input file is: \n" + content);
|
||||||
|
|
||||||
CharStream codeCharStream = CharStreams.fromString(content);
|
CharStream codeCharStream = CharStreams.fromString(content);
|
||||||
DecafLexer lexer = new DecafLexer(codeCharStream);
|
DecafLexer lexer = new DecafLexer(codeCharStream);
|
||||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||||
|
|
||||||
System.out.println("--- print tokens ---");
|
|
||||||
tokens.fill();
|
tokens.fill();
|
||||||
|
|
||||||
|
if(!suppressDetails) {
|
||||||
|
|
||||||
List<Token> tokenList = tokens.getTokens();
|
List<Token> tokenList = tokens.getTokens();
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
@ -52,7 +64,8 @@ public class Compiler {
|
|||||||
}
|
}
|
||||||
String readableTokens = stringBuilder.toString().trim();
|
String readableTokens = stringBuilder.toString().trim();
|
||||||
|
|
||||||
System.out.println(readableTokens);
|
System.out.println("The tokens of your input are: \n" + readableTokens);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DecafParser parser = new DecafParser(tokens);
|
DecafParser parser = new DecafParser(tokens);
|
||||||
@ -63,14 +76,30 @@ public class Compiler {
|
|||||||
Program abstractSyntaxTree =(Program) generator.visit(tree);
|
Program abstractSyntaxTree =(Program) generator.visit(tree);
|
||||||
|
|
||||||
|
|
||||||
System.out.println("--- AST generator ---");
|
|
||||||
System.out.println("Parsed " + abstractSyntaxTree.classes.size() + " classes with names:");
|
|
||||||
for (RefType refType : abstractSyntaxTree.classes) {
|
|
||||||
System.out.println(refType.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(!suppressDetails) {
|
||||||
|
System.out.println("Parsed " + abstractSyntaxTree.classes.size() + " classes: ");
|
||||||
|
abstractSyntaxTree.classes.forEach(refType -> {
|
||||||
|
System.out.print(refType.name);
|
||||||
|
if (abstractSyntaxTree.classes.indexOf(refType) < abstractSyntaxTree.classes.size() - 1) {
|
||||||
|
System.out.print(", ");
|
||||||
|
} else {
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// try {
|
||||||
|
// abstractSyntaxTree.typeCheck();
|
||||||
|
// }catch(TypeCheckException e){
|
||||||
|
// System.out.println("A TypeCheck error occurred. The compilation was stopped.");
|
||||||
|
// System.out.println(e);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
abstractSyntaxTree.typeCheck();
|
abstractSyntaxTree.typeCheck();
|
||||||
|
if(!suppressDetails)
|
||||||
|
System.out.println("No TypeCheck errors found.");
|
||||||
|
|
||||||
abstractSyntaxTree.codeGen();
|
abstractSyntaxTree.codeGen();
|
||||||
|
System.out.println("Your input was compiler. You can find the output at ???");// todo wo output? überhaupt hinschreiben?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class Example1 {
|
class Example1b {
|
||||||
public int fak(int number){
|
public int fak(int number){
|
||||||
if(number < 0){
|
if(number < 0){
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1,5 +1,27 @@
|
|||||||
public class TestClass {
|
class TestClass {
|
||||||
public static void main(String[] args){
|
int i;
|
||||||
|
int a = 12345;
|
||||||
|
Example e;
|
||||||
|
public TestClass(){i = 3456;}
|
||||||
|
int meth(int n){
|
||||||
|
Example e = new Example();
|
||||||
|
int abc = e.example1.m1(2).m2().m3();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Example m1(int n){
|
||||||
|
return new Example();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Example {
|
||||||
|
int i;
|
||||||
|
boolean b;
|
||||||
|
char c;
|
||||||
|
TestClass example1;
|
||||||
|
TestClass m(int a){
|
||||||
|
return new TestClass();
|
||||||
|
}
|
||||||
|
Example m2(){return new Example();}
|
||||||
|
int m3(){return 1;}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user