~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to lib/antlr/src/NoViableAltException.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ANTLR Translator Generator
2
 
 * Project led by Terence Parr at http://www.jGuru.com
3
 
 * Software rights: http://www.antlr.org/license.html
4
 
 *
5
 
 * $Id: NoViableAltException.cpp 626096 2007-01-22 06:35:06Z okellogg $
6
 
 */
7
 
 
8
 
#include "antlr/NoViableAltException.hpp"
9
 
#include "antlr/String.hpp"
10
 
 
11
 
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
12
 
namespace antlr {
13
 
#endif
14
 
 
15
 
ANTLR_USING_NAMESPACE(std)
16
 
 
17
 
NoViableAltException::NoViableAltException(RefAST t)
18
 
  : RecognitionException("NoViableAlt","<AST>",-1,-1),
19
 
    token(0), node(t)
20
 
{
21
 
}
22
 
 
23
 
NoViableAltException::NoViableAltException(
24
 
        RefToken t,
25
 
        const ANTLR_USE_NAMESPACE(std)string& fileName_
26
 
) : RecognitionException("NoViableAlt",fileName_,t->getLine(),t->getColumn()),
27
 
    token(t), node(nullASTptr)
28
 
{
29
 
}
30
 
 
31
 
ANTLR_USE_NAMESPACE(std)string NoViableAltException::getMessage() const
32
 
{
33
 
        if (token)
34
 
        {
35
 
                if( token->getType() == Token::EOF_TYPE )
36
 
                        return string("unexpected end of file");
37
 
                else if( token->getType() == Token::NULL_TREE_LOOKAHEAD )
38
 
                        return string("unexpected end of tree");
39
 
                else
40
 
                        return string("unexpected token: ")+token->getText();
41
 
        }
42
 
 
43
 
        // must a tree parser error if token==null
44
 
        if (!node)
45
 
                return "unexpected end of subtree";
46
 
 
47
 
        return string("unexpected AST node: ")+node->toString();
48
 
}
49
 
 
50
 
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
51
 
}
52
 
#endif