Skip to content

Commit

Permalink
use antlr4 to parse smali files
Browse files Browse the repository at this point in the history
Fix issue #16
#16

--HG--
branch : 2.x
  • Loading branch information
pxb1988 committed Jun 13, 2015
1 parent d69d6c1 commit 05dcb84
Show file tree
Hide file tree
Showing 16 changed files with 1,555 additions and 701 deletions.
17 changes: 8 additions & 9 deletions d2j-smali/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@ configurations {
antlr2java
}
dependencies {
compile(group: 'org.antlr', name: 'antlr-runtime', version:'3.5.2') {
exclude(module: 'stringtemplate')
}
compile 'org.antlr:antlr4-runtime:4.5'
compile project(':dex-reader')
antlr2java(group: 'org.antlr', name: 'antlr', version:'3.5.2')
antlr2java 'org.antlr:antlr4:4.5'
compile project(':d2j-base-cmd')
compile project(':dex-writer')
testCompile 'org.smali:baksmali:2.0.6'
}

task antlr2java(type: JavaExec) {
classpath=configurations.antlr2java
def source='src/main/antlr3'
def grammars = fileTree(source).include('**/*.g')
def source='src/main/antlr4'
def grammars = fileTree(source).include('**/*.g4')
ext.antlrJava="$buildDir/generated-sources/antlr"
def antlrDir="$buildDir/generated-sources/antlr/com/googlecode/d2j/smali"
def antlrDir="$buildDir/generated-sources/antlr/com/googlecode/d2j/smali/antlr4"
inputs.dir file(source)
outputs.dir file(ext.antlrJava)
main='org.antlr.Tool'
args=['-o', "$antlrDir",grammars.files].flatten()
main='org.antlr.v4.Tool'
args=[ '-no-listener', '-visitor','-package','com.googlecode.d2j.smali.antlr4', '-o', "$antlrDir",grammars.files].flatten()
}
compileJava{
dependsOn antlr2java
Expand Down
30 changes: 19 additions & 11 deletions d2j-smali/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr-runtime</artifactId>
<version>3.5.2</version>
<exclusions>
<exclusion>
<artifactId>stringtemplate</artifactId>
<groupId>org.antlr</groupId>
</exclusion>
</exclusions>
<artifactId>antlr4-runtime</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>com.googlecode.d2j</groupId>
Expand All @@ -37,20 +31,34 @@
<version>2.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.smali</groupId>
<artifactId>baksmali</artifactId>
<version>2.0.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr3-maven-plugin</artifactId>
<version>3.5.2</version>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.5</version>
<executions>
<execution>
<goals>
<goal>antlr</goal>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
<configuration>
<arguments>
<argument>-no-listener</argument>
<argument>-visitor</argument>
<argument>-package</argument>
<argument>com.googlecode.d2j.smali.antlr4</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Loading

0 comments on commit 05dcb84

Please sign in to comment.