Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Parser refers to C++ Classes (std::set<std::string>), unable to compile TS #524

Open
bskp opened this issue Mar 4, 2022 · 1 comment

Comments

@bskp
Copy link

bskp commented Mar 4, 2022

I am using antlr4ts 0.5.0-alpha.4 to generate a parser for the SQL dialect ClickHouse with the following Grammar:

While the lexer is fine, to my surprise, the generated ClickHouseParser.ts (link to Gist) contains type references which look like C++-Sets to me (excerp from row 13035):

(...)
export class EngineClauseContext extends ParserRuleContext {
	public clauses: std::set<std::string>;
	public engineExpr(): EngineExprContext {
		return this.getRuleContext(0, EngineExprContext);
	}
	public orderByClause(): OrderByClauseContext[];
	public orderByClause(i: number): OrderByClauseContext;
	public orderByClause(i?: number): OrderByClauseContext | OrderByClauseContext[] {
(...)

This line up with the used methods on clauses,

  • count() and
  • insert()

which are both present in the C++ standard libraries' Set implementation, but not in the JavaScript built-in Set implementation, which uses size/add.

For comparison, I also generated a parser using the "standard" antlr, v. 4.9.3 which was able to produce a functioning Javascript parser. Is this issue linked to a bug in antlr4ts, or a problem with the grammar?
Thank you for any pointers!

@alessiostalla
Copy link

Those types come from the grammar, e.g. https://github.com/ClickHouse/ClickHouse/blob/d4a1b71b184a06f515fb3d8bb23f4c315528d815/utils/antlr/ClickHouseParser.g4#L127
Maybe the JS target works because it omits types altogether?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants