mirror of
https://github.com/revanced/smali.git
synced 2025-05-04 08:34:25 +02:00
Add support for reporting of the source file name from the lexer, to be used for error messages
git-svn-id: https://smali.googlecode.com/svn/trunk@755 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
9ac6fa5048
commit
1c42f47ada
@ -276,6 +276,7 @@ public class main {
|
||||
InputStreamReader reader = new InputStreamReader(fis, "UTF-8");
|
||||
|
||||
lexer = new smaliFlexLexer(reader);
|
||||
((smaliFlexLexer)lexer).setSourceFile(smaliFile);
|
||||
tokens = new CommonTokenStream((TokenSource)lexer);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package org.jf.smali;
|
||||
|
||||
import java.io.*;
|
||||
import org.antlr.runtime.*;
|
||||
|
||||
import org.jf.util.*;
|
||||
import static org.jf.smali.smaliParser.*;
|
||||
|
||||
%%
|
||||
@ -25,6 +26,8 @@ import static org.jf.smali.smaliParser.*;
|
||||
|
||||
private int lexerErrors = 0;
|
||||
|
||||
private File sourceFile;
|
||||
|
||||
public Token nextToken() {
|
||||
try {
|
||||
Token token = yylex();
|
||||
@ -55,8 +58,16 @@ import static org.jf.smali.smaliParser.*;
|
||||
return this.yycolumn;
|
||||
}
|
||||
|
||||
public void setSourceFile(File sourceFile) {
|
||||
this.sourceFile = sourceFile;
|
||||
}
|
||||
|
||||
public String getSourceName() {
|
||||
return "";
|
||||
try {
|
||||
return PathUtil.getRelativeFile(new File("."), sourceFile).getPath();
|
||||
} catch (IOException ex) {
|
||||
return sourceFile.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumberOfSyntaxErrors() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user