How to use the antlr4/index.error function in antlr4

To help you get started, we’ve selected a few antlr4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cancerberoSgx / univac / univac / src / grammar / r / RParser.js View on Github external
break;
            case RParser.NL:
                this.state = 21;
                this.match(RParser.NL);
                break;
            default:
                throw new antlr4.error.NoViableAltException(this);
            }
            this.state = 26;
            this._errHandler.sync(this);
            _la = this._input.LA(1);
        }
        this.state = 27;
        this.match(RParser.EOF);
    } catch (re) {
    	if(re instanceof antlr4.error.RecognitionException) {
	        localctx.exception = re;
	        this._errHandler.reportError(this, re);
	        this._errHandler.recover(this, re);
	    } else {
	    	throw re;
	    }
    } finally {
        this.exitRule();
    }
    return localctx;
};
github cancerberoSgx / univac / univac / src / grammar / r / RParser.js View on Github external
this.state = 111;
                    if (!( this.precpred(this._ctx, 34))) {
                        throw new antlr4.error.FailedPredicateException(this, "this.precpred(this._ctx, 34)");
                    }
                    this.state = 112;
                    this.match(RParser.USER_OP);
                    this.state = 113;
                    this.expr(35);
                    break;

                case 6:
                    localctx = new ExprContext(this, _parentctx, _parentState);
                    this.pushNewRecursionContext(localctx, _startState, RParser.RULE_expr);
                    this.state = 114;
                    if (!( this.precpred(this._ctx, 33))) {
                        throw new antlr4.error.FailedPredicateException(this, "this.precpred(this._ctx, 33)");
                    }
                    this.state = 115;
                    _la = this._input.LA(1);
                    if(!(_la===RParser.T__12 || _la===RParser.T__13)) {
                    this._errHandler.recoverInline(this);
                    }
                    else {
                    	this._errHandler.reportMatch(this);
                        this.consume();
                    }
                    this.state = 116;
                    this.expr(34);
                    break;

                case 7:
                    localctx = new ExprContext(this, _parentctx, _parentState);
github microsoft / botbuilder-tools / packages / Ludown / lib / generated / LUFileParser.js View on Github external
try {
        this.enterOuterAlt(localctx, 1);
        this.state = 202;
        this.match(LUFileParser.FILTER_MARK);
        this.state = 204; 
        this._errHandler.sync(this);
        _la = this._input.LA(1);
        do {
            this.state = 203;
            this.filterLine();
            this.state = 206; 
            this._errHandler.sync(this);
            _la = this._input.LA(1);
        } while(_la===LUFileParser.DASH);
    } catch (re) {
    	if(re instanceof antlr4.error.RecognitionException) {
	        localctx.exception = re;
	        this._errHandler.reportError(this, re);
	        this._errHandler.recover(this, re);
	    } else {
	    	throw re;
	    }
    } finally {
        this.exitRule();
    }
    return localctx;
};
github cancerberoSgx / univac / univac / src / grammar / lua / LuaParser.js View on Github external
LuaParser.prototype.operatorOr = function() {

    var localctx = new OperatorOrContext(this, this._ctx, this.state);
    this.enterRule(localctx, 48, LuaParser.RULE_operatorOr);
    try {
        this.enterOuterAlt(localctx, 1);
        this.state = 378;
        this.match(LuaParser.T__32);
    } catch (re) {
    	if(re instanceof antlr4.error.RecognitionException) {
	        localctx.exception = re;
	        this._errHandler.reportError(this, re);
	        this._errHandler.recover(this, re);
	    } else {
	    	throw re;
	    }
    } finally {
        this.exitRule();
    }
    return localctx;
};
github cancerberoSgx / univac / univac / src / grammar / r / RFilter.js View on Github external
break;
            case RFilter.T__0:
                this.state = 12;
                this.match(RFilter.T__0);
                break;
            default:
                throw new antlr4.error.NoViableAltException(this);
            }
            this.state = 17;
            this._errHandler.sync(this);
            _la = this._input.LA(1);
        }
        this.state = 18;
        this.match(RFilter.EOF);
    } catch (re) {
    	if(re instanceof antlr4.error.RecognitionException) {
	        localctx.exception = re;
	        this._errHandler.reportError(this, re);
	        this._errHandler.recover(this, re);
	    } else {
	    	throw re;
	    }
    } finally {
        this.exitRule();
    }
    return localctx;
};
github stencila / mini / parser / MiniParser.js View on Github external
this.enterOuterAlt(localctx, 1);
            this.state = 138;
            this.match(MiniParser.INT);
             localctx.type = 'int' 
            break;
        case MiniParser.FLOAT:
            this.enterOuterAlt(localctx, 2);
            this.state = 140;
            this.match(MiniParser.FLOAT);
             localctx.type = 'float' 
            break;
        default:
            throw new antlr4.error.NoViableAltException(this);
        }
    } catch (re) {
    	if(re instanceof antlr4.error.RecognitionException) {
	        localctx.exception = re;
	        this._errHandler.reportError(this, re);
	        this._errHandler.recover(this, re);
	    } else {
	    	throw re;
	    }
    } finally {
        this.exitRule();
    }
    return localctx;
};
github merklejerk / solpp / src / antlr / ExprParser.js View on Github external
if (!( this.precpred(this._ctx, 17))) {
                        throw new antlr4.error.FailedPredicateException(this, "this.precpred(this._ctx, 17)");
                    }
                    this.state = 77;
                    this.match(ExprParser.DOT);
                    this.state = 78;
                    localctx.key = this.match(ExprParser.IDENTIFIER);
                    break;

                case 9:
                    localctx = new IndexOperationContext(this, new ExpressionContext(this, _parentctx, _parentState));
                    localctx.list = _prevctx;
                    this.pushNewRecursionContext(localctx, _startState, ExprParser.RULE_expression);
                    this.state = 79;
                    if (!( this.precpred(this._ctx, 16))) {
                        throw new antlr4.error.FailedPredicateException(this, "this.precpred(this._ctx, 16)");
                    }
                    this.state = 80;
                    this.match(ExprParser.LBRACKET);
                    this.state = 81;
                    localctx.inner = this.expression(0);
                    this.state = 82;
                    this.match(ExprParser.RBRACKET);
                    break;

                case 10:
                    localctx = new CallOperationContext(this, new ExpressionContext(this, _parentctx, _parentState));
                    localctx.callee = _prevctx;
                    this.pushNewRecursionContext(localctx, _startState, ExprParser.RULE_expression);
                    this.state = 84;
                    if (!( this.precpred(this._ctx, 11))) {
                        throw new antlr4.error.FailedPredicateException(this, "this.precpred(this._ctx, 11)");
github merklejerk / solpp / src / antlr / SolParser.js View on Github external
this.state = 243;
            localctx.key = this.match(SolParser.IDENTIFIER);

        }
        this.state = 246;
        this.match(SolParser.WS);
        this.state = 247;
        this.match(SolParser.IN_KW);
        this.state = 248;
        this.match(SolParser.WS);
        this.state = 249;
        localctx.iterable = this.directivePayload();
        this.state = 250;
        this.endDirective();
    } catch (re) {
    	if(re instanceof antlr4.error.RecognitionException) {
	        localctx.exception = re;
	        this._errHandler.reportError(this, re);
	        this._errHandler.recover(this, re);
	    } else {
	    	throw re;
	    }
    } finally {
        this.exitRule();
    }
    return localctx;
};
github cancerberoSgx / univac / univac / src / grammar / lua / LuaParser.js View on Github external
break;
        case LuaParser.T__30:
            this.state = 221;
            this.tableconstructor();
            break;
        case LuaParser.T__42:
        case LuaParser.T__49:
        case LuaParser.T__52:
        case LuaParser.T__53:
            this.state = 222;
            this.operatorUnary();
            this.state = 223;
            this.exp(8);
            break;
        default:
            throw new antlr4.error.NoViableAltException(this);
        }
        this._ctx.stop = this._input.LT(-1);
        this.state = 261;
        this._errHandler.sync(this);
        var _alt = this._interp.adaptivePredict(this._input,16,this._ctx)
        while(_alt!=2 && _alt!=antlr4.atn.ATN.INVALID_ALT_NUMBER) {
            if(_alt===1) {
                if(this._parseListeners!==null) {
                    this.triggerExitRuleEvent();
                }
                _prevctx = localctx;
                this.state = 259;
                this._errHandler.sync(this);
                var la_ = this._interp.adaptivePredict(this._input,15,this._ctx);
                switch(la_) {
                case 1:
github cancerberoSgx / univac / univac / src / grammar / r / RFilter.js View on Github external
case RFilter.HEX:
                case RFilter.INT:
                case RFilter.FLOAT:
                case RFilter.COMPLEX:
                case RFilter.STRING:
                case RFilter.ID:
                case RFilter.USER_OP:
                    this.state = 56;
                    this.elem();
                    break;
                case RFilter.NL:
                    this.state = 57;
                    this.eat();
                    break;
                default:
                    throw new antlr4.error.NoViableAltException(this);
                }
                this.state = 62;
                this._errHandler.sync(this);
                _la = this._input.LA(1);
            }
            this.state = 63;
            this.match(RFilter.T__2);
            break;
        case RFilter.T__1:
            this.enterOuterAlt(localctx, 6);
            this.state = 64;
            this.match(RFilter.T__1);
            this.state = 69;
            this._errHandler.sync(this);
            _la = this._input.LA(1);
            while((((_la) & ~0x1f) == 0 && ((1 << _la) & ((1 << RFilter.T__1) | (1 << RFilter.T__3) | (1 << RFilter.T__4) | (1 << RFilter.T__5) | (1 << RFilter.T__6) | (1 << RFilter.T__7) | (1 << RFilter.T__8) | (1 << RFilter.T__9) | (1 << RFilter.T__10) | (1 << RFilter.T__11) | (1 << RFilter.T__12) | (1 << RFilter.T__13) | (1 << RFilter.T__14) | (1 << RFilter.T__15) | (1 << RFilter.T__16) | (1 << RFilter.T__17) | (1 << RFilter.T__18) | (1 << RFilter.T__19) | (1 << RFilter.T__20) | (1 << RFilter.T__21) | (1 << RFilter.T__22) | (1 << RFilter.T__23) | (1 << RFilter.T__24) | (1 << RFilter.T__25) | (1 << RFilter.T__26) | (1 << RFilter.T__28) | (1 << RFilter.T__29))) !== 0) || ((((_la - 33)) & ~0x1f) == 0 && ((1 << (_la - 33)) & ((1 << (RFilter.T__32 - 33)) | (1 << (RFilter.T__33 - 33)) | (1 << (RFilter.T__35 - 33)) | (1 << (RFilter.T__37 - 33)) | (1 << (RFilter.T__38 - 33)) | (1 << (RFilter.T__39 - 33)) | (1 << (RFilter.T__40 - 33)) | (1 << (RFilter.T__41 - 33)) | (1 << (RFilter.T__42 - 33)) | (1 << (RFilter.T__43 - 33)) | (1 << (RFilter.T__44 - 33)) | (1 << (RFilter.T__45 - 33)) | (1 << (RFilter.T__46 - 33)) | (1 << (RFilter.T__47 - 33)) | (1 << (RFilter.T__48 - 33)) | (1 << (RFilter.T__49 - 33)) | (1 << (RFilter.T__50 - 33)) | (1 << (RFilter.T__51 - 33)) | (1 << (RFilter.T__52 - 33)) | (1 << (RFilter.T__53 - 33)) | (1 << (RFilter.HEX - 33)) | (1 << (RFilter.INT - 33)) | (1 << (RFilter.FLOAT - 33)) | (1 << (RFilter.COMPLEX - 33)) | (1 << (RFilter.STRING - 33)) | (1 << (RFilter.ID - 33)) | (1 << (RFilter.USER_OP - 33)) | (1 << (RFilter.NL - 33)))) !== 0)) {