• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/** An extra token while parsing a TokenStream */
2org.antlr.runtime.UnwantedTokenException = function(expecting, input) {
3    if (arguments.length>0) {
4        org.antlr.runtime.UnwantedTokenException.superclass.constructor.call(
5                this, expecting, input);
6    }
7};
8
9org.antlr.lang.extend(
10    org.antlr.runtime.UnwantedTokenException,
11    org.antlr.runtime.MismatchedTokenException, {
12    getUnexpectedToken: function() {
13        return this.token;
14    },
15    toString: function() {
16        var exp = ", expected "+this.expecting;
17        if ( this.expecting===org.antlr.runtime.Token.INVALID_TOKEN_TYPE ) {
18            exp = "";
19        }
20        if ( !org.antlr.lang.isValue(this.token) ) {
21            return "UnwantedTokenException(found="+exp+")";
22        }
23        return "UnwantedTokenException(found="+this.token.getText()+exp+")";
24    },
25    name: "org.antlr.runtime.UnwantedTokenException"
26});
27