FileDocCategorySizeDatePackage
LLkDebuggingParser.javaAPI DocGlassfish v2 API7887Wed Feb 08 12:31:20 GMT 2006persistence.antlr.debug

LLkDebuggingParser

public class LLkDebuggingParser extends LLkParser implements DebuggingParser

Fields Summary
protected ParserEventSupport
parserEventSupport
private boolean
_notDebugMode
protected String[]
ruleNames
protected String[]
semPredNames
Constructors Summary
public LLkDebuggingParser(int k_)



	   
		super(k_);
	
public LLkDebuggingParser(ParserSharedInputState state, int k_)

		super(state, k_);
	
public LLkDebuggingParser(TokenBuffer tokenBuf, int k_)

		super(tokenBuf, k_);
	
public LLkDebuggingParser(TokenStream lexer, int k_)

		super(lexer, k_);
	
Methods Summary
public intLA(int i)
Return the token type of the ith token of lookahead where i=1 is the current token being examined by the parser (i.e., it has not been matched yet).

		int la = super.LA(i);
		parserEventSupport.fireLA(i, la);
		return la;
	
public voidaddMessageListener(persistence.antlr.debug.MessageListener l)

		parserEventSupport.addMessageListener(l);
	
public voidaddParserListener(persistence.antlr.debug.ParserListener l)

		parserEventSupport.addParserListener(l);
	
public voidaddParserMatchListener(persistence.antlr.debug.ParserMatchListener l)

		parserEventSupport.addParserMatchListener(l);
	
public voidaddParserTokenListener(persistence.antlr.debug.ParserTokenListener l)

		parserEventSupport.addParserTokenListener(l);
	
public voidaddSemanticPredicateListener(persistence.antlr.debug.SemanticPredicateListener l)

		parserEventSupport.addSemanticPredicateListener(l);
	
public voidaddSyntacticPredicateListener(persistence.antlr.debug.SyntacticPredicateListener l)

		parserEventSupport.addSyntacticPredicateListener(l);
	
public voidaddTraceListener(persistence.antlr.debug.TraceListener l)

		parserEventSupport.addTraceListener(l);
	
public voidconsume()
Get another token object from the token stream

		int la_1 = -99;
		try {la_1 = LA(1);}	
		catch (TokenStreamException ignoreAnException) {}
		super.consume();
		parserEventSupport.fireConsume(la_1);
	
protected voidfireEnterRule(int num, int data)

		if (isDebugMode())
			parserEventSupport.fireEnterRule(num,inputState.guessing,data);
	
protected voidfireExitRule(int num, int data)

		if (isDebugMode())
			parserEventSupport.fireExitRule(num,inputState.guessing,data);
	
protected booleanfireSemanticPredicateEvaluated(int type, int num, boolean condition)

		if (isDebugMode())
			return parserEventSupport.fireSemanticPredicateEvaluated(type,num,condition,inputState.guessing);
		else
			return condition;
	
protected voidfireSyntacticPredicateFailed()

		if (isDebugMode())
			parserEventSupport.fireSyntacticPredicateFailed(inputState.guessing);
	
protected voidfireSyntacticPredicateStarted()

		if (isDebugMode())
			parserEventSupport.fireSyntacticPredicateStarted(inputState.guessing);
	
protected voidfireSyntacticPredicateSucceeded()

		if (isDebugMode())
			parserEventSupport.fireSyntacticPredicateSucceeded(inputState.guessing);
	
public java.lang.StringgetRuleName(int num)

		return ruleNames[num];
	
public java.lang.StringgetSemPredName(int num)

		return semPredNames[num];
	
public synchronized voidgoToSleep()

		try {wait();}
		catch (InterruptedException e) {	}		
	
public booleanisDebugMode()

		return !_notDebugMode;
	
public booleanisGuessing()

		return inputState.guessing > 0;
	
public voidmatch(int t)
Make sure current lookahead symbol matches token type t. Throw an exception upon mismatch, which is catch by either the error handler or by the syntactic predicate.

		String text = LT(1).getText();
		int la_1 = LA(1);
		try {
			super.match(t);
			parserEventSupport.fireMatch(t, text, inputState.guessing);
		}
		catch (MismatchedTokenException e) {
			if (inputState.guessing == 0)
				parserEventSupport.fireMismatch(la_1, t, text, inputState.guessing);
			throw e;
		}
	
public voidmatch(persistence.antlr.collections.impl.BitSet b)
Make sure current lookahead symbol matches the given set Throw an exception upon mismatch, which is catch by either the error handler or by the syntactic predicate.

		String text = LT(1).getText();
		int la_1 = LA(1);
		try {
			super.match(b);
			parserEventSupport.fireMatch(la_1,b, text, inputState.guessing);
		}
		catch (MismatchedTokenException e) {
			if (inputState.guessing == 0)
				parserEventSupport.fireMismatch(la_1, b, text, inputState.guessing);
			throw e;
		}
	
public voidmatchNot(int t)

		String text = LT(1).getText();
		int la_1 = LA(1);
		try {
			super.matchNot(t);
			parserEventSupport.fireMatchNot(la_1, t, text, inputState.guessing);
		}
		catch (MismatchedTokenException e) {
			if (inputState.guessing == 0)
				parserEventSupport.fireMismatchNot(la_1, t, text, inputState.guessing);
			throw e;
		}
	
public voidremoveMessageListener(persistence.antlr.debug.MessageListener l)

		parserEventSupport.removeMessageListener(l);
	
public voidremoveParserListener(persistence.antlr.debug.ParserListener l)

		parserEventSupport.removeParserListener(l);
	
public voidremoveParserMatchListener(persistence.antlr.debug.ParserMatchListener l)

		parserEventSupport.removeParserMatchListener(l);
	
public voidremoveParserTokenListener(persistence.antlr.debug.ParserTokenListener l)

		parserEventSupport.removeParserTokenListener(l);
	
public voidremoveSemanticPredicateListener(persistence.antlr.debug.SemanticPredicateListener l)

		parserEventSupport.removeSemanticPredicateListener(l);
	
public voidremoveSyntacticPredicateListener(persistence.antlr.debug.SyntacticPredicateListener l)

		parserEventSupport.removeSyntacticPredicateListener(l);
	
public voidremoveTraceListener(persistence.antlr.debug.TraceListener l)

	
		parserEventSupport.removeTraceListener(l);
	
public voidreportError(persistence.antlr.RecognitionException ex)
Parser error-reporting function can be overridden in subclass

		parserEventSupport.fireReportError(ex);
		super.reportError(ex);
	
public voidreportError(java.lang.String s)
Parser error-reporting function can be overridden in subclass

		parserEventSupport.fireReportError(s);
		super.reportError(s);
	
public voidreportWarning(java.lang.String s)
Parser warning-reporting function can be overridden in subclass

		parserEventSupport.fireReportWarning(s);
		super.reportWarning(s);
	
public voidsetDebugMode(boolean value)

		_notDebugMode = !value;
	
public voidsetupDebugging(persistence.antlr.TokenBuffer tokenBuf)

		setupDebugging(null, tokenBuf);
	
public voidsetupDebugging(persistence.antlr.TokenStream lexer)

		setupDebugging(lexer, null);
	
protected voidsetupDebugging(persistence.antlr.TokenStream lexer, persistence.antlr.TokenBuffer tokenBuf)
User can override to do their own debugging

		setDebugMode(true);
		// default parser debug setup is ParseView
		try {
			try {
				Class.forName("javax.swing.JButton");
			}
			catch (ClassNotFoundException e) {
				System.err.println("Swing is required to use ParseView, but is not present in your CLASSPATH");
				System.exit(1);
			}
			Class c = Class.forName("antlr.parseview.ParseView");
			Constructor constructor = c.getConstructor(new Class[] {LLkDebuggingParser.class, TokenStream.class, TokenBuffer.class});
			constructor.newInstance(new Object[] {this, lexer, tokenBuf});
		}
		catch(Exception e) {
			System.err.println("Error initializing ParseView: "+e);
			System.err.println("Please report this to Scott Stanchfield, thetick@magelang.com");
			System.exit(1);
		}
	
public synchronized voidwakeUp()

		notify();