public static IANTLRErrorListener GetErrorListener() { IANTLRErrorListener el = _listener; if (el == null) { return(theDefaultErrorListener); } return(el); }
public static IANTLRErrorListener GetErrorListener() { IANTLRErrorListener el = (IANTLRErrorListener)threadToListenerMap.get(Thread.CurrentThread); if (el == null) { return(theDefaultErrorListener); } return(el); }
/** Encodes the error handling found in setLocale, but does not trigger * panics, which would make GUI tools die if ANTLR's installation was * a bit screwy. Duplicated code...ick. * public static Locale getLocaleForValidMessages(Locale locale) { * ErrorManager.locale = locale; * String language = locale.getLanguage(); * String fileName = "org/antlr/tool/templates/messages/"+language+".stg"; * ClassLoader cl = Thread.currentThread().getContextClassLoader(); * InputStream is = cl.getResourceAsStream(fileName); * if ( is==null && language.equals(Locale.US.getLanguage()) ) { * return null; * } * else if ( is==null ) { * return getLocaleForValidMessages(Locale.US); // recurse on this rule, trying the US locale * } * * boolean messagesOK = verifyMessages(); * if ( !messagesOK && language.equals(Locale.US.getLanguage()) ) { * return null; * } * else if ( !messagesOK ) { * return getLocaleForValidMessages(Locale.US); // try US to see if that will work * } * return true; * } */ /** In general, you'll want all errors to go to a single spot. * However, in a GUI, you might have two frames up with two * different grammars. Two threads might launch to process the * grammars--you would want errors to go to different objects * depending on the thread. I store a single listener per * thread. */ public static void SetErrorListener(IANTLRErrorListener listener) { threadToListenerMap[Thread.CurrentThread] = listener; }
public static void RemoveErrorListener() { ErrorManager._listener = null; }
/** Encodes the error handling found in setLocale, but does not trigger * panics, which would make GUI tools die if ANTLR's installation was * a bit screwy. Duplicated code...ick. * public static Locale getLocaleForValidMessages(Locale locale) { * ErrorManager.locale = locale; * String language = locale.getLanguage(); * String fileName = "org/antlr/tool/templates/messages/"+language+".stg"; * ClassLoader cl = Thread.currentThread().getContextClassLoader(); * InputStream is = cl.getResourceAsStream(fileName); * if ( is==null && language.equals(Locale.US.getLanguage()) ) { * return null; * } * else if ( is==null ) { * return getLocaleForValidMessages(Locale.US); // recurse on this rule, trying the US locale * } * * boolean messagesOK = verifyMessages(); * if ( !messagesOK && language.equals(Locale.US.getLanguage()) ) { * return null; * } * else if ( !messagesOK ) { * return getLocaleForValidMessages(Locale.US); // try US to see if that will work * } * return true; * } */ /** In general, you'll want all errors to go to a single spot. * However, in a GUI, you might have two frames up with two * different grammars. Two threads might launch to process the * grammars--you would want errors to go to different objects * depending on the thread. I store a single listener per * thread. */ public static void SetErrorListener(IANTLRErrorListener listener) { ErrorManager._listener = listener; }
/** Encodes the error handling found in setLocale, but does not trigger * panics, which would make GUI tools die if ANTLR's installation was * a bit screwy. Duplicated code...ick. public static Locale getLocaleForValidMessages(Locale locale) { ErrorManager.locale = locale; String language = locale.getLanguage(); String fileName = "org/antlr/tool/templates/messages/"+language+".stg"; ClassLoader cl = Thread.currentThread().getContextClassLoader(); InputStream is = cl.getResourceAsStream(fileName); if ( is==null && language.equals(Locale.US.getLanguage()) ) { return null; } else if ( is==null ) { return getLocaleForValidMessages(Locale.US); // recurse on this rule, trying the US locale } boolean messagesOK = verifyMessages(); if ( !messagesOK && language.equals(Locale.US.getLanguage()) ) { return null; } else if ( !messagesOK ) { return getLocaleForValidMessages(Locale.US); // try US to see if that will work } return true; } */ /** In general, you'll want all errors to go to a single spot. * However, in a GUI, you might have two frames up with two * different grammars. Two threads might launch to process the * grammars--you would want errors to go to different objects * depending on the thread. I store a single listener per * thread. */ public static void SetErrorListener( IANTLRErrorListener listener ) { ErrorManager._listener = listener; }
/** Encodes the error handling found in setLocale, but does not trigger * panics, which would make GUI tools die if ANTLR's installation was * a bit screwy. Duplicated code...ick. public static Locale getLocaleForValidMessages(Locale locale) { ErrorManager.locale = locale; String language = locale.getLanguage(); String fileName = "org/antlr/tool/templates/messages/"+language+".stg"; ClassLoader cl = Thread.currentThread().getContextClassLoader(); InputStream is = cl.getResourceAsStream(fileName); if ( is==null && language.equals(Locale.US.getLanguage()) ) { return null; } else if ( is==null ) { return getLocaleForValidMessages(Locale.US); // recurse on this rule, trying the US locale } boolean messagesOK = verifyMessages(); if ( !messagesOK && language.equals(Locale.US.getLanguage()) ) { return null; } else if ( !messagesOK ) { return getLocaleForValidMessages(Locale.US); // try US to see if that will work } return true; } */ /** In general, you'll want all errors to go to a single spot. * However, in a GUI, you might have two frames up with two * different grammars. Two threads might launch to process the * grammars--you would want errors to go to different objects * depending on the thread. I store a single listener per * thread. */ public static void SetErrorListener( IANTLRErrorListener listener ) { threadToListenerMap[Thread.CurrentThread] = listener; }
public static void ResetErrorState() { _listener = null; _errorState = null; }