source: trunk/yao/share/antlr-2.7.7/lib/csharp/antlr.runtime/antlr/NoViableAltException.cs @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

File size: 1.4 KB
Line 
1using System;
2
3using AST                                       = antlr.collections.AST;
4
5namespace antlr
6{
7        /*ANTLR Translator Generator
8        * Project led by Terence Parr at http://www.jGuru.com
9        * Software rights: http://www.antlr.org/license.html
10        *
11        * $Id:$
12        */
13
14        //
15        // ANTLR C# Code Generator by Micheal Jordan
16        //                            Kunle Odutola       : kunle UNDERSCORE odutola AT hotmail DOT com
17        //                            Anthony Oguntimehin
18        //
19        // With many thanks to Eric V. Smith from the ANTLR list.
20        //
21       
22        [Serializable]
23        public class NoViableAltException : RecognitionException
24        {
25                public IToken token;
26                public AST node; // handles parsing and treeparsing
27               
28                public NoViableAltException(AST t) : base("NoViableAlt", "<AST>", - 1, - 1)
29                {
30                        node = t;
31                }
32               
33                public NoViableAltException(IToken t, string fileName_) : 
34                                        base("NoViableAlt", fileName_, t.getLine(), t.getColumn())
35                {
36                        token = t;
37                }
38               
39                /*
40                * Returns a clean error message (no line number/column information)
41                */
42                override public string Message
43                {
44                        get 
45                        {
46                                if (token != null)
47                                {
48                                        //return "unexpected token: " + token.getText();
49                                        return "unexpected token: " + token.ToString();
50                                }
51                       
52                                // must a tree parser error if token==null
53                                if ( (node==null) || (node==TreeParser.ASTNULL) )
54                                {
55                                        return "unexpected end of subtree";
56                                }
57                                return "unexpected AST node: " + node.ToString();
58                        }
59                }
60        }
61}
Note: See TracBrowser for help on using the repository browser.