SQLsmith  v1.2.1-5-gfacd7a8
A random SQL query generator
prod.hh
Go to the documentation of this file.
1 
4 #include <string>
5 #include <iostream>
6 
7 #ifndef PROD_HH
8 #define PROD_HH
9 
11 struct prod_visitor {
12  virtual void visit(struct prod *p) = 0;
13  virtual ~prod_visitor() { }
14 };
15 
17 struct prod {
20  struct prod *pprod;
22  struct scope *scope;
24  int level;
27  long retries = 0;
30  long retry_limit = 100;
31  prod(prod *parent);
33  virtual void indent(std::ostream &out);
35  virtual void out(std::ostream &out) = 0;
38  virtual void match();
41  virtual void accept(prod_visitor *v) { v->visit(this); }
43  virtual void fail(const char *reason);
46  void retry();
47 };
48 
49 inline std::ostream& operator<<(std::ostream& s, prod& p)
50 {
51  p.out(s); return s;
52 }
53 
54 #endif
Base class for walking the AST.
Definition: prod.hh:11
Base class for AST nodes.
Definition: prod.hh:17
virtual void indent(std::ostream &out)
Newline and indent according to tree level.
Definition: prod.cc:20
void retry()
Increase the retry count and throw an exception when retry_limit is exceeded.
Definition: prod.cc:27
struct scope * scope
Scope object to model column/table reference visibility.
Definition: prod.hh:22
long retry_limit
Maximum number of retries allowed before reporting a failure to the Parent prod.
Definition: prod.hh:30
int level
Level of this production in the AST. 0 for root node.
Definition: prod.hh:24
virtual void out(std::ostream &out)=0
Emit SQL for this production.
struct prod * pprod
Parent production that instanciated this one.
Definition: prod.hh:20
virtual void fail(const char *reason)
Report a "failed to generate" error.
Definition: prod.cc:44
long retries
Number of retries in this production.
Definition: prod.hh:27
virtual void match()
Check with the impedance matching code whether this production has been blacklisted and throw an exce...
Definition: prod.cc:38
virtual void accept(prod_visitor *v)
Visitor pattern for walking the AST.
Definition: prod.hh:41