Base calling AST

This commit is contained in:
jeffcheasey88 2023-10-17 04:11:52 +02:00
parent 7689afeef9
commit b17ce88e11
2 changed files with 25 additions and 3 deletions

Binary file not shown.

View file

@ -21,6 +21,8 @@ import javax.tools.StandardLocation;
import be.jeffcheasey88.peeratcode.parser.Parser; import be.jeffcheasey88.peeratcode.parser.Parser;
import be.jeffcheasey88.peeratcode.parser.TokenValidator; import be.jeffcheasey88.peeratcode.parser.TokenValidator;
import be.jeffcheasey88.peeratcode.parser.java.Annotation;
import be.jeffcheasey88.peeratcode.parser.java.Class;
import be.jeffcheasey88.peeratcode.parser.java.JavaElement; import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
import be.jeffcheasey88.peeratcode.parser.java.JavaFile; import be.jeffcheasey88.peeratcode.parser.java.JavaFile;
import be.jeffcheasey88.peeratcode.parser.java.JavaParser; import be.jeffcheasey88.peeratcode.parser.java.JavaParser;
@ -75,6 +77,7 @@ public class TreasureProcessor extends AbstractProcessor{
process(source, output, file, javaFile); process(source, output, file, javaFile);
}catch(Exception ex){ }catch(Exception ex){
error(source, output, file, ex); error(source, output, file, ex);
throw ex;
} }
} }
@ -83,16 +86,35 @@ public class TreasureProcessor extends AbstractProcessor{
File parent = out.getParentFile(); File parent = out.getParentFile();
if(!parent.exists()) parent.mkdirs(); if(!parent.exists()) parent.mkdirs();
if(!out.exists()) out.createNewFile(); if(!out.exists()) out.createNewFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(out)); // BufferedWriter writer = new BufferedWriter(new FileWriter(out));
PARSER.build(writer); // PARSER.build(writer);
if(TokenValidator.TOKENS != TokenValidator.MAX_VALIDATE) throw new Exception(TokenValidator.TOKENS +" < "+TokenValidator.MAX_VALIDATE);
Class treasure = file.find((element) -> {
if(element instanceof Class){
Class c = (Class)element;
return c.find((subelement) -> {
if(subelement instanceof Annotation){
Annotation annotation = (Annotation)subelement;
if(annotation.getName().getValue().equals("Treasure")) return true; //can also be dev.peerat.mapping.Treasure
}
return false;
}) != null;
}
return false;
});
if(treasure != null){
}
} }
private void error(File source, File output, File clazz, Exception e) throws Exception{ private void error(File source, File output, File clazz, Exception e) throws Exception{
File out = new File(output, clazz.getAbsolutePath().substring(source.getAbsolutePath().length())); File out = new File(output, "log.txt");
File parent = out.getParentFile(); File parent = out.getParentFile();
if(!parent.exists()) parent.mkdirs(); if(!parent.exists()) parent.mkdirs();
if(!out.exists()) out.createNewFile(); if(!out.exists()) out.createNewFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(out)); BufferedWriter writer = new BufferedWriter(new FileWriter(out));
writer.write(clazz.getAbsolutePath()+"\n");
writer.write(e.getMessage()+"\n"); writer.write(e.getMessage()+"\n");
for(StackTraceElement trace : e.getStackTrace()){ for(StackTraceElement trace : e.getStackTrace()){
writer.write(trace+"\n"); writer.write(trace+"\n");