Closed zhangysh1995 closed 3 years ago
Yushan ZHANG writes:
Hi, I read the talk slides and want to see the implementation of AST mutation. Could you give me any hints to start with?
The AST is never changed in way after construction. Maybe I'm misunderstanding what you mean by mutation? Nevertheless some pointers: Construction of the AST happens top-down, the root node being created by
shared_ptr<prod> statement_factory(struct scope *s);
The generation of SQL is done by calling the root node's
void out(std::ostream &out);
Walking of the AST (without modifying it) is done via
virtual void accept(prod_visitor *v);
This is done for the impedance matching module to collect statistics on consistently failing grammar rules after the test result is known. But there are also some productions that walk parts of the AST to figure out whether they are legal in the current ast (e.g., window function are mostly expressions, but not leagal in all expression contexts).
regards, Andreas
I want to ask where to find the implementation of generating new SQL query
. Sorry for the ambiguous question.
statement_factory()
is in grammar.cc.
Hi, I read the talk slides and want to see the implementation of AST mutation. Could you give me any hints to start with?