UNPKG

@stordata/grammars

Version:

A collection of ANTLR grammars used at Stordata. This project exists so that we can package the grammars (and various utilities) as a CommonJS module. The `antlr4` Javascript runtime is only available as an ES module at the time of writing.

512 lines (434 loc) 15 kB
// Generated from src/grammars/PrometheusMetrics.g4 by ANTLR 4.13.1 // jshint ignore: start import antlr4 from 'antlr4'; import PrometheusMetricsListener from './PrometheusMetricsListener.js'; import PrometheusMetricsVisitor from './PrometheusMetricsVisitor.js'; const serializedATN = [4,1,9,64,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,1,0,5,0, 10,8,0,10,0,12,0,13,9,0,1,1,1,1,4,1,17,8,1,11,1,12,1,18,1,1,3,1,22,8,1,1, 1,4,1,25,8,1,11,1,12,1,26,1,1,3,1,30,8,1,1,2,1,2,1,2,5,2,35,8,2,10,2,12, 2,38,9,2,1,2,3,2,41,8,2,1,2,1,2,1,2,5,2,46,8,2,10,2,12,2,49,9,2,1,2,3,2, 52,8,2,1,3,3,3,55,8,3,1,3,3,3,58,8,3,1,3,1,3,1,3,1,3,1,3,0,0,4,0,2,4,6,0, 1,1,0,6,7,70,0,11,1,0,0,0,2,14,1,0,0,0,4,51,1,0,0,0,6,54,1,0,0,0,8,10,3, 2,1,0,9,8,1,0,0,0,10,13,1,0,0,0,11,9,1,0,0,0,11,12,1,0,0,0,12,1,1,0,0,0, 13,11,1,0,0,0,14,21,3,4,2,0,15,17,5,1,0,0,16,15,1,0,0,0,17,18,1,0,0,0,18, 16,1,0,0,0,18,19,1,0,0,0,19,20,1,0,0,0,20,22,5,6,0,0,21,16,1,0,0,0,21,22, 1,0,0,0,22,29,1,0,0,0,23,25,5,1,0,0,24,23,1,0,0,0,25,26,1,0,0,0,26,24,1, 0,0,0,26,27,1,0,0,0,27,28,1,0,0,0,28,30,5,6,0,0,29,24,1,0,0,0,29,30,1,0, 0,0,30,3,1,0,0,0,31,40,5,6,0,0,32,36,5,2,0,0,33,35,3,6,3,0,34,33,1,0,0,0, 35,38,1,0,0,0,36,34,1,0,0,0,36,37,1,0,0,0,37,39,1,0,0,0,38,36,1,0,0,0,39, 41,5,3,0,0,40,32,1,0,0,0,40,41,1,0,0,0,41,52,1,0,0,0,42,43,5,2,0,0,43,47, 5,7,0,0,44,46,3,6,3,0,45,44,1,0,0,0,46,49,1,0,0,0,47,45,1,0,0,0,47,48,1, 0,0,0,48,50,1,0,0,0,49,47,1,0,0,0,50,52,5,3,0,0,51,31,1,0,0,0,51,42,1,0, 0,0,52,5,1,0,0,0,53,55,5,4,0,0,54,53,1,0,0,0,54,55,1,0,0,0,55,57,1,0,0,0, 56,58,5,1,0,0,57,56,1,0,0,0,57,58,1,0,0,0,58,59,1,0,0,0,59,60,7,0,0,0,60, 61,5,5,0,0,61,62,5,7,0,0,62,7,1,0,0,0,11,11,18,21,26,29,36,40,47,51,54,57]; const atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN); const decisionsToDFA = atn.decisionToState.map( (ds, index) => new antlr4.dfa.DFA(ds, index) ); const sharedContextCache = new antlr4.atn.PredictionContextCache(); export default class PrometheusMetricsParser extends antlr4.Parser { static grammarFileName = "PrometheusMetrics.g4"; static literalNames = [ null, "' '", "'{'", "'}'", "','", "'='" ]; static symbolicNames = [ null, null, null, null, null, null, "IDENTIFIER", "QUOTED_DENTIFIER", "NEWLINE", "COMMENT" ]; static ruleNames = [ "all", "line", "metric", "label" ]; constructor(input) { super(input); this._interp = new antlr4.atn.ParserATNSimulator(this, atn, decisionsToDFA, sharedContextCache); this.ruleNames = PrometheusMetricsParser.ruleNames; this.literalNames = PrometheusMetricsParser.literalNames; this.symbolicNames = PrometheusMetricsParser.symbolicNames; } all() { let localctx = new AllContext(this, this._ctx, this.state); this.enterRule(localctx, 0, PrometheusMetricsParser.RULE_all); var _la = 0; try { this.enterOuterAlt(localctx, 1); this.state = 11; this._errHandler.sync(this); _la = this._input.LA(1); while(_la===2 || _la===6) { this.state = 8; this.line(); this.state = 13; this._errHandler.sync(this); _la = this._input.LA(1); } } 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; } line() { let localctx = new LineContext(this, this._ctx, this.state); this.enterRule(localctx, 2, PrometheusMetricsParser.RULE_line); var _la = 0; try { this.enterOuterAlt(localctx, 1); this.state = 14; this.metric(); this.state = 21; this._errHandler.sync(this); var la_ = this._interp.adaptivePredict(this._input,2,this._ctx); if(la_===1) { this.state = 16; this._errHandler.sync(this); _la = this._input.LA(1); do { this.state = 15; this.match(PrometheusMetricsParser.T__0); this.state = 18; this._errHandler.sync(this); _la = this._input.LA(1); } while(_la===1); this.state = 20; localctx.value = this.match(PrometheusMetricsParser.IDENTIFIER); } this.state = 29; this._errHandler.sync(this); _la = this._input.LA(1); if(_la===1) { this.state = 24; this._errHandler.sync(this); _la = this._input.LA(1); do { this.state = 23; this.match(PrometheusMetricsParser.T__0); this.state = 26; this._errHandler.sync(this); _la = this._input.LA(1); } while(_la===1); this.state = 28; localctx.timestamp = this.match(PrometheusMetricsParser.IDENTIFIER); } } 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; } metric() { let localctx = new MetricContext(this, this._ctx, this.state); this.enterRule(localctx, 4, PrometheusMetricsParser.RULE_metric); var _la = 0; try { this.state = 51; this._errHandler.sync(this); switch(this._input.LA(1)) { case 6: this.enterOuterAlt(localctx, 1); this.state = 31; localctx.name = this.match(PrometheusMetricsParser.IDENTIFIER); this.state = 40; this._errHandler.sync(this); var la_ = this._interp.adaptivePredict(this._input,6,this._ctx); if(la_===1) { this.state = 32; this.match(PrometheusMetricsParser.T__1); this.state = 36; this._errHandler.sync(this); _la = this._input.LA(1); while((((_la) & ~0x1f) === 0 && ((1 << _la) & 210) !== 0)) { this.state = 33; this.label(); this.state = 38; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 39; this.match(PrometheusMetricsParser.T__2); } break; case 2: this.enterOuterAlt(localctx, 2); this.state = 42; this.match(PrometheusMetricsParser.T__1); this.state = 43; localctx.name = this.match(PrometheusMetricsParser.QUOTED_DENTIFIER); this.state = 47; this._errHandler.sync(this); _la = this._input.LA(1); while((((_la) & ~0x1f) === 0 && ((1 << _la) & 210) !== 0)) { this.state = 44; this.label(); this.state = 49; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 50; this.match(PrometheusMetricsParser.T__2); 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; } label() { let localctx = new LabelContext(this, this._ctx, this.state); this.enterRule(localctx, 6, PrometheusMetricsParser.RULE_label); var _la = 0; try { this.enterOuterAlt(localctx, 1); this.state = 54; this._errHandler.sync(this); _la = this._input.LA(1); if(_la===4) { this.state = 53; this.match(PrometheusMetricsParser.T__3); } this.state = 57; this._errHandler.sync(this); _la = this._input.LA(1); if(_la===1) { this.state = 56; this.match(PrometheusMetricsParser.T__0); } this.state = 59; localctx.name = this._input.LT(1); _la = this._input.LA(1); if(!(_la===6 || _la===7)) { localctx.name = this._errHandler.recoverInline(this); } else { this._errHandler.reportMatch(this); this.consume(); } this.state = 60; this.match(PrometheusMetricsParser.T__4); this.state = 61; localctx.value = this.match(PrometheusMetricsParser.QUOTED_DENTIFIER); } 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; } } PrometheusMetricsParser.EOF = antlr4.Token.EOF; PrometheusMetricsParser.T__0 = 1; PrometheusMetricsParser.T__1 = 2; PrometheusMetricsParser.T__2 = 3; PrometheusMetricsParser.T__3 = 4; PrometheusMetricsParser.T__4 = 5; PrometheusMetricsParser.IDENTIFIER = 6; PrometheusMetricsParser.QUOTED_DENTIFIER = 7; PrometheusMetricsParser.NEWLINE = 8; PrometheusMetricsParser.COMMENT = 9; PrometheusMetricsParser.RULE_all = 0; PrometheusMetricsParser.RULE_line = 1; PrometheusMetricsParser.RULE_metric = 2; PrometheusMetricsParser.RULE_label = 3; class AllContext extends antlr4.ParserRuleContext { constructor(parser, parent, invokingState) { if(parent===undefined) { parent = null; } if(invokingState===undefined || invokingState===null) { invokingState = -1; } super(parent, invokingState); this.parser = parser; this.ruleIndex = PrometheusMetricsParser.RULE_all; } line = function(i) { if(i===undefined) { i = null; } if(i===null) { return this.getTypedRuleContexts(LineContext); } else { return this.getTypedRuleContext(LineContext,i); } }; enterRule(listener) { if(listener instanceof PrometheusMetricsListener ) { listener.enterAll(this); } } exitRule(listener) { if(listener instanceof PrometheusMetricsListener ) { listener.exitAll(this); } } accept(visitor) { if ( visitor instanceof PrometheusMetricsVisitor ) { return visitor.visitAll(this); } else { return visitor.visitChildren(this); } } } class LineContext extends antlr4.ParserRuleContext { constructor(parser, parent, invokingState) { if(parent===undefined) { parent = null; } if(invokingState===undefined || invokingState===null) { invokingState = -1; } super(parent, invokingState); this.parser = parser; this.ruleIndex = PrometheusMetricsParser.RULE_line; this.value = null; this.timestamp = null; } metric() { return this.getTypedRuleContext(MetricContext,0); }; IDENTIFIER = function(i) { if(i===undefined) { i = null; } if(i===null) { return this.getTokens(PrometheusMetricsParser.IDENTIFIER); } else { return this.getToken(PrometheusMetricsParser.IDENTIFIER, i); } }; enterRule(listener) { if(listener instanceof PrometheusMetricsListener ) { listener.enterLine(this); } } exitRule(listener) { if(listener instanceof PrometheusMetricsListener ) { listener.exitLine(this); } } accept(visitor) { if ( visitor instanceof PrometheusMetricsVisitor ) { return visitor.visitLine(this); } else { return visitor.visitChildren(this); } } } class MetricContext extends antlr4.ParserRuleContext { constructor(parser, parent, invokingState) { if(parent===undefined) { parent = null; } if(invokingState===undefined || invokingState===null) { invokingState = -1; } super(parent, invokingState); this.parser = parser; this.ruleIndex = PrometheusMetricsParser.RULE_metric; this.name = null; } IDENTIFIER() { return this.getToken(PrometheusMetricsParser.IDENTIFIER, 0); }; label = function(i) { if(i===undefined) { i = null; } if(i===null) { return this.getTypedRuleContexts(LabelContext); } else { return this.getTypedRuleContext(LabelContext,i); } }; QUOTED_DENTIFIER() { return this.getToken(PrometheusMetricsParser.QUOTED_DENTIFIER, 0); }; enterRule(listener) { if(listener instanceof PrometheusMetricsListener ) { listener.enterMetric(this); } } exitRule(listener) { if(listener instanceof PrometheusMetricsListener ) { listener.exitMetric(this); } } accept(visitor) { if ( visitor instanceof PrometheusMetricsVisitor ) { return visitor.visitMetric(this); } else { return visitor.visitChildren(this); } } } class LabelContext extends antlr4.ParserRuleContext { constructor(parser, parent, invokingState) { if(parent===undefined) { parent = null; } if(invokingState===undefined || invokingState===null) { invokingState = -1; } super(parent, invokingState); this.parser = parser; this.ruleIndex = PrometheusMetricsParser.RULE_label; this.name = null; this.value = null; } QUOTED_DENTIFIER = function(i) { if(i===undefined) { i = null; } if(i===null) { return this.getTokens(PrometheusMetricsParser.QUOTED_DENTIFIER); } else { return this.getToken(PrometheusMetricsParser.QUOTED_DENTIFIER, i); } }; IDENTIFIER() { return this.getToken(PrometheusMetricsParser.IDENTIFIER, 0); }; enterRule(listener) { if(listener instanceof PrometheusMetricsListener ) { listener.enterLabel(this); } } exitRule(listener) { if(listener instanceof PrometheusMetricsListener ) { listener.exitLabel(this); } } accept(visitor) { if ( visitor instanceof PrometheusMetricsVisitor ) { return visitor.visitLabel(this); } else { return visitor.visitChildren(this); } } } PrometheusMetricsParser.AllContext = AllContext; PrometheusMetricsParser.LineContext = LineContext; PrometheusMetricsParser.MetricContext = MetricContext; PrometheusMetricsParser.LabelContext = LabelContext;