@Override
  public void exitSemantic_range(VersionParser.Semantic_rangeContext ctx) {
    String operator = ctx.getChild(0).getText();
    Object o = stack.pop();
    if (o instanceof SemanticVersion) {
      switch (operator) {
        case "^":
          SemanticVersion sv = (SemanticVersion) o;
          VersionRange from = new VersionRange(">=", sv);
          VersionRange to = new VersionRange("<", sv.getNextCaretVersion());
          range = new AndRange(from, to);
          break;
      }
      stack.push(range);
    }
    else {
      throw new InvalidRangeRuntimeException("Expected a semantic version, got a " + o.getClass().getSimpleName());
    }
  }
@ Override public void exitSemantic_range ( VersionParser . Semantic_rangeContext ctx ) { String operator = ctx . getChild ( 0 ) . getText ( ) ; Object o = stack . pop ( ) ; if ( o instanceof SemanticVersion ) { switch ( operator ) { case "^" : SemanticVersion sv = ( SemanticVersion ) o ; VersionRange from = new VersionRange ( ">=" , sv ) ; VersionRange to = new VersionRange ( "<" , sv . getNextCaretVersion ( ) ) ; range = new AndRange ( from , to ) ; break ; } stack . push ( range ) ; } else { throw new InvalidRangeRuntimeException ( "Expected a semantic version, got a " + o . getClass ( ) . getSimpleName ( ) ) ; } }
Special semantic version type ranges