org.antlr.v4.runtime.tree.TerminalNode Java Examples

The following examples show how to use org.antlr.v4.runtime.tree.TerminalNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaFilePage.java    From jd-gui with GNU General Public License v3.0 6 votes vote down vote up
public void enterNewExpression(List<TerminalNode> identifiers, JavaParser.ClassCreatorRestContext classCreatorRest) {
    if (identifiers.size() > 0) {
        String name = concatIdentifiers(identifiers);
        String internalTypeName = resolveInternalTypeName(identifiers);
        int position = identifiers.get(0).getSymbol().getStartIndex();

        if (classCreatorRest != null) {
            // Constructor call -> Add a link to the constructor declaration
            JavaParser.ExpressionListContext expressionList = classCreatorRest.arguments().expressionList();
            String descriptor = (expressionList != null) ? getParametersDescriptor(expressionList).append('V').toString() : "()V";

            addHyperlink(new TypePage.HyperlinkReferenceData(position, name.length(), newReferenceData(internalTypeName, "<init>", descriptor, currentInternalTypeName)));
        } else {
            // New type array -> Add a link to the type declaration
            addHyperlink(new TypePage.HyperlinkReferenceData(position, name.length(), newReferenceData(internalTypeName, null, null, currentInternalTypeName)));
        }
    }
}
 
Example #2
Source File: JsonPathCompiler.java    From JsonSurfer with MIT License 6 votes vote down vote up
@Override
public Void visitSlicing(JsonPathParser.SlicingContext ctx) {
    Integer left = null;
    Integer right;
    Integer temp = null;
    for (ParseTree node : ctx.children) {
        if (node instanceof TerminalNode) {
            TerminalNode tNode = (TerminalNode) node;
            if (((TerminalNode) node).getSymbol().getType() == JsonPathParser.COLON) {
                left = temp;
                temp = null;
            } else if (tNode.getSymbol().getType() == JsonPathParser.NUM) {
                temp = Integer.parseInt(tNode.getText());
            }
        }
    }
    right = temp;
    pathBuilder.slicing(left, right);
    return super.visitSlicing(ctx);
}
 
Example #3
Source File: BuildVisitor.java    From Arend with Apache License 2.0 6 votes vote down vote up
private Concrete.Expression visitNew(AppPrefixContext prefixCtx, AppExprContext appCtx, ImplementStatementsContext implCtx) {
  Concrete.Expression expr = visitAppExpr(appCtx);

  if (implCtx != null) {
    expr = Concrete.ClassExtExpression.make(tokenPosition(appCtx.start), expr, visitLocalCoClauses(implCtx.localCoClause()));
  }

  if (prefixCtx != null) {
    TerminalNode peval = prefixCtx.PEVAL();
    if (peval != null) {
      expr = new Concrete.EvalExpression(tokenPosition(peval.getSymbol()), true, expr);
    } else {
      TerminalNode eval = prefixCtx.EVAL();
      if (eval != null) {
        expr = new Concrete.EvalExpression(tokenPosition(eval.getSymbol()), false, expr);
      }
    }

    TerminalNode newNode = prefixCtx.NEW();
    if (newNode != null) {
      expr = new Concrete.NewExpression(tokenPosition(newNode.getSymbol()), expr);
    }
  }

  return expr;
}
 
Example #4
Source File: Trainer.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static int getMatchingSymbolEndsLine(Corpus corpus,
	                                            InputDocument doc,
	                                            TerminalNode node)
	{
		TerminalNode matchingLeftNode = getMatchingLeftSymbol(corpus, doc, node);
		if ( matchingLeftNode != null ) {
			Token matchingLeftToken = matchingLeftNode.getSymbol();
			int i = matchingLeftToken.getTokenIndex();
			Token tokenAfterMatchingToken = doc.tokens.getNextRealToken(i);
//			System.out.printf("doc=%s node=%s, pair=%s, after=%s\n",
//			                  new File(doc.fileName).getName(), node.getSymbol(), matchingLeftToken, tokenAfterMatchingToken);
			if ( tokenAfterMatchingToken!=null ) {
				if ( tokenAfterMatchingToken.getType()==Token.EOF ) {
					return 1;
				}
				return tokenAfterMatchingToken.getLine()>matchingLeftToken.getLine() ? 1 : 0;
			}
		}
		return NOT_PAIR;
	}
 
Example #5
Source File: GDLLoader.java    From gdl with Apache License 2.0 6 votes vote down vote up
/**
 * Processes a conjuctive expression (AND, OR, XOR) and connects the filter with the corresponding operator
 *
 * @param conjunctions list of conjunction operators
 */
private void processConjunctionExpression(List<TerminalNode> conjunctions) {
  Predicate conjunctionReuse;

  for (int i = conjunctions.size() - 1; i >= 0; i--) {
    Predicate rhs = currentPredicates.removeLast();
    Predicate lhs = currentPredicates.removeLast();

    switch (conjunctions.get(i).getText().toLowerCase()) {
      case "and":
        conjunctionReuse = new And(lhs, rhs);
        break;
      case "or":
        conjunctionReuse = new Or(lhs, rhs);
        break;
      default:
        conjunctionReuse = new Xor(lhs, rhs);
        break;
    }
    currentPredicates.add(conjunctionReuse);
  }
}
 
Example #6
Source File: DefaultDataQLVisitor.java    From hasor with Apache License 2.0 6 votes vote down vote up
@Override
public T visitDyadicExpr_A(DyadicExpr_AContext ctx) {
    TerminalNode dyadicOper = null;
    dyadicOper = operSwitch(dyadicOper, ctx.MUL());
    dyadicOper = operSwitch(dyadicOper, ctx.DIV());
    dyadicOper = operSwitch(dyadicOper, ctx.DIV2());
    dyadicOper = operSwitch(dyadicOper, ctx.MOD());
    //
    ctx.expr(0).accept(this);
    ctx.expr(1).accept(this);
    //
    Expression expr2 = (Expression) this.instStack.pop();
    Expression expr1 = (Expression) this.instStack.pop();
    SymbolToken symbolToken = code(new SymbolToken(dyadicOper.getText()), dyadicOper);
    this.instStack.push(code(new DyadicExpression(expr1, symbolToken, expr2), ctx));
    return null;
}
 
Example #7
Source File: DefaultDataQLVisitor.java    From hasor with Apache License 2.0 6 votes vote down vote up
@Override
public T visitLambdaDef(LambdaDefContext ctx) {
    LambdaVariable lambdaVariable = code(new LambdaVariable(), ctx);
    List<TerminalNode> identifierList = ctx.IDENTIFIER();
    if (identifierList != null) {
        for (TerminalNode terminalNode : identifierList) {
            String paramName = fixIdentifier(terminalNode);
            StringToken paramToken = code(new StringToken(paramName), terminalNode);
            lambdaVariable.addParam(paramToken);
        }
    }
    //
    this.instStack.push(lambdaVariable);
    //
    ctx.blockSet().accept(this);
    InstSet instSet = (InstSet) this.instStack.pop();
    ((LambdaVariable) this.instStack.peek()).setMultipleInst(instSet.isMultipleInst());
    ((LambdaVariable) this.instStack.peek()).addInstSet(instSet);
    return null;
}
 
Example #8
Source File: PhysicalParser.java    From Cubert with Apache License 2.0 6 votes vote down vote up
@Override
public void exitCreateDictionary(CreateDictionaryContext ctx)
{
    ObjectNode dict = objMapper.createObjectNode();
    String dictName = ctx.ID().getText();
    for (ColumnDictionaryContext colDict : ctx.columnDictionary())
    {
        String columnName = colDict.ID().getText();
        ArrayNode values = objMapper.createArrayNode();
        for (TerminalNode val : colDict.STRING())
        {
            values.add(CommonUtils.stripQuotes(val.getText()));
        }
        dict.put(columnName, values);
    }
    inlineDictionaries.put(dictName, dict);
}
 
Example #9
Source File: JetTemplateCodeVisitor.java    From jetbrick-template-1x with Apache License 2.0 6 votes vote down vote up
@Override
public Code visitExpr_math_binary_shift(Expr_math_binary_shiftContext ctx) {
    SegmentCode lhs = (SegmentCode) ctx.expression(0).accept(this);
    SegmentCode rhs = (SegmentCode) ctx.expression(1).accept(this);

    // Combined '>' '>' => '>>'
    String op = "";
    for (int i = 1; i < ctx.getChildCount() - 1; i++) {
        ParseTree node = ctx.getChild(i);
        if (node instanceof TerminalNode) {
            op = op + node.getText();
        }
    }

    // 类型检查
    Class<?> resultKlass = PromotionUtils.get_binary_shift(lhs.getKlass(), rhs.getKlass(), op);
    if (resultKlass == null) {
        throw reportError("The BinaryOperator \"" + op + "\" is not applicable for the operands " + lhs.getKlassName() + " and " + rhs.getKlassName(), ctx.getChild(1));
    }

    String source = "(" + lhs.toString() + op + rhs.toString() + ")";
    return new SegmentCode(resultKlass, source, ctx);
}
 
Example #10
Source File: DefaultDataQLVisitor.java    From hasor with Apache License 2.0 6 votes vote down vote up
private SpecialType specialType(TerminalNode rou, SpecialType defaultType) {
    if (rou == null) {
        return defaultType;
    }
    String rouType = rou.getText();
    if ("#".equals(rouType)) {
        return SpecialType.Special_A;
    }
    if ("$".equals(rouType)) {
        return SpecialType.Special_B;
    }
    if ("@".equals(rouType)) {
        return SpecialType.Special_C;
    }
    throw newParseException(rou.getSymbol(), "rouType '" + rouType + "' is not supported");
}
 
Example #11
Source File: JavaFilePage.java    From jd-gui with GNU General Public License v3.0 6 votes vote down vote up
public boolean isAField(JavaParser.ExpressionContext ctx) {
    RuleContext parent = ctx.parent;

    if (parent instanceof JavaParser.ExpressionContext) {
        int size = parent.getChildCount();

        if (parent.getChild(size - 1) != ctx) {
            for (int i=0; i<size; i++) {
                if (parent.getChild(i) == ctx) {
                    ParseTree next = parent.getChild(i+1);

                    if (next instanceof TerminalNode) {
                        switch (((TerminalNode)next).getSymbol().getType()) {
                            case JavaParser.DOT:
                            case JavaParser.LPAREN:
                                return false;
                        }
                    }
                }
            }
        }
    }

    return true;
}
 
Example #12
Source File: EqualityOperatorsEvaluatorTest.java    From metron with Apache License 2.0 5 votes vote down vote up
@Test
public void eqTestForTwoIntegers() {
  Token<Integer> left = mock(Token.class);
  when(left.getValue()).thenReturn(1);

  Token<Integer> right = mock(Token.class);
  when(right.getValue()).thenReturn(1);

  StellarParser.ComparisonOpContext op = mock(StellarParser.ComparisonOpContext.class);
  when(op.EQ()).thenReturn(mock(TerminalNode.class));

  assertTrue(evaluator.evaluate(left, right, op));
}
 
Example #13
Source File: ProgramParser.java    From vespa with Apache License 2.0 5 votes vote down vote up
public static int getParseTreeIndex(ParseTree parseTree) {
    if (parseTree instanceof TerminalNode) {
        return ((TerminalNode)parseTree).getSymbol().getType();
    } else {
        return ((RuleNode)parseTree).getRuleContext().getRuleIndex();
    }
}
 
Example #14
Source File: AntlrUtils.java    From djl with Apache License 2.0 5 votes vote down vote up
private static void getText(StringBuilder sb, ParseTree tree) {
    if (tree instanceof TerminalNode) {
        sb.append("\"v\" : \"").append(tree.getText()).append('"');
        return;
    }
    sb.append('"');
    sb.append(tree.getClass().getSimpleName()).append("\" : {");
    for (int i = 0; i < tree.getChildCount(); i++) {
        getText(sb, tree.getChild(i));
        if (i < tree.getChildCount() - 1) {
            sb.append(',');
        }
    }
    sb.append('}');
}
 
Example #15
Source File: MySQLVisitor.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
private ASTNode createAggregationSegment(final AggregationFunctionContext ctx, final String aggregationType) {
    AggregationType type = AggregationType.valueOf(aggregationType.toUpperCase());
    int innerExpressionStartIndex = ((TerminalNode) ctx.getChild(1)).getSymbol().getStartIndex();
    if (null == ctx.distinct()) {
        return new AggregationProjectionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), type, innerExpressionStartIndex);
    }
    return new AggregationDistinctProjectionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), type, innerExpressionStartIndex, getDistinctExpression(ctx));
}
 
Example #16
Source File: ProgramParser.java    From yql-plus with Apache License 2.0 5 votes vote down vote up
public static int getParseTreeIndex(ParseTree parseTree) {
    if (parseTree instanceof TerminalNode) {
        return ((TerminalNode) parseTree).getSymbol().getType();
    } else {
        return ((RuleNode) parseTree).getRuleContext().getRuleIndex();
    }
}
 
Example #17
Source File: JsonModelResolver.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NonNull
private JsObjectImpl createJSObject(
        @NonNull final TerminalNode literal,
        @NullAllowed final JsonParser.PairContext property) {
    final JsObjectImpl declarationScope = modelBuilder.getCurrentObject();
    final Identifier name = property != null ?
            new Identifier(
                    stringValue(property.key().getText()),
                    createOffsetRange(property.key())) :
            new Identifier(modelBuilder.getUnigueNameForAnonymObject(parserResult), OffsetRange.NONE);
    JsObjectImpl object = new JsObjectImpl(
            declarationScope,
            name,
            property != null ?
                    createOffsetRange(property) :
                    createOffsetRange(literal),
            true,
            declarationScope.getMimeType(),
            declarationScope.getSourceLabel());
    declarationScope.addProperty(object.getName(), object);
    object.addAssignment(
            getLiteralType(literal),
            object.getOffset());
    if (property == null) {
        object.setAnonymous(true);
        object.setJsKind(JsElement.Kind.OBJECT);
    } else {
        object.setJsKind(JsElement.Kind.PROPERTY);
        object.addOccurrence(name.getOffsetRange());
    }
    return object;
}
 
Example #18
Source File: SQLServerVisitor.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
@Override
public final ASTNode visitDataTypeLength(final DataTypeLengthContext ctx) {
    DataTypeLengthSegment dataTypeLengthSegment = new DataTypeLengthSegment();
    dataTypeLengthSegment.setStartIndex(ctx.start.getStartIndex());
    dataTypeLengthSegment.setStopIndex(ctx.stop.getStartIndex());
    List<TerminalNode> numbers = ctx.NUMBER_();
    if (numbers.size() == 1) {
        dataTypeLengthSegment.setPrecision(Integer.parseInt(numbers.get(0).getText()));
    }
    if (numbers.size() == 2) {
        dataTypeLengthSegment.setPrecision(Integer.parseInt(numbers.get(0).getText()));
        dataTypeLengthSegment.setScale(Integer.parseInt(numbers.get(1).getText()));
    }
    return dataTypeLengthSegment;
}
 
Example #19
Source File: DefaultDataQLVisitor.java    From hasor with Apache License 2.0 5 votes vote down vote up
@Override
public T visitParamRoute(ParamRouteContext ctx) {
    // .根
    TerminalNode rouTerm = ctx.ROU();
    SpecialType special = specialType(rouTerm, SpecialType.Special_B);
    TerminalNode identifier = ctx.IDENTIFIER();
    TerminalNode string = ctx.STRING();
    StringToken rouNameToken = null;
    //
    Token enterToken = rouTerm != null ? rouTerm.getSymbol() : ctx.start;
    EnterRouteVariable enter = code(new EnterRouteVariable(RouteType.Params, special), enterToken);
    if (identifier != null) {
        rouNameToken = code(new StringToken(fixIdentifier(identifier)), identifier);
    } else {
        rouNameToken = code(new StringToken(string.getText()), string);
    }
    this.instStack.push(code(new NameRouteVariable(enter, rouNameToken), rouNameToken));
    //
    // .x{} 后面的继续路由
    RouteSubscriptContext routeSubscript = ctx.routeSubscript();
    if (routeSubscript != null) {
        routeSubscript.accept(this);
    }
    RouteNameSetContext routeNameSet = ctx.routeNameSet();
    if (routeNameSet != null) {
        routeNameSet.accept(this);
    }
    return null;
}
 
Example #20
Source File: BuildVisitor.java    From Arend with Apache License 2.0 5 votes vote down vote up
@Override
public Concrete.Expression visitAtomFieldsAcc(AtomFieldsAccContext ctx) {
  Concrete.Expression expression = visitExpr(ctx.atom());
  for (TerminalNode projCtx : ctx.NUMBER()) {
    expression = new Concrete.ProjExpression(tokenPosition(projCtx.getSymbol()), expression, Integer.parseInt(projCtx.getText()) - 1);
  }
  return expression;
}
 
Example #21
Source File: OracleVisitor.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
private ASTNode createAggregationSegment(final AggregationFunctionContext ctx, final String aggregationType) {
    AggregationType type = AggregationType.valueOf(aggregationType.toUpperCase());
    int innerExpressionStartIndex = ((TerminalNode) ctx.getChild(1)).getSymbol().getStartIndex();
    if (null == ctx.distinct()) {
        return new AggregationProjectionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), type, innerExpressionStartIndex);
    }
    return new AggregationDistinctProjectionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), type, innerExpressionStartIndex, getDistinctExpression(ctx));
}
 
Example #22
Source File: CypherCstToAstVisitor.java    From vertexium with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private <T extends ParseTree> CypherBinaryExpression toBinaryExpressions(List<ParseTree> children, Function<T, CypherAstBase> itemTransform) {
    CypherAstBase left = null;
    CypherBinaryExpression.Op op = null;
    for (int i = 0; i < children.size(); i++) {
        ParseTree child = children.get(i);
        if (child instanceof TerminalNode) {
            CypherBinaryExpression.Op newOp = CypherBinaryExpression.Op.parseOrNull(child.getText());
            if (newOp != null) {
                if (op == null) {
                    op = newOp;
                } else {
                    throw new VertexiumException("unexpected op, found too many ops in a row");
                }
            }
        } else {
            CypherAstBase childObj = itemTransform.apply((T) child);
            if (left == null) {
                left = childObj;
            } else {
                if (op == null) {
                    throw new VertexiumException("unexpected binary expression. expected an op between expressions");
                }
                left = new CypherBinaryExpression(left, op, childObj);
            }
            op = null;
        }
    }
    return (CypherBinaryExpression) left;
}
 
Example #23
Source File: DefaultDataQLVisitor.java    From hasor with Apache License 2.0 5 votes vote down vote up
@Override
public T visitBreakInst(BreakInstContext ctx) {
    //
    TerminalNode breakCodeNode = ctx.INTEGER_NUM();
    IntegerToken breakCodeToken = null;
    if (breakCodeNode != null) {
        int breakCode = Integer.parseInt(breakCodeNode.getText());
        breakCodeToken = code(new IntegerToken(breakCode), breakCodeNode);
    } else {
        breakCodeToken = code(new IntegerToken(0), ctx.start);
    }
    //
    AnyObjectContext anyObject = ctx.anyObject();
    anyObject.accept(this);
    Variable variable = (Variable) this.instStack.pop();
    //
    if (ctx.EXIT() != null) {
        ((InstSet) this.instStack.peek()).addInst(code(new ExitInst(breakCodeToken, variable), ctx));
        return null;
    }
    if (ctx.THROW() != null) {
        ((InstSet) this.instStack.peek()).addInst(code(new ThrowInst(breakCodeToken, variable), ctx));
        return null;
    }
    if (ctx.RETURN() != null) {
        ((InstSet) this.instStack.peek()).addInst(code(new ReturnInst(breakCodeToken, variable), ctx));
        return null;
    }
    throw newParseException(ctx.start, "missing exit statement.");
}
 
Example #24
Source File: WildcardPruner.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Override
public void visitTerminal(TerminalNode node) {
  if (_enablePathRecording) {
    String text = node.getText();
    int line = node.getSymbol().getLine();
    if (node.getSymbol().getType() == FlatJuniperLexer.WILDCARD_ARTIFACT) {
      _currentPath.addWildcardNode(text, line);
    } else {
      _currentPath.addNode(text, line);
    }
  }
}
 
Example #25
Source File: JavaFilePage.java    From jd-gui with GNU General Public License v3.0 5 votes vote down vote up
public void enterClassBodyDeclaration(JavaParser.ClassBodyDeclarationContext ctx) {
    if (ctx.getChildCount() == 2) {
        ParseTree first = ctx.getChild(0);

        if (first instanceof TerminalNode) {
            TerminalNode f = (TerminalNode)first;

            if (f.getSymbol().getType() == JavaParser.STATIC) {
                String name = f.getText();
                int position = f.getSymbol().getStartIndex();
                declarations.put(currentInternalTypeName + "-<clinit>-()V", new TypePage.DeclarationData(position, 6, currentInternalTypeName, name, "()V"));
            }
        }
    }
}
 
Example #26
Source File: VisitSiblingLists.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static List<Tree> getSeparators(ParserRuleContext ctx, List<? extends ParserRuleContext> siblings) {
	ParserRuleContext first = siblings.get(0);
	ParserRuleContext last = siblings.get(siblings.size()-1);
	int start = BuffUtils.indexOf(ctx, first);
	int end = BuffUtils.indexOf(ctx, last);
	List<Tree> elements = Trees.getChildren(ctx).subList(start, end+1);
	return BuffUtils.filter(elements, c -> c instanceof TerminalNode);
}
 
Example #27
Source File: DefaultDataQLVisitor.java    From hasor with Apache License 2.0 5 votes vote down vote up
@Override
public T visitDyadicExpr_E(DyadicExpr_EContext ctx) {
    TerminalNode dyadicOper = null;
    dyadicOper = operSwitch(dyadicOper, ctx.SC_OR());
    dyadicOper = operSwitch(dyadicOper, ctx.SC_AND());
    //
    ctx.expr(0).accept(this);
    ctx.expr(1).accept(this);
    //
    Expression expr2 = (Expression) this.instStack.pop();
    Expression expr1 = (Expression) this.instStack.pop();
    SymbolToken symbolToken = code(new SymbolToken(dyadicOper.getText()), dyadicOper);
    this.instStack.push(code(new DyadicExpression(expr1, symbolToken, expr2), ctx));
    return null;
}
 
Example #28
Source File: AstBuilder.java    From macrobase with Apache License 2.0 5 votes vote down vote up
@Override
public Node visitComparison(SqlBaseParser.ComparisonContext context) {
    return new ComparisonExpression(
        getLocation(context.comparisonOperator()),
        getComparisonOperator(
            ((TerminalNode) context.comparisonOperator().getChild(0)).getSymbol()),
        (Expression) visit(context.value),
        (Expression) visit(context.right));
}
 
Example #29
Source File: SQL92Visitor.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
private ASTNode createAggregationSegment(final AggregationFunctionContext ctx, final String aggregationType) {
    AggregationType type = AggregationType.valueOf(aggregationType.toUpperCase());
    int innerExpressionStartIndex = ((TerminalNode) ctx.getChild(1)).getSymbol().getStartIndex();
    if (null == ctx.distinct()) {
        return new AggregationProjectionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), type, innerExpressionStartIndex);
    }
    return new AggregationDistinctProjectionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), type, innerExpressionStartIndex, getDistinctExpression(ctx));
}
 
Example #30
Source File: CComplexObjectParser.java    From archie with Apache License 2.0 5 votes vote down vote up
private MultiplicityInterval parseMultiplicityInterval(C_existenceContext existenceContext) {
    MultiplicityInterval interval = new MultiplicityInterval();
    List<TerminalNode> integers = existenceContext.existence().INTEGER();
    if(integers.size() == 1) {
        interval.setLower(Integer.parseInt(integers.get(0).getText()));
        interval.setUpper(interval.getLower());
    } else if (integers.size() == 2) {
        interval.setLower(Integer.parseInt(integers.get(0).getText()));
        interval.setUpper(Integer.parseInt(integers.get(1).getText()));
    }
    return interval;
}