Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How can I know the exact meaning of a AST node.#2004

Answeredbymanticore-projects
yszc asked this question inQ&A
Discussion options

I'm developing a custom SQL processor using the visitor pattern.
How can I know the exact meaning of a AST class, such asAllColumns,AllTableColumns,AllValue.
What's the origin expression it related in a SQL statement.

You must be logged in to vote

I am sorry to tell you that exactly this kind of documentation is missing, because nobody has the time and resources to write it.
Of course you are most welcome to submit PRs with JavaDoc when you are on this job now.

Btw, IntelliJ has an excellent JavaCC plugin which makes it easy to find the production for each AST class.
Also, you could parse the grammar with javaCC itself to get the BNF of each production and last but not leasthttps://manticore-projects.com/JSQLParser/syntax_snapshot.html will show you the Grammar and has a searchable side bar.

Example forAllTableColumns:https://manticore-projects.com/JSQLParser/syntax_snapshot.html#alltablecolumns

Replies: 2 comments 4 replies

Comment options

Greetings.

I understand what you mean, this kind of documentation is missing:

AllColumns refers to the* inSELECT * FROM ...
AllTableColumns withtablename='t' refers to tot.* inSELECT t.* FROM ...

A strong volunteer would need to write that as Java-Doc into each AST class.
In the meantime, your best bet was to go through those AST classes and study theirtoString() method in order to understand what this class is holding.

You must be logged in to vote
4 replies
@yszc
Comment options

Thanks, but I can't usetoString().

The situation is, I need to process all kinds of nodes extended byASTNodeAccessImpl, so there are some grammer beyond my knowledge, so I need to get SQL snippet directly from the class (have no object).

Now I have a method which is searching for the class name inJSqlParserCC.jjt and analyze the context. Is there any more efficiency method?

@manticore-projects
Comment options

I am sorry to tell you that exactly this kind of documentation is missing, because nobody has the time and resources to write it.
Of course you are most welcome to submit PRs with JavaDoc when you are on this job now.

Btw, IntelliJ has an excellent JavaCC plugin which makes it easy to find the production for each AST class.
Also, you could parse the grammar with javaCC itself to get the BNF of each production and last but not leasthttps://manticore-projects.com/JSQLParser/syntax_snapshot.html will show you the Grammar and has a searchable side bar.

Example forAllTableColumns:https://manticore-projects.com/JSQLParser/syntax_snapshot.html#alltablecolumns

Answer selected byyszc
@yszc
Comment options

Thank you, I wasn't expecting a documentation-based answer. The Syntax Snapshot is very useful. 😀

@manticore-projects
Comment options

You are welcome and I am glad to be of assistance. If anything else comes up, please don't hesitate to ask. Cheers!

Comment options

Additionally you can useJSQLFormatter online

to get this kind of AST illustration:

SQL Text └─Statements: statement.select.PlainSelect    ├─selectItems: statement.select.SelectItem    │  └─expression: statement.select.AllTableColumns    │     └─Table: t    └─Table: dual
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@yszc@manticore-projects

[8]ページ先頭

©2009-2025 Movatter.jp