Hi,

I'm newbie using Antlr3.Runtime.dll C# , VS 2008, CSharp2 target
(perhaps better use vs2010 and CSharp3 target)

I need advanced error handling for use spanish in my error messages, and
do more clearly the messages to show it to the users.

I have been this page:

http://www.antlr.org/wiki/pages/viewpage.action?pageId=23232568


how is the code of getRuleInvocationStack ??? 

please, any another advanced samples for error handling ??

thanks.


public String getErrorMessage(RecognitionException e,
                                  String[] tokenNames)
    {
        List stack = getRuleInvocationStack(e,
this.getClass().getName());
        String msg = null;
        String inputContext =
            input.LT(-3) == null ? "" : ((Tree)input.LT(-3)).getText()+"
"+
            input.LT(-2) == null ? "" : ((Tree)input.LT(-2)).getText()+"
"+
            input.LT(-1) == null ? "" : ((Tree)input.LT(-1)).getText()+"
>>>"+
            ((Tree)input.LT(1)).getText()+"<<< "+
            ((Tree)input.LT(2)).getText()+" "+
            ((Tree)input.LT(3)).getText();
        if ( e instanceof NoViableAltException ) {
           NoViableAltException nvae = (NoViableAltException)e;
           msg = " no viable alt; token="+e.token+
              " (decision="+nvae.decisionNumber+
              " state "+nvae.stateNumber+")"+
              " decision=<<"+nvae.grammarDecisionDescription+">>";
        }
        else {
           msg = super.getErrorMessage(e, tokenNames);
        }
        return stack+" "+msg+" context=..."+inputContext+"...";
    }
    public String getTokenErrorDisplay(Token t) {
        return t.toString();
    }

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to