public static boolean isReserved(final String token) {

    final SqlBaseLexer sqlBaseLexer = new SqlBaseLexer(
            new CaseInsensitiveStream(CharStreams.fromString(token)));
    final CommonTokenStream tokenStream = new CommonTokenStream(sqlBaseLexer);
    final SqlBaseParser sqlBaseParser = new SqlBaseParser(tokenStream);

    sqlBaseParser.removeErrorListeners();

    final SqlBaseParser.NonReservedContext nonReservedContext = sqlBaseParser.nonReserved();
    if (nonReservedContext.exception == null) {
      // If we call nonReservedWord, and if it successfully parses,
      // then we just parsed through a nonReserved word as defined in SqlBase.g4
      // and we return false
      return false;
    }

    final Set<String> allVocab = ParserKeywordValidatorUtil.getKsqlReservedWords();

    return allVocab.contains(token.toLowerCase());
  }
@Test
    public void shouldNotBeReserved() {
        // Given:
        final String[] keywords = new String[]{
                "source",      // non-reserved keyword
                "sink",        // non-reserved keyword
                "MAP",         //upper case
                "Array",        //case insensitive
                "ASSERT",
                "foo",
                "bAR"
        };

        // Then:
        for (final String keyword : keywords) {
            assertEquals(false, ParserUtil.isReserved(keyword));
        }
    }