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.

5,392 lines 71.9 kB
import antlr4, { ErrorListener, CommonTokenStream, InputStream, ParseTreeWalker } from 'antlr4';

class CustomMetricListener extends antlr4.tree.ParseTreeListener {
  // Enter a parse tree produced by CustomMetricParser#all.
  enterAll(ctx) {
  }
  // Exit a parse tree produced by CustomMetricParser#all.
  exitAll(ctx) {
  }
  // Enter a parse tree produced by CustomMetricParser#Function.
  enterFunction(ctx) {
  }
  // Exit a parse tree produced by CustomMetricParser#Function.
  exitFunction(ctx) {
  }
  // Enter a parse tree produced by CustomMetricParser#Addition.
  enterAddition(ctx) {
  }
  // Exit a parse tree produced by CustomMetricParser#Addition.
  exitAddition(ctx) {
  }
  // Enter a parse tree produced by CustomMetricParser#Multiplication.
  enterMultiplication(ctx) {
  }
  // Exit a parse tree produced by CustomMetricParser#Multiplication.
  exitMultiplication(ctx) {
  }
  // Enter a parse tree produced by CustomMetricParser#Subtraction.
  enterSubtraction(ctx) {
  }
  // Exit a parse tree produced by CustomMetricParser#Subtraction.
  exitSubtraction(ctx) {
  }
  // Enter a parse tree produced by CustomMetricParser#Number.
  enterNumber(ctx) {
  }
  // Exit a parse tree produced by CustomMetricParser#Number.
  exitNumber(ctx) {
  }
  // Enter a parse tree produced by CustomMetricParser#WrappedExpression.
  enterWrappedExpression(ctx) {
  }
  // Exit a parse tree produced by CustomMetricParser#WrappedExpression.
  exitWrappedExpression(ctx) {
  }
  // Enter a parse tree produced by CustomMetricParser#Division.
  enterDivision(ctx) {
  }
  // Exit a parse tree produced by CustomMetricParser#Division.
  exitDivision(ctx) {
  }
  // Enter a parse tree produced by CustomMetricParser#String.
  enterString(ctx) {
  }
  // Exit a parse tree produced by CustomMetricParser#String.
  exitString(ctx) {
  }
}

class CustomMetricVisitor extends antlr4.tree.ParseTreeVisitor {
  // Visit a parse tree produced by CustomMetricParser#all.
  visitAll(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CustomMetricParser#Function.
  visitFunction(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CustomMetricParser#Addition.
  visitAddition(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CustomMetricParser#Multiplication.
  visitMultiplication(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CustomMetricParser#Subtraction.
  visitSubtraction(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CustomMetricParser#Number.
  visitNumber(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CustomMetricParser#WrappedExpression.
  visitWrappedExpression(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CustomMetricParser#Division.
  visitDivision(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CustomMetricParser#String.
  visitString(ctx) {
    return this.visitChildren(ctx);
  }
}

const serializedATN$5 = [
  4,
  1,
  23,
  47,
  2,
  0,
  7,
  0,
  2,
  1,
  7,
  1,
  1,
  0,
  1,
  0,
  1,
  0,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  3,
  1,
  18,
  8,
  1,
  1,
  1,
  1,
  1,
  5,
  1,
  22,
  8,
  1,
  10,
  1,
  12,
  1,
  25,
  9,
  1,
  1,
  1,
  3,
  1,
  28,
  8,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  1,
  5,
  1,
  42,
  8,
  1,
  10,
  1,
  12,
  1,
  45,
  9,
  1,
  1,
  1,
  0,
  1,
  2,
  2,
  0,
  2,
  0,
  0,
  53,
  0,
  4,
  1,
  0,
  0,
  0,
  2,
  27,
  1,
  0,
  0,
  0,
  4,
  5,
  3,
  2,
  1,
  0,
  5,
  6,
  5,
  0,
  0,
  1,
  6,
  1,
  1,
  0,
  0,
  0,
  7,
  8,
  6,
  1,
  -1,
  0,
  8,
  9,
  5,
  12,
  0,
  0,
  9,
  10,
  3,
  2,
  1,
  0,
  10,
  11,
  5,
  13,
  0,
  0,
  11,
  28,
  1,
  0,
  0,
  0,
  12,
  28,
  5,
  2,
  0,
  0,
  13,
  28,
  5,
  3,
  0,
  0,
  14,
  15,
  5,
  4,
  0,
  0,
  15,
  17,
  5,
  12,
  0,
  0,
  16,
  18,
  3,
  2,
  1,
  0,
  17,
  16,
  1,
  0,
  0,
  0,
  17,
  18,
  1,
  0,
  0,
  0,
  18,
  23,
  1,
  0,
  0,
  0,
  19,
  20,
  5,
  1,
  0,
  0,
  20,
  22,
  3,
  2,
  1,
  0,
  21,
  19,
  1,
  0,
  0,
  0,
  22,
  25,
  1,
  0,
  0,
  0,
  23,
  21,
  1,
  0,
  0,
  0,
  23,
  24,
  1,
  0,
  0,
  0,
  24,
  26,
  1,
  0,
  0,
  0,
  25,
  23,
  1,
  0,
  0,
  0,
  26,
  28,
  5,
  13,
  0,
  0,
  27,
  7,
  1,
  0,
  0,
  0,
  27,
  12,
  1,
  0,
  0,
  0,
  27,
  13,
  1,
  0,
  0,
  0,
  27,
  14,
  1,
  0,
  0,
  0,
  28,
  43,
  1,
  0,
  0,
  0,
  29,
  30,
  10,
  8,
  0,
  0,
  30,
  31,
  5,
  6,
  0,
  0,
  31,
  42,
  3,
  2,
  1,
  9,
  32,
  33,
  10,
  7,
  0,
  0,
  33,
  34,
  5,
  7,
  0,
  0,
  34,
  42,
  3,
  2,
  1,
  8,
  35,
  36,
  10,
  6,
  0,
  0,
  36,
  37,
  5,
  8,
  0,
  0,
  37,
  42,
  3,
  2,
  1,
  7,
  38,
  39,
  10,
  5,
  0,
  0,
  39,
  40,
  5,
  9,
  0,
  0,
  40,
  42,
  3,
  2,
  1,
  6,
  41,
  29,
  1,
  0,
  0,
  0,
  41,
  32,
  1,
  0,
  0,
  0,
  41,
  35,
  1,
  0,
  0,
  0,
  41,
  38,
  1,
  0,
  0,
  0,
  42,
  45,
  1,
  0,
  0,
  0,
  43,
  41,
  1,
  0,
  0,
  0,
  43,
  44,
  1,
  0,
  0,
  0,
  44,
  3,
  1,
  0,
  0,
  0,
  45,
  43,
  1,
  0,
  0,
  0,
  5,
  17,
  23,
  27,
  41,
  43
];
const atn$5 = new antlr4.atn.ATNDeserializer().deserialize(serializedATN$5);
const decisionsToDFA$5 = atn$5.decisionToState.map((ds, index) => new antlr4.dfa.DFA(ds, index));
const sharedContextCache$2 = new antlr4.atn.PredictionContextCache();
class CustomMetricParser extends antlr4.Parser {
  static grammarFileName = "CustomMetric.g4";
  static literalNames = [
    null,
    "','",
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    "'.'",
    "'('",
    "')'",
    "'+'",
    "'-'",
    "'*'",
    "'/'",
    `'"'`,
    "' '"
  ];
  static symbolicNames = [
    null,
    null,
    "NUMBER",
    "STRING",
    "FN",
    "WHITESPACE",
    "ADD",
    "SUBTRACT",
    "MULTIPLY",
    "DIVIDE",
    "DIGIT",
    "DOT",
    "L_PARANT",
    "R_PARANT",
    "PLUS",
    "MINUS",
    "STAR",
    "SLASH",
    "DQUOTE",
    "SPACE",
    "TAB",
    "CR",
    "LF",
    "ANY"
  ];
  static ruleNames = ["all", "expression"];
  constructor(input) {
    super(input);
    this._interp = new antlr4.atn.ParserATNSimulator(this, atn$5, decisionsToDFA$5, sharedContextCache$2);
    this.ruleNames = CustomMetricParser.ruleNames;
    this.literalNames = CustomMetricParser.literalNames;
    this.symbolicNames = CustomMetricParser.symbolicNames;
  }
  sempred(localctx, ruleIndex, predIndex) {
    switch (ruleIndex) {
      case 1:
        return this.expression_sempred(localctx, predIndex);
      default:
        throw "No predicate with index:" + ruleIndex;
    }
  }
  expression_sempred(localctx, predIndex) {
    switch (predIndex) {
      case 0:
        return this.precpred(this._ctx, 8);
      case 1:
        return this.precpred(this._ctx, 7);
      case 2:
        return this.precpred(this._ctx, 6);
      case 3:
        return this.precpred(this._ctx, 5);
      default:
        throw "No predicate with index:" + predIndex;
    }
  }
  all() {
    let localctx = new AllContext$2(this, this._ctx, this.state);
    this.enterRule(localctx, 0, CustomMetricParser.RULE_all);
    try {
      this.enterOuterAlt(localctx, 1);
      this.state = 4;
      this.expression(0);
      this.state = 5;
      this.match(CustomMetricParser.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;
  }
  expression(_p) {
    if (_p === void 0) {
      _p = 0;
    }
    const _parentctx = this._ctx;
    const _parentState = this.state;
    let localctx = new ExpressionContext(this, this._ctx, _parentState);
    let _prevctx = localctx;
    const _startState = 2;
    this.enterRecursionRule(localctx, 2, CustomMetricParser.RULE_expression, _p);
    var _la = 0;
    try {
      this.enterOuterAlt(localctx, 1);
      this.state = 27;
      this._errHandler.sync(this);
      switch (this._input.LA(1)) {
        case 12:
          localctx = new WrappedExpressionContext(this, localctx);
          this._ctx = localctx;
          _prevctx = localctx;
          this.state = 8;
          this.match(CustomMetricParser.L_PARANT);
          this.state = 9;
          this.expression(0);
          this.state = 10;
          this.match(CustomMetricParser.R_PARANT);
          break;
        case 2:
          localctx = new NumberContext(this, localctx);
          this._ctx = localctx;
          _prevctx = localctx;
          this.state = 12;
          this.match(CustomMetricParser.NUMBER);
          break;
        case 3:
          localctx = new StringContext(this, localctx);
          this._ctx = localctx;
          _prevctx = localctx;
          this.state = 13;
          this.match(CustomMetricParser.STRING);
          break;
        case 4:
          localctx = new FunctionContext(this, localctx);
          this._ctx = localctx;
          _prevctx = localctx;
          this.state = 14;
          this.match(CustomMetricParser.FN);
          this.state = 15;
          this.match(CustomMetricParser.L_PARANT);
          this.state = 17;
          this._errHandler.sync(this);
          _la = this._input.LA(1);
          if ((_la & ~31) === 0 && (1 << _la & 4124) !== 0) {
            this.state = 16;
            this.expression(0);
          }
          this.state = 23;
          this._errHandler.sync(this);
          _la = this._input.LA(1);
          while (_la === 1) {
            this.state = 19;
            this.match(CustomMetricParser.T__0);
            this.state = 20;
            this.expression(0);
            this.state = 25;
            this._errHandler.sync(this);
            _la = this._input.LA(1);
          }
          this.state = 26;
          this.match(CustomMetricParser.R_PARANT);
          break;
        default:
          throw new antlr4.error.NoViableAltException(this);
      }
      this._ctx.stop = this._input.LT(-1);
      this.state = 43;
      this._errHandler.sync(this);
      var _alt = this._interp.adaptivePredict(this._input, 4, 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 = 41;
          this._errHandler.sync(this);
          var la_ = this._interp.adaptivePredict(this._input, 3, this._ctx);
          switch (la_) {
            case 1:
              localctx = new AdditionContext(this, new ExpressionContext(this, _parentctx, _parentState));
              localctx.left = _prevctx;
              this.pushNewRecursionContext(localctx, _startState, CustomMetricParser.RULE_expression);
              this.state = 29;
              if (!this.precpred(this._ctx, 8)) {
                throw new antlr4.error.FailedPredicateException(this, "this.precpred(this._ctx, 8)");
              }
              this.state = 30;
              this.match(CustomMetricParser.ADD);
              this.state = 31;
              localctx.right = this.expression(9);
              break;
            case 2:
              localctx = new SubtractionContext(this, new ExpressionContext(this, _parentctx, _parentState));
              localctx.left = _prevctx;
              this.pushNewRecursionContext(localctx, _startState, CustomMetricParser.RULE_expression);
              this.state = 32;
              if (!this.precpred(this._ctx, 7)) {
                throw new antlr4.error.FailedPredicateException(this, "this.precpred(this._ctx, 7)");
              }
              this.state = 33;
              this.match(CustomMetricParser.SUBTRACT);
              this.state = 34;
              localctx.right = this.expression(8);
              break;
            case 3:
              localctx = new MultiplicationContext(this, new ExpressionContext(this, _parentctx, _parentState));
              localctx.left = _prevctx;
              this.pushNewRecursionContext(localctx, _startState, CustomMetricParser.RULE_expression);
              this.state = 35;
              if (!this.precpred(this._ctx, 6)) {
                throw new antlr4.error.FailedPredicateException(this, "this.precpred(this._ctx, 6)");
              }
              this.state = 36;
              this.match(CustomMetricParser.MULTIPLY);
              this.state = 37;
              localctx.right = this.expression(7);
              break;
            case 4:
              localctx = new DivisionContext(this, new ExpressionContext(this, _parentctx, _parentState));
              localctx.left = _prevctx;
              this.pushNewRecursionContext(localctx, _startState, CustomMetricParser.RULE_expression);
              this.state = 38;
              if (!this.precpred(this._ctx, 5)) {
                throw new antlr4.error.FailedPredicateException(this, "this.precpred(this._ctx, 5)");
              }
              this.state = 39;
              this.match(CustomMetricParser.DIVIDE);
              this.state = 40;
              localctx.right = this.expression(6);
              break;
          }
        }
        this.state = 45;
        this._errHandler.sync(this);
        _alt = this._interp.adaptivePredict(this._input, 4, this._ctx);
      }
    } catch (error) {
      if (error instanceof antlr4.error.RecognitionException) {
        localctx.exception = error;
        this._errHandler.reportError(this, error);
        this._errHandler.recover(this, error);
      } else {
        throw error;
      }
    } finally {
      this.unrollRecursionContexts(_parentctx);
    }
    return localctx;
  }
}
CustomMetricParser.EOF = antlr4.Token.EOF;
CustomMetricParser.T__0 = 1;
CustomMetricParser.NUMBER = 2;
CustomMetricParser.STRING = 3;
CustomMetricParser.FN = 4;
CustomMetricParser.WHITESPACE = 5;
CustomMetricParser.ADD = 6;
CustomMetricParser.SUBTRACT = 7;
CustomMetricParser.MULTIPLY = 8;
CustomMetricParser.DIVIDE = 9;
CustomMetricParser.DIGIT = 10;
CustomMetricParser.DOT = 11;
CustomMetricParser.L_PARANT = 12;
CustomMetricParser.R_PARANT = 13;
CustomMetricParser.PLUS = 14;
CustomMetricParser.MINUS = 15;
CustomMetricParser.STAR = 16;
CustomMetricParser.SLASH = 17;
CustomMetricParser.DQUOTE = 18;
CustomMetricParser.SPACE = 19;
CustomMetricParser.TAB = 20;
CustomMetricParser.CR = 21;
CustomMetricParser.LF = 22;
CustomMetricParser.ANY = 23;
CustomMetricParser.RULE_all = 0;
CustomMetricParser.RULE_expression = 1;
let AllContext$2 = class AllContext extends antlr4.ParserRuleContext {
  constructor(parser, parent, invokingState) {
    if (parent === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || invokingState === null) {
      invokingState = -1;
    }
    super(parent, invokingState);
    this.parser = parser;
    this.ruleIndex = CustomMetricParser.RULE_all;
  }
  expression() {
    return this.getTypedRuleContext(ExpressionContext, 0);
  }
  EOF() {
    return this.getToken(CustomMetricParser.EOF, 0);
  }
  enterRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.enterAll(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.exitAll(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CustomMetricVisitor) {
      return visitor.visitAll(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
};
class ExpressionContext extends antlr4.ParserRuleContext {
  constructor(parser, parent, invokingState) {
    if (parent === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || invokingState === null) {
      invokingState = -1;
    }
    super(parent, invokingState);
    this.parser = parser;
    this.ruleIndex = CustomMetricParser.RULE_expression;
  }
  copyFrom(ctx) {
    super.copyFrom(ctx);
  }
}
class FunctionContext extends ExpressionContext {
  constructor(parser, ctx) {
    super(parser);
    super.copyFrom(ctx);
  }
  FN() {
    return this.getToken(CustomMetricParser.FN, 0);
  }
  L_PARANT() {
    return this.getToken(CustomMetricParser.L_PARANT, 0);
  }
  R_PARANT() {
    return this.getToken(CustomMetricParser.R_PARANT, 0);
  }
  expression = function(i) {
    if (i === void 0) {
      i = null;
    }
    if (i === null) {
      return this.getTypedRuleContexts(ExpressionContext);
    } else {
      return this.getTypedRuleContext(ExpressionContext, i);
    }
  };
  enterRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.enterFunction(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.exitFunction(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CustomMetricVisitor) {
      return visitor.visitFunction(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
CustomMetricParser.FunctionContext = FunctionContext;
class AdditionContext extends ExpressionContext {
  constructor(parser, ctx) {
    super(parser);
    this.left = null;
    this.right = null;
    super.copyFrom(ctx);
  }
  ADD() {
    return this.getToken(CustomMetricParser.ADD, 0);
  }
  expression = function(i) {
    if (i === void 0) {
      i = null;
    }
    if (i === null) {
      return this.getTypedRuleContexts(ExpressionContext);
    } else {
      return this.getTypedRuleContext(ExpressionContext, i);
    }
  };
  enterRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.enterAddition(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.exitAddition(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CustomMetricVisitor) {
      return visitor.visitAddition(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
CustomMetricParser.AdditionContext = AdditionContext;
class MultiplicationContext extends ExpressionContext {
  constructor(parser, ctx) {
    super(parser);
    this.left = null;
    this.right = null;
    super.copyFrom(ctx);
  }
  MULTIPLY() {
    return this.getToken(CustomMetricParser.MULTIPLY, 0);
  }
  expression = function(i) {
    if (i === void 0) {
      i = null;
    }
    if (i === null) {
      return this.getTypedRuleContexts(ExpressionContext);
    } else {
      return this.getTypedRuleContext(ExpressionContext, i);
    }
  };
  enterRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.enterMultiplication(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.exitMultiplication(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CustomMetricVisitor) {
      return visitor.visitMultiplication(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
CustomMetricParser.MultiplicationContext = MultiplicationContext;
class SubtractionContext extends ExpressionContext {
  constructor(parser, ctx) {
    super(parser);
    this.left = null;
    this.right = null;
    super.copyFrom(ctx);
  }
  SUBTRACT() {
    return this.getToken(CustomMetricParser.SUBTRACT, 0);
  }
  expression = function(i) {
    if (i === void 0) {
      i = null;
    }
    if (i === null) {
      return this.getTypedRuleContexts(ExpressionContext);
    } else {
      return this.getTypedRuleContext(ExpressionContext, i);
    }
  };
  enterRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.enterSubtraction(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.exitSubtraction(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CustomMetricVisitor) {
      return visitor.visitSubtraction(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
CustomMetricParser.SubtractionContext = SubtractionContext;
class NumberContext extends ExpressionContext {
  constructor(parser, ctx) {
    super(parser);
    super.copyFrom(ctx);
  }
  NUMBER() {
    return this.getToken(CustomMetricParser.NUMBER, 0);
  }
  enterRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.enterNumber(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.exitNumber(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CustomMetricVisitor) {
      return visitor.visitNumber(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
CustomMetricParser.NumberContext = NumberContext;
class WrappedExpressionContext extends ExpressionContext {
  constructor(parser, ctx) {
    super(parser);
    super.copyFrom(ctx);
  }
  L_PARANT() {
    return this.getToken(CustomMetricParser.L_PARANT, 0);
  }
  expression() {
    return this.getTypedRuleContext(ExpressionContext, 0);
  }
  R_PARANT() {
    return this.getToken(CustomMetricParser.R_PARANT, 0);
  }
  enterRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.enterWrappedExpression(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.exitWrappedExpression(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CustomMetricVisitor) {
      return visitor.visitWrappedExpression(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
CustomMetricParser.WrappedExpressionContext = WrappedExpressionContext;
class DivisionContext extends ExpressionContext {
  constructor(parser, ctx) {
    super(parser);
    this.left = null;
    this.right = null;
    super.copyFrom(ctx);
  }
  DIVIDE() {
    return this.getToken(CustomMetricParser.DIVIDE, 0);
  }
  expression = function(i) {
    if (i === void 0) {
      i = null;
    }
    if (i === null) {
      return this.getTypedRuleContexts(ExpressionContext);
    } else {
      return this.getTypedRuleContext(ExpressionContext, i);
    }
  };
  enterRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.enterDivision(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.exitDivision(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CustomMetricVisitor) {
      return visitor.visitDivision(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
CustomMetricParser.DivisionContext = DivisionContext;
class StringContext extends ExpressionContext {
  constructor(parser, ctx) {
    super(parser);
    super.copyFrom(ctx);
  }
  STRING() {
    return this.getToken(CustomMetricParser.STRING, 0);
  }
  enterRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.enterString(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CustomMetricListener) {
      listener.exitString(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CustomMetricVisitor) {
      return visitor.visitString(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
CustomMetricParser.StringContext = StringContext;
CustomMetricParser.AllContext = AllContext$2;
CustomMetricParser.ExpressionContext = ExpressionContext;

const serializedATN$4 = [
  4,
  0,
  23,
  124,
  6,
  -1,
  2,
  0,
  7,
  0,
  2,
  1,
  7,
  1,
  2,
  2,
  7,
  2,
  2,
  3,
  7,
  3,
  2,
  4,
  7,
  4,
  2,
  5,
  7,
  5,
  2,
  6,
  7,
  6,
  2,
  7,
  7,
  7,
  2,
  8,
  7,
  8,
  2,
  9,
  7,
  9,
  2,
  10,
  7,
  10,
  2,
  11,
  7,
  11,
  2,
  12,
  7,
  12,
  2,
  13,
  7,
  13,
  2,
  14,
  7,
  14,
  2,
  15,
  7,
  15,
  2,
  16,
  7,
  16,
  2,
  17,
  7,
  17,
  2,
  18,
  7,
  18,
  2,
  19,
  7,
  19,
  2,
  20,
  7,
  20,
  2,
  21,
  7,
  21,
  2,
  22,
  7,
  22,
  1,
  0,
  1,
  0,
  1,
  1,
  3,
  1,
  51,
  8,
  1,
  1,
  1,
  4,
  1,
  54,
  8,
  1,
  11,
  1,
  12,
  1,
  55,
  1,
  1,
  1,
  1,
  4,
  1,
  60,
  8,
  1,
  11,
  1,
  12,
  1,
  61,
  3,
  1,
  64,
  8,
  1,
  1,
  2,
  1,
  2,
  4,
  2,
  68,
  8,
  2,
  11,
  2,
  12,
  2,
  69,
  1,
  2,
  1,
  2,
  1,
  3,
  4,
  3,
  75,
  8,
  3,
  11,
  3,
  12,
  3,
  76,
  1,
  4,
  1,
  4,
  1,
  4,
  1,
  4,
  4,
  4,
  83,
  8,
  4,
  11,
  4,
  12,
  4,
  84,
  1,
  4,
  1,
  4,
  1,
  5,
  1,
  5,
  1,
  6,
  1,
  6,
  1,
  7,
  1,
  7,
  1,
  8,
  1,
  8,
  1,
  9,
  1,
  9,
  1,
  10,
  1,
  10,
  1,
  11,
  1,
  11,
  1,
  12,
  1,
  12,
  1,
  13,
  1,
  13,
  1,
  14,
  1,
  14,
  1,
  15,
  1,
  15,
  1,
  16,
  1,
  16,
  1,
  17,
  1,
  17,
  1,
  18,
  1,
  18,
  1,
  19,
  1,
  19,
  1,
  20,
  1,
  20,
  1,
  21,
  1,
  21,
  1,
  22,
  1,
  22,
  1,
  69,
  0,
  23,
  1,
  1,
  3,
  2,
  5,
  3,
  7,
  4,
  9,
  5,
  11,
  6,
  13,
  7,
  15,
  8,
  17,
  9,
  19,
  10,
  21,
  11,
  23,
  12,
  25,
  13,
  27,
  14,
  29,
  15,
  31,
  16,
  33,
  17,
  35,
  18,
  37,
  19,
  39,
  20,
  41,
  21,
  43,
  22,
  45,
  23,
  1,
  0,
  5,
  2,
  0,
  65,
  90,
  97,
  122,
  1,
  0,
  48,
  57,
  1,
  0,
  9,
  9,
  1,
  0,
  13,
  13,
  1,
  0,
  10,
  10,
  133,
  0,
  1,
  1,
  0,
  0,
  0,
  0,
  3,
  1,
  0,
  0,
  0,
  0,
  5,
  1,
  0,
  0,
  0,
  0,
  7,
  1,
  0,
  0,
  0,
  0,
  9,
  1,
  0,
  0,
  0,
  0,
  11,
  1,
  0,
  0,
  0,
  0,
  13,
  1,
  0,
  0,
  0,
  0,
  15,
  1,
  0,
  0,
  0,
  0,
  17,
  1,
  0,
  0,
  0,
  0,
  19,
  1,
  0,
  0,
  0,
  0,
  21,
  1,
  0,
  0,
  0,
  0,
  23,
  1,
  0,
  0,
  0,
  0,
  25,
  1,
  0,
  0,
  0,
  0,
  27,
  1,
  0,
  0,
  0,
  0,
  29,
  1,
  0,
  0,
  0,
  0,
  31,
  1,
  0,
  0,
  0,
  0,
  33,
  1,
  0,
  0,
  0,
  0,
  35,
  1,
  0,
  0,
  0,
  0,
  37,
  1,
  0,
  0,
  0,
  0,
  39,
  1,
  0,
  0,
  0,
  0,
  41,
  1,
  0,
  0,
  0,
  0,
  43,
  1,
  0,
  0,
  0,
  0,
  45,
  1,
  0,
  0,
  0,
  1,
  47,
  1,
  0,
  0,
  0,
  3,
  50,
  1,
  0,
  0,
  0,
  5,
  65,
  1,
  0,
  0,
  0,
  7,
  74,
  1,
  0,
  0,
  0,
  9,
  82,
  1,
  0,
  0,
  0,
  11,
  88,
  1,
  0,
  0,
  0,
  13,
  90,
  1,
  0,
  0,
  0,
  15,
  92,
  1,
  0,
  0,
  0,
  17,
  94,
  1,
  0,
  0,
  0,
  19,
  96,
  1,
  0,
  0,
  0,
  21,
  98,
  1,
  0,
  0,
  0,
  23,
  100,
  1,
  0,
  0,
  0,
  25,
  102,
  1,
  0,
  0,
  0,
  27,
  104,
  1,
  0,
  0,
  0,
  29,
  106,
  1,
  0,
  0,
  0,
  31,
  108,
  1,
  0,
  0,
  0,
  33,
  110,
  1,
  0,
  0,
  0,
  35,
  112,
  1,
  0,
  0,
  0,
  37,
  114,
  1,
  0,
  0,
  0,
  39,
  116,
  1,
  0,
  0,
  0,
  41,
  118,
  1,
  0,
  0,
  0,
  43,
  120,
  1,
  0,
  0,
  0,
  45,
  122,
  1,
  0,
  0,
  0,
  47,
  48,
  5,
  44,
  0,
  0,
  48,
  2,
  1,
  0,
  0,
  0,
  49,
  51,
  3,
  29,
  14,
  0,
  50,
  49,
  1,
  0,
  0,
  0,
  50,
  51,
  1,
  0,
  0,
  0,
  51,
  53,
  1,
  0,
  0,
  0,
  52,
  54,
  3,
  19,
  9,
  0,
  53,
  52,
  1,
  0,
  0,
  0,
  54,
  55,
  1,
  0,
  0,
  0,
  55,
  53,
  1,
  0,
  0,
  0,
  55,
  56,
  1,
  0,
  0,
  0,
  56,
  63,
  1,
  0,
  0,
  0,
  57,
  59,
  3,
  21,
  10,
  0,
  58,
  60,
  3,
  19,
  9,
  0,
  59,
  58,
  1,
  0,
  0,
  0,
  60,
  61,
  1,
  0,
  0,
  0,
  61,
  59,
  1,
  0,
  0,
  0,
  61,
  62,
  1,
  0,
  0,
  0,
  62,
  64,
  1,
  0,
  0,
  0,
  63,
  57,
  1,
  0,
  0,
  0,
  63,
  64,
  1,
  0,
  0,
  0,
  64,
  4,
  1,
  0,
  0,
  0,
  65,
  67,
  3,
  35,
  17,
  0,
  66,
  68,
  3,
  45,
  22,
  0,
  67,
  66,
  1,
  0,
  0,
  0,
  68,
  69,
  1,
  0,
  0,
  0,
  69,
  70,
  1,
  0,
  0,
  0,
  69,
  67,
  1,
  0,
  0,
  0,
  70,
  71,
  1,
  0,
  0,
  0,
  71,
  72,
  3,
  35,
  17,
  0,
  72,
  6,
  1,
  0,
  0,
  0,
  73,
  75,
  7,
  0,
  0,
  0,
  74,
  73,
  1,
  0,
  0,
  0,
  75,
  76,
  1,
  0,
  0,
  0,
  76,
  74,
  1,
  0,
  0,
  0,
  76,
  77,
  1,
  0,
  0,
  0,
  77,
  8,
  1,
  0,
  0,
  0,
  78,
  83,
  3,
  37,
  18,
  0,
  79,
  83,
  3,
  39,
  19,
  0,
  80,
  83,
  3,
  41,
  20,
  0,
  81,
  83,
  3,
  43,
  21,
  0,
  82,
  78,
  1,
  0,
  0,
  0,
  82,
  79,
  1,
  0,
  0,
  0,
  82,
  80,
  1,
  0,
  0,
  0,
  82,
  81,
  1,
  0,
  0,
  0,
  83,
  84,
  1,
  0,
  0,
  0,
  84,
  82,
  1,
  0,
  0,
  0,
  84,
  85,
  1,
  0,
  0,
  0,
  85,
  86,
  1,
  0,
  0,
  0,
  86,
  87,
  6,
  4,
  0,
  0,
  87,
  10,
  1,
  0,
  0,
  0,
  88,
  89,
  3,
  27,
  13,
  0,
  89,
  12,
  1,
  0,
  0,
  0,
  90,
  91,
  3,
  29,
  14,
  0,
  91,
  14,
  1,
  0,
  0,
  0,
  92,
  93,
  3,
  31,
  15,
  0,
  93,
  16,
  1,
  0,
  0,
  0,
  94,
  95,
  3,
  33,
  16,
  0,
  95,
  18,
  1,
  0,
  0,
  0,
  96,
  97,
  7,
  1,
  0,
  0,
  97,
  20,
  1,
  0,
  0,
  0,
  98,
  99,
  5,
  46,
  0,
  0,
  99,
  22,
  1,
  0,
  0,
  0,
  100,
  101,
  5,
  40,
  0,
  0,
  101,
  24,
  1,
  0,
  0,
  0,
  102,
  103,
  5,
  41,
  0,
  0,
  103,
  26,
  1,
  0,
  0,
  0,
  104,
  105,
  5,
  43,
  0,
  0,
  105,
  28,
  1,
  0,
  0,
  0,
  106,
  107,
  5,
  45,
  0,
  0,
  107,
  30,
  1,
  0,
  0,
  0,
  108,
  109,
  5,
  42,
  0,
  0,
  109,
  32,
  1,
  0,
  0,
  0,
  110,
  111,
  5,
  47,
  0,
  0,
  111,
  34,
  1,
  0,
  0,
  0,
  112,
  113,
  5,
  34,
  0,
  0,
  113,
  36,
  1,
  0,
  0,
  0,
  114,
  115,
  5,
  32,
  0,
  0,
  115,
  38,
  1,
  0,
  0,
  0,
  116,
  117,
  7,
  2,
  0,
  0,
  117,
  40,
  1,
  0,
  0,
  0,
  118,
  119,
  7,
  3,
  0,
  0,
  119,
  42,
  1,
  0,
  0,
  0,
  120,
  121,
  7,
  4,
  0,
  0,
  121,
  44,
  1,
  0,
  0,
  0,
  122,
  123,
  9,
  0,
  0,
  0,
  123,
  46,
  1,
  0,
  0,
  0,
  9,
  0,
  50,
  55,
  61,
  63,
  69,
  76,
  82,
  84,
  1,
  6,
  0,
  0
];
const atn$4 = new antlr4.atn.ATNDeserializer().deserialize(serializedATN$4);
const decisionsToDFA$4 = atn$4.decisionToState.map((ds, index) => new antlr4.dfa.DFA(ds, index));
class CustomMetricLexer extends antlr4.Lexer {
  static grammarFileName = "CustomMetric.g4";
  static channelNames = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"];
  static modeNames = ["DEFAULT_MODE"];
  static literalNames = [
    null,
    "','",
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    "'.'",
    "'('",
    "')'",
    "'+'",
    "'-'",
    "'*'",
    "'/'",
    `'"'`,
    "' '"
  ];
  static symbolicNames = [
    null,
    null,
    "NUMBER",
    "STRING",
    "FN",
    "WHITESPACE",
    "ADD",
    "SUBTRACT",
    "MULTIPLY",
    "DIVIDE",
    "DIGIT",
    "DOT",
    "L_PARANT",
    "R_PARANT",
    "PLUS",
    "MINUS",
    "STAR",
    "SLASH",
    "DQUOTE",
    "SPACE",
    "TAB",
    "CR",
    "LF",
    "ANY"
  ];
  static ruleNames = [
    "T__0",
    "NUMBER",
    "STRING",
    "FN",
    "WHITESPACE",
    "ADD",
    "SUBTRACT",
    "MULTIPLY",
    "DIVIDE",
    "DIGIT",
    "DOT",
    "L_PARANT",
    "R_PARANT",
    "PLUS",
    "MINUS",
    "STAR",
    "SLASH",
    "DQUOTE",
    "SPACE",
    "TAB",
    "CR",
    "LF",
    "ANY"
  ];
  constructor(input) {
    super(input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn$4, decisionsToDFA$4, new antlr4.atn.PredictionContextCache());
  }
}
CustomMetricLexer.EOF = antlr4.Token.EOF;
CustomMetricLexer.T__0 = 1;
CustomMetricLexer.NUMBER = 2;
CustomMetricLexer.STRING = 3;
CustomMetricLexer.FN = 4;
CustomMetricLexer.WHITESPACE = 5;
CustomMetricLexer.ADD = 6;
CustomMetricLexer.SUBTRACT = 7;
CustomMetricLexer.MULTIPLY = 8;
CustomMetricLexer.DIVIDE = 9;
CustomMetricLexer.DIGIT = 10;
CustomMetricLexer.DOT = 11;
CustomMetricLexer.L_PARANT = 12;
CustomMetricLexer.R_PARANT = 13;
CustomMetricLexer.PLUS = 14;
CustomMetricLexer.MINUS = 15;
CustomMetricLexer.STAR = 16;
CustomMetricLexer.SLASH = 17;
CustomMetricLexer.DQUOTE = 18;
CustomMetricLexer.SPACE = 19;
CustomMetricLexer.TAB = 20;
CustomMetricLexer.CR = 21;
CustomMetricLexer.LF = 22;
CustomMetricLexer.ANY = 23;

const serializedATN$3 = [
  4,
  0,
  5,
  33,
  6,
  -1,
  2,
  0,
  7,
  0,
  2,
  1,
  7,
  1,
  2,
  2,
  7,
  2,
  2,
  3,
  7,
  3,
  2,
  4,
  7,
  4,
  1,
  0,
  1,
  0,
  1,
  1,
  1,
  1,
  1,
  2,
  4,
  2,
  17,
  8,
  2,
  11,
  2,
  12,
  2,
  18,
  1,
  3,
  1,
  3,
  1,
  3,
  1,
  3,
  5,
  3,
  25,
  8,
  3,
  10,
  3,
  12,
  3,
  28,
  9,
  3,
  1,
  3,
  1,
  3,
  1,
  4,
  1,
  4,
  0,
  0,
  5,
  1,
  1,
  3,
  2,
  5,
  3,
  7,
  4,
  9,
  5,
  1,
  0,
  3,
  4,
  0,
  10,
  10,
  13,
  13,
  44,
  44,
  59,
  59,
  1,
  0,
  34,
  34,
  2,
  0,
  44,
  44,
  59,
  59,
  35,
  0,
  1,
  1,
  0,
  0,
  0,
  0,
  3,
  1,
  0,
  0,
  0,
  0,
  5,
  1,
  0,
  0,
  0,
  0,
  7,
  1,
  0,
  0,
  0,
  0,
  9,
  1,
  0,
  0,
  0,
  1,
  11,
  1,
  0,
  0,
  0,
  3,
  13,
  1,
  0,
  0,
  0,
  5,
  16,
  1,
  0,
  0,
  0,
  7,
  20,
  1,
  0,
  0,
  0,
  9,
  31,
  1,
  0,
  0,
  0,
  11,
  12,
  5,
  13,
  0,
  0,
  12,
  2,
  1,
  0,
  0,
  0,
  13,
  14,
  5,
  10,
  0,
  0,
  14,
  4,
  1,
  0,
  0,
  0,
  15,
  17,
  8,
  0,
  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,
  6,
  1,
  0,
  0,
  0,
  20,
  26,
  5,
  34,
  0,
  0,
  21,
  22,
  5,
  34,
  0,
  0,
  22,
  25,
  5,
  34,
  0,
  0,
  23,
  25,
  8,
  1,
  0,
  0,
  24,
  21,
  1,
  0,
  0,
  0,
  24,
  23,
  1,
  0,
  0,
  0,
  25,
  28,
  1,
  0,
  0,
  0,
  26,
  24,
  1,
  0,
  0,
  0,
  26,
  27,
  1,
  0,
  0,
  0,
  27,
  29,
  1,
  0,
  0,
  0,
  28,
  26,
  1,
  0,
  0,
  0,
  29,
  30,
  5,
  34,
  0,
  0,
  30,
  8,
  1,
  0,
  0,
  0,
  31,
  32,
  7,
  2,
  0,
  0,
  32,
  10,
  1,
  0,
  0,
  0,
  4,
  0,
  18,
  24,
  26,
  0
];
const atn$3 = new antlr4.atn.ATNDeserializer().deserialize(serializedATN$3);
const decisionsToDFA$3 = atn$3.decisionToState.map((ds, index) => new antlr4.dfa.DFA(ds, index));
class CSVLexer extends antlr4.Lexer {
  static grammarFileName = "CSV.g4";
  static channelNames = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"];
  static modeNames = ["DEFAULT_MODE"];
  static literalNames = [null, "'\\r'", "'\\n'"];
  static symbolicNames = [null, null, null, "UNQUOTED", "QUOTED", "DELIMITER"];
  static ruleNames = ["T__0", "T__1", "UNQUOTED", "QUOTED", "DELIMITER"];
  constructor(input) {
    super(input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn$3, decisionsToDFA$3, new antlr4.atn.PredictionContextCache());
  }
}
CSVLexer.EOF = antlr4.Token.EOF;
CSVLexer.T__0 = 1;
CSVLexer.T__1 = 2;
CSVLexer.UNQUOTED = 3;
CSVLexer.QUOTED = 4;
CSVLexer.DELIMITER = 5;

class CSVListener extends antlr4.tree.ParseTreeListener {
  // Enter a parse tree produced by CSVParser#all.
  enterAll(ctx) {
  }
  // Exit a parse tree produced by CSVParser#all.
  exitAll(ctx) {
  }
  // Enter a parse tree produced by CSVParser#headers.
  enterHeaders(ctx) {
  }
  // Exit a parse tree produced by CSVParser#headers.
  exitHeaders(ctx) {
  }
  // Enter a parse tree produced by CSVParser#line.
  enterLine(ctx) {
  }
  // Exit a parse tree produced by CSVParser#line.
  exitLine(ctx) {
  }
  // Enter a parse tree produced by CSVParser#column.
  enterColumn(ctx) {
  }
  // Exit a parse tree produced by CSVParser#column.
  exitColumn(ctx) {
  }
}

class CSVVisitor extends antlr4.tree.ParseTreeVisitor {
  // Visit a parse tree produced by CSVParser#all.
  visitAll(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CSVParser#headers.
  visitHeaders(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CSVParser#line.
  visitLine(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by CSVParser#column.
  visitColumn(ctx) {
    return this.visitChildren(ctx);
  }
}

const serializedATN$2 = [
  4,
  1,
  5,
  37,
  2,
  0,
  7,
  0,
  2,
  1,
  7,
  1,
  2,
  2,
  7,
  2,
  2,
  3,
  7,
  3,
  1,
  0,
  1,
  0,
  3,
  0,
  11,
  8,
  0,
  1,
  0,
  1,
  0,
  5,
  0,
  15,
  8,
  0,
  10,
  0,
  12,
  0,
  18,
  9,
  0,
  1,
  0,
  1,
  0,
  1,
  1,
  1,
  1,
  1,
  2,
  1,
  2,
  1,
  2,
  5,
  2,
  27,
  8,
  2,
  10,
  2,
  12,
  2,
  30,
  9,
  2,
  1,
  3,
  1,
  3,
  1,
  3,
  3,
  3,
  35,
  8,
  3,
  1,
  3,
  0,
  0,
  4,
  0,
  2,
  4,
  6,
  0,
  0,
  37,
  0,
  8,
  1,
  0,
  0,
  0,
  2,
  21,
  1,
  0,
  0,
  0,
  4,
  23,
  1,
  0,
  0,
  0,
  6,
  34,
  1,
  0,
  0,
  0,
  8,
  16,
  3,
  2,
  1,
  0,
  9,
  11,
  5,
  1,
  0,
  0,
  10,
  9,
  1,
  0,
  0,
  0,
  10,
  11,
  1,
  0,
  0,
  0,
  11,
  12,
  1,
  0,
  0,
  0,
  12,
  13,
  5,
  2,
  0,
  0,
  13,
  15,
  3,
  4,
  2,
  0,
  14,
  10,
  1,
  0,
  0,
  0,
  15,
  18,
  1,
  0,
  0,
  0,
  16,
  14,
  1,
  0,
  0,
  0,
  16,
  17,
  1,
  0,
  0,
  0,
  17,
  19,
  1,
  0,
  0,
  0,
  18,
  16,
  1,
  0,
  0,
  0,
  19,
  20,
  5,
  0,
  0,
  1,
  20,
  1,
  1,
  0,
  0,
  0,
  21,
  22,
  3,
  4,
  2,
  0,
  22,
  3,
  1,
  0,
  0,
  0,
  23,
  28,
  3,
  6,
  3,
  0,
  24,
  25,
  5,
  5,
  0,
  0,
  25,
  27,
  3,
  6,
  3,
  0,
  26,
  24,
  1,
  0,
  0,
  0,
  27,
  30,
  1,
  0,
  0,
  0,
  28,
  26,
  1,
  0,
  0,
  0,
  28,
  29,
  1,
  0,
  0,
  0,
  29,
  5,
  1,
  0,
  0,
  0,
  30,
  28,
  1,
  0,
  0,
  0,
  31,
  35,
  5,
  3,
  0,
  0,
  32,
  35,
  5,
  4,
  0,
  0,
  33,
  35,
  1,
  0,
  0,
  0,
  34,
  31,
  1,
  0,
  0,
  0,
  34,
  32,
  1,
  0,
  0,
  0,
  34,
  33,
  1,
  0,
  0,
  0,
  35,
  7,
  1,
  0,
  0,
  0,
  4,
  10,
  16,
  28,
  34
];
const atn$2 = new antlr4.atn.ATNDeserializer().deserialize(serializedATN$2);
const decisionsToDFA$2 = atn$2.decisionToState.map((ds, index) => new antlr4.dfa.DFA(ds, index));
const sharedContextCache$1 = new antlr4.atn.PredictionContextCache();
class CSVParser extends antlr4.Parser {
  static grammarFileName = "CSV.g4";
  static literalNames = [null, "'\\r'", "'\\n'"];
  static symbolicNames = [null, null, null, "UNQUOTED", "QUOTED", "DELIMITER"];
  static ruleNames = ["all", "headers", "line", "column"];
  constructor(input) {
    super(input);
    this._interp = new antlr4.atn.ParserATNSimulator(this, atn$2, decisionsToDFA$2, sharedContextCache$1);
    this.ruleNames = CSVParser.ruleNames;
    this.literalNames = CSVParser.literalNames;
    this.symbolicNames = CSVParser.symbolicNames;
  }
  all() {
    let localctx = new AllContext$1(this, this._ctx, this.state);
    this.enterRule(localctx, 0, CSVParser.RULE_all);
    var _la = 0;
    try {
      this.enterOuterAlt(localctx, 1);
      this.state = 8;
      this.headers();
      this.state = 16;
      this._errHandler.sync(this);
      _la = this._input.LA(1);
      while (_la === 1 || _la === 2) {
        this.state = 10;
        this._errHandler.sync(this);
        _la = this._input.LA(1);
        if (_la === 1) {
          this.state = 9;
          this.match(CSVParser.T__0);
        }
        this.state = 12;
        this.match(CSVParser.T__1);
        this.state = 13;
        this.line();
        this.state = 18;
        this._errHandler.sync(this);
        _la = this._input.LA(1);
      }
      this.state = 19;
      this.match(CSVParser.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;
  }
  headers() {
    let localctx = new HeadersContext(this, this._ctx, this.state);
    this.enterRule(localctx, 2, CSVParser.RULE_headers);
    try {
      this.enterOuterAlt(localctx, 1);
      this.state = 21;
      this.line();
    } 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$1(this, this._ctx, this.state);
    this.enterRule(localctx, 4, CSVParser.RULE_line);
    var _la = 0;
    try {
      this.enterOuterAlt(localctx, 1);
      this.state = 23;
      this.column();
      this.state = 28;
      this._errHandler.sync(this);
      _la = this._input.LA(1);
      while (_la === 5) {
        this.state = 24;
        this.match(CSVParser.DELIMITER);
        this.state = 25;
        this.column();
        this.state = 30;
        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;
  }
  column() {
    let localctx = new ColumnContext(this, this._ctx, this.state);
    this.enterRule(localctx, 6, CSVParser.RULE_column);
    try {
      this.state = 34;
      this._errHandler.sync(this);
      switch (this._input.LA(1)) {
        case 3:
          this.enterOuterAlt(localctx, 1);
          this.state = 31;
          this.match(CSVParser.UNQUOTED);
          break;
        case 4:
          this.enterOuterAlt(localctx, 2);
          this.state = 32;
          this.match(CSVParser.QUOTED);
          break;
        case -1:
        case 1:
        case 2:
        case 5:
          this.enterOuterAlt(localctx, 3);
          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;
  }
}
CSVParser.EOF = antlr4.Token.EOF;
CSVParser.T__0 = 1;
CSVParser.T__1 = 2;
CSVParser.UNQUOTED = 3;
CSVParser.QUOTED = 4;
CSVParser.DELIMITER = 5;
CSVParser.RULE_all = 0;
CSVParser.RULE_headers = 1;
CSVParser.RULE_line = 2;
CSVParser.RULE_column = 3;
let AllContext$1 = class AllContext extends antlr4.ParserRuleContext {
  constructor(parser, parent, invokingState) {
    if (parent === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || invokingState === null) {
      invokingState = -1;
    }
    super(parent, invokingState);
    this.parser = parser;
    this.ruleIndex = CSVParser.RULE_all;
  }
  headers() {
    return this.getTypedRuleContext(HeadersContext, 0);
  }
  EOF() {
    return this.getToken(CSVParser.EOF, 0);
  }
  line = function(i) {
    if (i === void 0) {
      i = null;
    }
    if (i === null) {
      return this.getTypedRuleContexts(LineContext$1);
    } else {
      return this.getTypedRuleContext(LineContext$1, i);
    }
  };
  enterRule(listener) {
    if (listener instanceof CSVListener) {
      listener.enterAll(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CSVListener) {
      listener.exitAll(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CSVVisitor) {
      return visitor.visitAll(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
};
class HeadersContext extends antlr4.ParserRuleContext {
  constructor(parser, parent, invokingState) {
    if (parent === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || invokingState === null) {
      invokingState = -1;
    }
    super(parent, invokingState);
    this.parser = parser;
    this.ruleIndex = CSVParser.RULE_headers;
  }
  line() {
    return this.getTypedRuleContext(LineContext$1, 0);
  }
  enterRule(listener) {
    if (listener instanceof CSVListener) {
      listener.enterHeaders(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CSVListener) {
      listener.exitHeaders(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CSVVisitor) {
      return visitor.visitHeaders(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
let LineContext$1 = class LineContext extends antlr4.ParserRuleContext {
  constructor(parser, parent, invokingState) {
    if (parent === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || invokingState === null) {
      invokingState = -1;
    }
    super(parent, invokingState);
    this.parser = parser;
    this.ruleIndex = CSVParser.RULE_line;
  }
  column = function(i) {
    if (i === void 0) {
      i = null;
    }
    if (i === null) {
      return this.getTypedRuleContexts(ColumnContext);
    } else {
      return this.getTypedRuleContext(ColumnContext, i);
    }
  };
  DELIMITER = function(i) {
    if (i === void 0) {
      i = null;
    }
    if (i === null) {
      return this.getTokens(CSVParser.DELIMITER);
    } else {
      return this.getToken(CSVParser.DELIMITER, i);
    }
  };
  enterRule(listener) {
    if (listener instanceof CSVListener) {
      listener.enterLine(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CSVListener) {
      listener.exitLine(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CSVVisitor) {
      return visitor.visitLine(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
};
class ColumnContext extends antlr4.ParserRuleContext {
  constructor(parser, parent, invokingState) {
    if (parent === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || invokingState === null) {
      invokingState = -1;
    }
    super(parent, invokingState);
    this.parser = parser;
    this.ruleIndex = CSVParser.RULE_column;
  }
  UNQUOTED() {
    return this.getToken(CSVParser.UNQUOTED, 0);
  }
  QUOTED() {
    return this.getToken(CSVParser.QUOTED, 0);
  }
  enterRule(listener) {
    if (listener instanceof CSVListener) {
      listener.enterColumn(this);
    }
  }
  exitRule(listener) {
    if (listener instanceof CSVListener) {
      listener.exitColumn(this);
    }
  }
  accept(visitor) {
    if (visitor instanceof CSVVisitor) {
      return visitor.visitColumn(this);
    } else {
      return visitor.visitChildren(this);
    }
  }
}
CSVParser.AllContext = AllContext$1;
CSVParser.HeadersContext = HeadersContext;
CSVParser.LineContext = LineContext$1;
CSVParser.ColumnContext = ColumnContext;

const serializedATN$1 = [
  4,
  0,
  9,
  67,
  6,
  -1,
  2,
  0,
  7,
  0,
  2,
  1,
  7,
  1,
  2,
  2,
  7,
  2,
  2,
  3,
  7,
  3,
  2,
  4,
  7,
  4,
  2,
  5,
  7,
  5,
  2,
  6,
  7,
  6,
  2,
  7,
  7,
  7,
  2,
  8,
  7,
  8,
  1,
  0,
  1,
  0,
  1,
  1,
  1,
  1,
  1,
  2,
  1,
  2,
  1,
  3,
  1,
  3,
  1,
  4,
  1,
  4,
  1,
  5,
  4,
  5,
  31,
  8,
  5,
  11,
  5,
  12,
  5,
  32,
  1,
  6,
  1,
  6,
  1,
  6,
  1,
  6,
  1,
  6,
  1,
  6,
  1,
  6,
  1,
  6,
  1,
  6,
  1,
  6,
  5,
  6,
  45,
  8,
  6,
  10,
  6,
  12,
  6,
  48,
  9,
  6,
  1,
  6,
  1,
  6,
  1,
  7,
  4,
  7,
  53,
  8,
  7,
  11,
  7,
  12,
  7,
  54,
  1,
  7,
  1,
  7,
  1,
  8,
  1,
  8,
  5,
  8,
  61,
  8,
  8,
  10,
  8,
  12,
  8,
  64,
  9,
  8,
  1,
  8,
  1,
  8,
  0,
  0,
  9,
  1,
  1,
  3,
  2,
  5,
  3,
  7,
  4,
  9,
  5,
  11,
  6,
  13,
  7,
  15,
  8,
  17,
  9,
  1,
  0,
  3,
  8,
  0,
  10,
  10,
  13,
  13,
  32,
  32,
  34,
  34,
  44,
  44,
  61,
  61,
  123,
  123,
  125,
  125,
  4,
  0,
  10,
  10,
  13,
  13,
  34,
  34,
  92,
  92,
  2,
  0,
  10,
  10,
  13,
  13,
  74,
  0,
  1,
  1,
  0,
  0,
  0,
  0,
  3,
  1,
  0,
  0,
  0,
  0,
  5,
  1,
  0,
  0,
  0,
  0,
  7,
  1,
  0,
  0,
  0,
  0,
  9,
  1,
  0,
  0,
  0,
  0,
  11,
  1,
  0,
  0,
  0,
  0,
  13,
  1,
  0,
  0,
  0,
  0,
  15,
  1,
  0,
  0,
  0,
  0,
  17,
  1,
  0,
  0,
  0,
  1,
  19,
  1,
  0,
  0,
  0,
  3,
  21,
  1,
  0,
  0,
  0,
  5,
  23,
  1,
  0,
  0,
  0,
  7,
  25,
  1,
  0,
  0,
  0,
  9,
  27,
  1,
  0,
  0,
  0,
  11,
  30,
  1,
  0,
  0,
  0,
  13,
  34,
  1,
  0,
  0,
  0,
  15,
  52,
  1,
  0,
  0,
  0,
  17,
  58,
  1,
  0,
  0,
  0,
  19,
  20,
  5,
  32,
  0,
  0,
  20,
  2,
  1,
  0,
  0,
  0,
  21,
  22,
  5,
  123,
  0,
  0,
  22,
  4,
  1,
  0,
  0,
  0,
  23,
  24,
  5,
  125,
  0,
  0,
  24,
  6,
  1,
  0,
  0,
  0,
  25,
  26,
  5,
  44,
  0,
  0,
  26,
  8,
  1,
  0,
  0,
  0,
  27,
  28,
  5,
  61,
  0,
  0,
  28,
  10,
  1,
  0,
  0,
  0,
  29,
  31,
  8,
  0,
  0,
  0,
  30,
  29,
  1,
  0,
  0,
  0,
  31,
  32,
  1,
  0,
  0,
  0,
  32,
  30,
  1,
  0,
  0,
  0,
  32,
  33,
  1,
  0,
  0,
  0,
  33,
  12,
  1,
  0,
  0,
  0,
  34,
  46,
  5,
  34,
  0,
  0,
  35,
  36,
  5,
  92,
  0,
  0,
  36,
  45,
  5,
  34,
  0,
  0,
  37,
  38,
  5,
  92,
  0,
  0,
  38,
  45,
  5,
  114,
  0,
  0,
  39,
  40,
  5,
  92,
  0,
  0,
  40,
  45,
  5,
  110,
  0,
  0,
  41,
  42,
  5,
  92,
  0,
  0,
  42,
  45,
  5,
  92,
  0,
  0,
  43,
  45,
  8,
  1,
  0,
  0,
  44,
  35,
  1,
  0,
  0,
  0,
  44,
  37,
  1,
  0,
  0,
  0,
  44,
  39,
  1,
  0,
  0,
  0,
  44,
  41,
  1,
  0,
  0,
  0,
  44,
  43,
  1,
  0,
  0,
  0,
  45,
  48,
  1,
  0,
  0,
  0,
  46,
  44,
  1,
  0,
  0,
  0,
  46,
  47,
  1,
  0,
  0,
  0,
  47,
  49,
  1,
  0,
  0,
  0,
  48,
  46,
  1,
  0,
  0,
  0,
  49,
  50,
  5,
  34,
  0,
  0,
  50,
  14,
  1,
  0,
  0,
  0,
  51,
  53,
  7,
  2,
  0,
  0,
  52,
  51,
  1,
  0,
  0,
  0,
  53,
  54,
  1,
  0,
  0,
  0,
  54,
  52,
  1,
  0,
  0,
  0,
  54,
  55,
  1,
  0,
  0,
  0,
  55,
  56,
  1,
  0,
  0,
  0,
  56,
  57,
  6,
  7,
  0,
  0,
  57,
  16,
  1,
  0,
  0,
  0,
  58,
  62,
  5,
  35,
  0,
  0,
  59,
  61,
  8,
  2,
  0,
  0,
  60,
  59,
  1,
  0,
  0,
  0,
  61,
  64,
  1,
  0,
  0,
  0,
  62,
  60,
  1,
  0,
  0,
  0,
  62,
  63,
  1,
  0,
  0,
  0,
  63,
  65,
  1,
  0,
  0,
  0,
  64,
  62,
  1,
  0,
  0,
  0,
  65,
  66,
  6,
  8,
  0,
  0,
  66,
  18,
  1,
  0,
  0,
  0,
  6,
  0,
  32,
  44,
  46,
  54,
  62,
  1,
  6,
  0,
  0
];
const atn$1 = new antlr4.atn.ATNDeserializer().deserialize(serializedATN$1);
const decisionsToDFA$1 = atn$1.decisionToState.map((ds, index) => new antlr4.dfa.DFA(ds, index));
class PrometheusMetricsLexer extends antlr4.Lexer {
  static grammarFileName = "PrometheusMetrics.g4";
  static channelNames = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"];
  static modeNames = ["DEFAULT_MODE"];
  static literalNames = [null, "' '", "'{'", "'}'", "','", "'='"];
  static symbolicNames = [
    null,
    null,
    null,
    null,
    null,
    null,
    "IDENTIFIER",
    "QUOTED_DENTIFIER",
    "NEWLINE",
    "COMMENT"
  ];
  static ruleNames = [
    "T__0",
    "T__1",
    "T__2",
    "T__3",
    "T__4",
    "IDENTIFIER",
    "QUOTED_DENTIFIER",
    "NEWLINE",
    "COMMENT"
  ];
  constructor(input) {
    super(input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn$1, decisionsToDFA$1, new antlr4.atn.PredictionContextCache());
  }
}
PrometheusMetricsLexer.EOF = antlr4.Token.EOF;
PrometheusMetricsLexer.T__0 = 1;
PrometheusMetricsLexer.T__1 = 2;
PrometheusMetricsLexer.T__2 = 3;
PrometheusMetricsLexer.T__3 = 4;
PrometheusMetricsLexer.T__4 = 5;
PrometheusMetricsLexer.IDENTIFIER = 6;
PrometheusMetricsLexer.QUOTED_DENTIFIER = 7;
PrometheusMetricsLexer.NEWLINE = 8;
PrometheusMetricsLexer.COMMENT = 9;

class PrometheusMetricsListener extends antlr4.tree.ParseTreeListener {
  // Enter a parse tree produced by PrometheusMetricsParser#all.
  enterAll(ctx) {
  }
  // Exit a parse tree produced by PrometheusMetricsParser#all.
  exitAll(ctx) {
  }
  // Enter a parse tree produced by PrometheusMetricsParser#line.
  enterLine(ctx) {
  }
  // Exit a parse tree produced by PrometheusMetricsParser#line.
  exitLine(ctx) {
  }
  // Enter a parse tree produced by PrometheusMetricsParser#metric.
  enterMetric(ctx) {
  }
  // Exit a parse tree produced by PrometheusMetricsParser#metric.
  exitMetric(ctx) {
  }
  // Enter a parse tree produced by PrometheusMetricsParser#label.
  enterLabel(ctx) {
  }
  // Exit a parse tree produced by PrometheusMetricsParser#label.
  exitLabel(ctx) {
  }
}

class PrometheusMetricsVisitor extends antlr4.tree.ParseTreeVisitor {
  // Visit a parse tree produced by PrometheusMetricsParser#all.
  visitAll(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by PrometheusMetricsParser#line.
  visitLine(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by PrometheusMetricsParser#metric.
  visitMetric(ctx) {
    return this.visitChildren(ctx);
  }
  // Visit a parse tree produced by PrometheusMetricsParser#label.
  visitLabel(ctx) {
    return this.visitChildren(ctx);
  }
}

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();
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 & ~31) === 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 & ~31) === 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 === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || invokingState === null) {
      invokingState = -1;
    }
    super(parent, invokingState);
    this.parser = parser;
    this.ruleIndex = PrometheusMetricsParser.RULE_all;
  }
  line = function(i) {
    if (i === void 0) {
      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 === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || 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 === void 0) {
      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 === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || 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 === void 0) {
      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 === void 0) {
      parent = null;
    }
    if (invokingState === void 0 || 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 === void 0) {
      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;

class GrammarSyntaxError extends Error {
  constructor(message, line, column) {
    super(`${message} at ${line}:${column}`);
    this.line = line;
    this.column = column;
  }
}

class ThrowingErrorListener extends ErrorListener {
  syntaxError(recognizer, offendingSymbol, line, column, msg, e) {
    throw new GrammarSyntaxError(msg, line, column, e);
  }
}

function parse(input, Lexer, Parser) {
  const parser = new Parser(
    new CommonTokenStream(
      new Lexer(
        new InputStream(input)
      )
    )
  );
  parser.removeErrorListeners();
  parser.addErrorListener(new ThrowingErrorListener());
  return parser.all();
}

function walk(tree, listener) {
  ParseTreeWalker.DEFAULT.walk(listener, tree);
  return listener;
}

function parseCustomMetric$1(input) {
  return parse(input, CustomMetricLexer, CustomMetricParser);
}

class CSVParserVisitor extends CSVVisitor {
  constructor() {
    super();
    this.lines = [];
    this.headers = [];
    this.delimiter = void 0;
  }
  visitAll(ctx) {
    super.visitAll(ctx);
    return {
      lines: this.lines,
      headers: this.headers,
      delimiter: this.delimiter
    };
  }
  visitHeaders(ctx) {
    super.visitHeaders(ctx);
    this.headers = this.lines.shift();
  }
  visitLine(ctx) {
    this.line = [];
    super.visitLine(ctx);
    this.lines.push(this.line);
  }
  visitColumn(ctx) {
    let text = ctx.getText().trim();
    const isQuoted = text.startsWith('"') && text.endsWith('"');
    if (isQuoted) {
      text = text.slice(1, -1).replaceAll('""', '"');
    }
    const index = ctx.parentCtx.children.indexOf(ctx);
    if (index === 0) {
      this.line.push(text);
    } else {
      const delimiter = ctx.parentCtx.children[index - 1].getText();
      if (!this.delimiter) {
        this.delimiter = delimiter;
      }
      if (delimiter !== this.delimiter) {
        this.line[this.line.length - 1] += delimiter + ctx.getText();
      } else {
        this.line.push(text);
      }
    }
  }
}

function parseCustomMetric(input) {
  return parse(input.trim(), CSVLexer, CSVParser).accept(new CSVParserVisitor());
}

class PrometheusMetricsParserVisitor extends PrometheusMetricsVisitor {
  visitLine(ctx) {
    const metric = ctx.metric();
    return new Metric(metric.name, ctx.value, ctx.timestamp, metric.label());
  }
}
class Metric {
  name = "";
  labels = {};
  value = null;
  timestamp = null;
  constructor(name, value, timestamp, labels) {
    this.name = getText(name);
    this.value = parseNumber(getText(value));
    this.timestamp = parseNumber(getText(timestamp));
    this.labels = labels.reduce(toKeyedLabelsReducer, {});
  }
}
function getText(ctx) {
  const text = ctx?.text;
  if (!text) {
    return null;
  }
  if (!text.startsWith('"')) {
    return text;
  }
  return text.slice(1, text.length - 1).replaceAll("\\\\", "\\").replaceAll('\\"', '"').replaceAll("\\r", "\r").replaceAll("\\n", "\n");
}
function parseNumber(text) {
  if (!text) {
    return null;
  }
  switch (text) {
    case "NaN":
      return NaN;
    case "+Inf":
      return Infinity;
    case "-Inf":
      return -Infinity;
    default:
      return parseFloat(text);
  }
}
function toKeyedLabelsReducer(acc, ctx) {
  acc[getText(ctx.name)] = getText(ctx.value);
  return acc;
}

function parsePrometheusMetrics(input) {
  return parse(input.trim(), PrometheusMetricsLexer, PrometheusMetricsParser).accept(new PrometheusMetricsParserVisitor());
}

export { CSVLexer, CSVListener, CSVParser, CSVVisitor, CustomMetricLexer, CustomMetricListener, CustomMetricParser, CustomMetricVisitor, GrammarSyntaxError, PrometheusMetricsLexer, PrometheusMetricsListener, PrometheusMetricsParser, PrometheusMetricsVisitor, parse, parseCustomMetric as parseCSV, parseCustomMetric$1 as parseCustomMetric, parsePrometheusMetrics, walk };