From: Svjatoslav Agejenko Date: Sat, 6 Jul 2013 21:33:25 +0000 (+0300) Subject: java syntax parser X-Git-Tag: javainspect-1.1~12 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=b11a3d9201e6fa8b62fa2fdfd5b99ade27297e3f;p=javainspect.git java syntax parser --- diff --git a/src/main/java/eu/svjatoslav/inspector/java/methods/JavaFile.java b/src/main/java/eu/svjatoslav/inspector/java/methods/JavaFile.java index d517537..5b636d6 100644 --- a/src/main/java/eu/svjatoslav/inspector/java/methods/JavaFile.java +++ b/src/main/java/eu/svjatoslav/inspector/java/methods/JavaFile.java @@ -35,6 +35,12 @@ public class JavaFile { tokenizer.addTerminator("\n", true); tokenizer.addTerminator(";", false); + tokenizer.addTerminator("{", false); + tokenizer.addTerminator("}", false); + tokenizer.addTerminator("(", false); + tokenizer.addTerminator(")", false); + tokenizer.addTerminator("[", false); + tokenizer.addTerminator("]", false); while (true) { final TokenizerMatch match = tokenizer.getToken(); @@ -43,6 +49,10 @@ public class JavaFile { if (match.token.equals("import")) parseImport(tokenizer); + + if (match.token.equals("package")) + parsePackage(tokenizer); + } } @@ -50,7 +60,7 @@ public class JavaFile { private void parseImport(final Tokenizer tokenizer) { final Import imp = new Import(); - final TokenizerMatch match = tokenizer.getToken(); + TokenizerMatch match = tokenizer.getToken(); if (match.token.equals("static")) { imp.isStatic = true; @@ -59,6 +69,19 @@ public class JavaFile { imp.path = match.token; imports.add(imp); + + // ; + match = tokenizer.getToken(); + } + + private void parsePackage(final Tokenizer tokenizer) { + + TokenizerMatch match = tokenizer.getToken(); + + System.out.println(match.token); + + // ; + match = tokenizer.getToken(); } private void readFile() throws FileNotFoundException, IOException {