From e186646752d88d137a157894c5cba12885bec8d0 Mon Sep 17 00:00:00 2001 From: "JesusFreke@JesusFreke.com" Date: Sat, 6 Jun 2009 18:53:40 +0000 Subject: [PATCH] Updated the token emmission mechanism to include token line/column info git-svn-id: https://smali.googlecode.com/svn/trunk@100 55b6fa8a-2a1e-11de-a435-ffa8d773f76a --- .../antlr3/org/JesusFreke/smali/smaliLexer.g | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/main/antlr3/org/JesusFreke/smali/smaliLexer.g b/src/main/antlr3/org/JesusFreke/smali/smaliLexer.g index 21995306..ea8df9d3 100644 --- a/src/main/antlr3/org/JesusFreke/smali/smaliLexer.g +++ b/src/main/antlr3/org/JesusFreke/smali/smaliLexer.g @@ -161,20 +161,29 @@ import java.util.ArrayDeque; tokens.add(Token.SKIP_TOKEN); } - public void emit(Token token) { - tokens.add(token); - } - - public void emit(Token token, int type) { - token.setType(type); - tokens.add(token); - } - - public void emit(Token token, int type, int channel) { - token.setType(type); - token.setChannel(channel); - tokens.add(token); - } + public void emit(Token token) { + token.setLine(state.tokenStartLine); + token.setText(state.text); + token.setCharPositionInLine(state.tokenStartCharPositionInLine); + tokens.add(token); + } + + public void emit(Token token, int type) { + token.setLine(state.tokenStartLine); + token.setText(state.text); + token.setCharPositionInLine(state.tokenStartCharPositionInLine); + token.setType(type); + tokens.add(token); + } + + public void emit(Token token, int type, int channel) { + token.setLine(state.tokenStartLine); + token.setText(state.text); + token.setCharPositionInLine(state.tokenStartCharPositionInLine); + token.setType(type); + token.setChannel(channel); + tokens.add(token); + } public String getErrorHeader(RecognitionException e) { return getSourceName()+"["+ e.line+","+e.charPositionInLine+"]";