code: private void consumeUntilBalanced(IntervalSet follow) {
  
          log.debug("Lexer entered consumeUntilBalanced with {} and follow {}",
                  ls, follow);
  
          int c;
          do {
              c = input.LA(1);
              // change apostrophe state
              if (c == '\'' && ls.quotOpen == false) {
                  ls.aposOpen = !ls.aposOpen;
              }
              // change quot state
              else if (c == '"' && ls.aposOpen == false) {
                  ls.quotOpen = !ls.quotOpen;
              } else if (c == '(') {
                  ls.parenNest++;
              } else if (c == ')' && ls.parenNest > 0) {
                  ls.parenNest--;
              } else if (c == '{') {
                  ls.curlyNest++;
              } else if (c == '}' && ls.curlyNest > 0) {
                  ls.curlyNest--;
              }
              // handle end of line in string
              else if (c == '\n') {
                  if (ls.quotOpen) ls.quotOpen = false;
                  else if (ls.aposOpen) ls.aposOpen = false;
              } else if (c == Token.EOF) {
                  log.info("Unexpected EOF during consumeUntilBalanced, EOF not consumed");
                  return;
              }
  
              input.consume();
              // log result
              if (log.isTraceEnabled())
                  log.trace("Lexer consumes '{}'({}) until balanced ({}).",
                          new Object[]{
                                  Character.toString((char) c),
                                  Integer.toString(c),
                                  ls});
  
          } while (!(ls.isBalanced() && follow.contains(c)));
      }
docs: Eats characters until on from follow is found and Lexer state
  is balanced at the moment