Base class for AST nodes
| 15 | |
| 16 | /// Base class for AST nodes |
| 17 | struct prod { |
| 18 | /// Parent production that instanciated this one. May be NULL for |
| 19 | /// top-level productions. |
| 20 | struct prod *pprod; |
| 21 | /// Scope object to model column/table reference visibility. |
| 22 | struct scope *scope; |
| 23 | /// Level of this production in the AST. 0 for root node. |
| 24 | int level; |
| 25 | /// Number of retries in this production. Child productions are |
| 26 | /// generated speculatively and may fail. |
| 27 | long retries = 0; |
| 28 | /// Maximum number of retries allowed before reporting a failure to |
| 29 | /// the Parent prod. |
| 30 | long retry_limit = 100; |
| 31 | prod(prod *parent); |
| 32 | /// Newline and indent according to tree level. |
| 33 | virtual void indent(std::ostream &out); |
| 34 | /// Emit SQL for this production. |
| 35 | virtual void out(std::ostream &out) = 0; |
| 36 | /// Check with the impedance matching code whether this production |
| 37 | /// has been blacklisted and throw an exception. |
| 38 | virtual void match(); |
| 39 | /// Visitor pattern for walking the AST. Make sure you visit all |
| 40 | /// child production when deriving classes. |
| 41 | virtual void accept(prod_visitor *v) { v->visit(this); } |
| 42 | /// Report a "failed to generate" error. |
| 43 | virtual void fail(const char *reason); |
| 44 | /// Increase the retry count and throw an exception when retry_limit |
| 45 | /// is exceeded. |
| 46 | void retry(); |
| 47 | }; |
| 48 | |
| 49 | inline std::ostream& operator<<(std::ostream& s, prod& p) |
| 50 | { |
nothing calls this directly
no outgoing calls
no test coverage detected