Skip to content

Remove dead legacy JavaCC-generated SQL parser (com.arcadedb.query.sql.parser.SqlParser) #5867

Closed

Description

@lvca

Summary

Found while working #5851's follow-up (PR #5864): the production SQL parser is SQLAntlrParser (ANTLR4-based, com.arcadedb.query.sql.antlr), reached via StatementCache.parse() -> antlrParser.parse(statement). The legacy JavaCC/JJTree-generated parser under com.arcadedb.query.sql.parser - SqlParser.java (~27,200 lines), SqlParserTokenManager.java (~5,740 lines), and JJTSqlParserState.java - is never instantiated or invoked anywhere at runtime. There is no javacc-maven-plugin/jjtree step in engine/pom.xml either, so these aren't even regenerated from a source grammar any more; the original .jjt grammar was already archived as engine/src/main/grammar-archive/SQLGrammar.jjt.old. They're just ~33,000 lines of static, unmaintained, unreachable code sitting in the module.

Confirmed via grep -rl "new SqlParser(" --include="*.java" . across the repo: zero matches.

Not fully dead - two small holder classes have live consumers

SqlParserTreeConstants.java (357 lines) and SqlParserConstants.java (788 lines) are also JavaCC-generated, but they're pure constant tables (node-type IDs, token-type IDs and the tokenImage string array), not parsing logic, and a few files still import from them:

  • SelectStatement.java, MatchStatement.java, SQLQueryEngine.java - import static ...SqlParserTreeConstants.{JJTLIMIT,JJTTIMEOUT} (used as arbitrary-but-stable integer markers, unrelated to actual JavaCC tree-building)
  • engine/src/test/java/.../function/FunctionReferenceGenerator.java - reads SqlParserConstants.tokenImage to enumerate SQL keywords for doc generation

Removal needs to either keep these two small constant-holder files (dropping only the actual parser/lexer: SqlParser.java, SqlParserTokenManager.java, JJTSqlParserState.java, and anything else with zero live references) or extract the handful of constants those four files actually use into a small new home and drop everything.

Suggested approach

  1. Confirm zero references the same way (grep/an IDE "find usages" pass) right before removal, since this codebase has multiple agents landing PRs concurrently.
  2. Remove SqlParser.java, SqlParserTokenManager.java, JJTSqlParserState.java outright.
  3. Either keep SqlParserTreeConstants.java/SqlParserConstants.java as-is (cheapest, still slightly odd to keep "JavaCC-generated" constant files with no generator), or extract just JJTLIMIT/JJTTIMEOUT/tokenImage into a small hand-written replacement and drop those two files too.
  4. engine/src/main/grammar-archive/SQLGrammar.jjt.old can go too once the generated code it produced is gone.
  5. Full mvn -pl engine test pass afterward - the four live-consumer files above are the only ones that need re-verifying.

🤖 Generated with Claude Code

Activity

  1. self-assigned this
    on Aug 7, 2026
  2. added this to the 26.9.1 milestone on Aug 7, 2026
  3. added theissue type on Aug 7, 2026
  4. added 4 commits that reference this issue on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions