package jshinter.analyzer;

import jshinter.antlr.ECMAScriptBaseListener;
import jshinter.antlr.ECMAScriptParser;
import jshinter.antlr.ECMAScriptParser.ProgramContext;

public class JSHinterListener extends ECMAScriptBaseListener {

	private ECMAScriptParser parser;
	
	private final Boolean DEBUG;
	
	public JSHinterListener(ECMAScriptParser parser) {
		this.parser = parser;
		this.DEBUG = false;
	}
	
	public JSHinterListener(ECMAScriptParser parser, Boolean debugMode) {
		this.parser = parser;
		this.DEBUG = debugMode;
	}

	@Override
	public void enterProgram(ProgramContext ctx) {
//		super.enterProgram(ctx);
		System.out.println("PROGRAMA JAVASCRIPT");
	}
}

@@ -21,16 +21,93 @@
 lyzer;%0A%0A
+import org.antlr.v4.runtime.Token;%0Aimport org.antlr.v4.runtime.TokenStream;%0A%0A
 import j
@@ -223,23 +223,355 @@
 tParser.
-Program
+AssignmentOperatorContext;%0Aimport jshinter.antlr.ECMAScriptParser.BitAndExpressionContext;%0Aimport jshinter.antlr.ECMAScriptParser.BitNotExpressionContext;%0Aimport jshinter.antlr.ECMAScriptParser.BitOrExpressionContext;%0Aimport jshinter.antlr.ECMAScriptParser.BitShiftExpressionContext;%0Aimport jshinter.antlr.ECMAScriptParser.BitXOrExpression
 Context;
@@ -935,141 +935,1679 @@
 %0A%09%7D%0A
-%0A%09@Override%0A%09public void enterProgram(ProgramContext ctx) %7B%0A//%09%09super.enterProgram(ctx);%0A%09%09System.out.println(%22PROGRAMA JAVASCRIPT%22);
+%09%0A%09private void reportError(String msg, Token t) %7B%0A%09%09System.out.printf(%22%25d,%25d: %25s.%5Cn%22, t.getLine(), t.getCharPositionInLine() + 1, msg);%0A%09%7D%0A%0A%09@Override%0A%09public void enterBitXOrExpression(BitXOrExpressionContext ctx) %7B%0A%09%09TokenStream ts = parser.getTokenStream();%0A%0A%09%09reportError(String.format(%22Unexpected use of '%25s'%22, ctx.getChild(1).getText()), ts.get(ctx.getChild(1).getSourceInterval().a));%0A%09%7D%0A%0A%09@Override%0A%09public void enterBitShiftExpression(BitShiftExpressionContext ctx) %7B%0A%09%09TokenStream ts = parser.getTokenStream();%0A%0A%09%09reportError(String.format(%22Unexpected use of '%25s'%22, ctx.getChild(1).getText()), ts.get(ctx.getChild(1).getSourceInterval().a));%0A%09%7D%0A%0A%09@Override%0A%09public void enterBitNotExpression(BitNotExpressionContext ctx) %7B%0A%09%09TokenStream ts = parser.getTokenStream();%0A%0A%09%09reportError(String.format(%22Unexpected use of '%25s'%22, ctx.getChild(1).getText()), ts.get(ctx.getChild(1).getSourceInterval().a));%0A%09%7D%0A%0A%09@Override%0A%09public void enterBitAndExpression(BitAndExpressionContext ctx) %7B%0A%09%09TokenStream ts = parser.getTokenStream();%0A%0A%09%09reportError(String.format(%22Unexpected use of '%25s'%22, ctx.getChild(1).getText()), ts.get(ctx.getChild(1).getSourceInterval().a));%0A%09%7D%0A%0A%09@Override%0A%09public void enterBitOrExpression(BitOrExpressionContext ctx) %7B%0A%09%09TokenStream ts = parser.getTokenStream();%0A%0A%09%09reportError(String.format(%22Unexpected use of '%25s'%22, ctx.getChild(1).getText()), ts.get(ctx.getChild(1).getSourceInterval().a));%0A%09%7D%0A%0A%09@Override%0A%09public void enterAssignmentOperator(AssignmentOperatorContext ctx) %7B%0A%09%09Token t = ctx.getStart();%0A%09%09int type = t.getType();%0A%09%09%0A%09%09if (type %3E= 45 %7C%7C type %3C= 50) %7B%0A%09%09%09reportError(String.format(%22Unexpected use of '%25s'%22, t.getText()), t);%0A%09%09%7D
 %0A%09%7D%0A

Include bitwise rule