Przeglądaj źródła

Formatted language and parser classes.

Timur Sağlam 5 lat temu
rodzic
commit
9dda8ccdcc

+ 42 - 44
jplag.frontend.java-1.9/src/main/java/jplag/java19/Language.java

@@ -6,65 +6,63 @@ import jplag.ProgramI;
 import jplag.Structure;
 
 /**
- * Hello world!
- *
+ * Language for Java 9 and newer.
  */
 public class Language implements jplag.Language {
-	private Parser parser;
+    private Parser parser;
 
-	public Language(ProgramI program) {
-		this.parser = new Parser();
-		this.parser.setProgram(program);
+    public Language(ProgramI program) {
+        this.parser = new Parser();
+        this.parser.setProgram(program);
+    }
 
-	}
-	
     public String[] suffixes() {
-    	String[] res = { ".java", ".JAVA" };
-		return res;
-	}
+        String[] res = {".java", ".JAVA"};
+        return res;
+    }
 
-	public String name() {
-		return "Javac 1.9+ based AST plugin";
-	}
+    public String name() {
+        return "Javac 1.9+ based AST plugin";
+    }
 
-	public String getShortName() {
-		return "java19";
-	}
+    public String getShortName() {
+        return "java19";
+    }
 
-	public int min_token_match() {
-		return 9;
-	}
-	public boolean supportsColumns() {
-		return true;
-	}
+    public int min_token_match() {
+        return 9;
+    }
 
-	public boolean isPreformatted() {
-		return true;
-	}
+    public boolean supportsColumns() {
+        return true;
+    }
 
-	public boolean usesIndex() {
-		return false;
-	}
+    public boolean isPreformatted() {
+        return true;
+    }
 
-	public int noOfTokens() {
-		return JavaToken.numberOfTokens();
-	}
+    public boolean usesIndex() {
+        return false;
+    }
 
-	public String type2string(int type) {
-		return JavaToken.type2string(type);
-	}
+    public int noOfTokens() {
+        return JavaToken.numberOfTokens();
+    }
 
+    public String type2string(int type) {
+        return JavaToken.type2string(type);
+    }
 
-	public Structure parse(File dir, String[] files) {
-		return this.parser.parse(dir, files);
-	}
+    public Structure parse(File dir, String[] files) {
+        return this.parser.parse(dir, files);
+    }
 
-	public boolean errors() {
-		return this.parser.getErrors();
-	}
+    public boolean errors() {
+        return this.parser.getErrors();
+    }
 
-	public int errorsCount() {
-		return this.parser.errorsCount();
-	}
+    public int errorsCount() {
+        return this.parser.errorsCount();
+    }
 
 }

+ 21 - 23
jplag.frontend.java-1.9/src/main/java/jplag/java19/Parser.java

@@ -2,29 +2,27 @@ package jplag.java19;
 
 import java.io.File;
 
-public class Parser  extends jplag.Parser {
-	private jplag.Structure struct;
+public class Parser extends jplag.Parser {
+    private jplag.Structure struct;
 
-	public jplag.Structure parse(File dir, String files[]) {
-		struct = new jplag.Structure();
-		errors = 0;
-		File pathedFiles[] = new File[files.length];
-		for (int i = 0; i < files.length; i++) {
-			pathedFiles[i]=new File(dir,files[i]); 
-		}
-		JavacAdapter javac = new JavacAdapter();
-		errors += javac.parseFiles(dir,pathedFiles,this);
-		
-		
-		this.parseEnd();
-		return struct;
-	}
-	
-	public void add(int type,String filename, long line, long col, long length) {
-		struct.addToken(new JavaToken(type, filename, (int) line, (int)col,(int)length));
-	}
+    public jplag.Structure parse(File dir, String files[]) {
+        struct = new jplag.Structure();
+        errors = 0;
+        File pathedFiles[] = new File[files.length];
+        for (int i = 0; i < files.length; i++) {
+            pathedFiles[i] = new File(dir, files[i]);
+        }
+        JavacAdapter javac = new JavacAdapter();
+        errors += javac.parseFiles(dir, pathedFiles, this);
+        this.parseEnd();
+        return struct;
+    }
 
-	public void errorsInc() {
-		errors++;
-	}
+    public void add(int type, String filename, long line, long col, long length) {
+        struct.addToken(new JavaToken(type, filename, (int) line, (int) col, (int) length));
+    }
+
+    public void errorsInc() {
+        errors++;
+    }
 }