AST
source: bluebase/core/ast.py
AST stands for Abstract Syntax Tree.
- dataclassclass Ast[source]
Bases:
ABCAn abstract base class for ASTs.
Common Grammar
table: WORD | WORD "AS" WORD tables: table | tables COMMA table attr: WORD | WORD DOT WORD attrs: attr | attrs COMMA attr value: FLOAT | INT | BOOL | STRING values: value | values COMMA value hand: attr | value cond: attr COMP hand conds: cond | conds "AND" cond assign: attr COMP hand assigns: assign | assigns COMMA assign domain: BOOL | INT | FLOAT | STRING LP INT RP define: attr domain defines: define | defines COMMA define where_clause: | "WHERE" conds
Dispatch Grammar
create_statement : "CREATE" "TABLE" create_table_body SC | "CREATE" "INDEX" create_index_body SC drop_statement : "DROP" "TABLE" drop_table_body SC | "DROP" "INDEX" drop_index_body SC
Partial Grammar
create_table_body: table LP defines RP create_index_body: attr "OF" table drop_table_body: table drop_index_body: attr "OF" table
Statement Grammar
select_statement: "SELECT" attrs "FROM" tables where_clause SC insert_statement: "INSERT" "INTO" table "VALUES" LP values RP SC delete_statement: "DELETE" "FROM" table where_clause SC update_statement: "UPDATE" table "SET" assigns where_clause SC show_tables_statement: "SHOW" "TABLES" SC describe_table_statement: "DESCRIBE" "TABLE" table SC dump_table_statement: "DUMP" "TABLE" table SC exit_statement: "EXIT" SC
- dataclassclass AstTable(name: str, alias: str | None)[source]
Bases:
AstAn AST representing a
table.- Variables:
name (str) – the name of the
tablealias (str | None) – the alias of the
tableif"AS"is specified
- dataclassclass AstAttr(ref: str | None, name: str)[source]
Bases:
AstAn AST representing a
attr.- Variables:
ref (str | None) – the reference of the
attrifDOTis presentname (str) – the name of the
attr
- dataclassclass AstCond(left_attr: AstAttr, comp: Comp, right_hand: AstAttr | bool | int | float | str)[source]
Bases:
AstAn AST representing a
cond.
- dataclassclass AstAssign(left_attr: AstAttr, right_hand: AstAttr | bool | int | float | str)[source]
Bases:
AstAn AST representing a
assign.
- dataclassclass AstDefine(attr: AstAttr, domain: Domain)[source]
Bases:
AstAn AST representing a
define.
- dataclassclass AstSelect(attrs: list[AstAttr], tables: list[AstTable], conds: list[AstCond])[source]
Bases:
AstAn AST representing a
select_statement.
- dataclassclass AstInsert(table: AstTable, values: tuple[bool | int | float | str, ...])[source]
Bases:
AstAn AST representing a
insert_statement.- Variables:
table (AstTable) – the
tableof theinsert_statementvalues (tuple[bool | int | float | str, ...]) – the
valuesof theinsert_statement
- dataclassclass AstDelete(table: AstTable, conds: list[AstCond])[source]
Bases:
AstAn AST representing a
delete_statement.
- dataclassclass AstUpdate(table: AstTable, assigns: list[AstAssign], conds: list[AstCond])[source]
Bases:
AstAn AST representing a
update_statement.
- dataclassclass AstCreateTable(table: AstTable, defines: list[AstDefine])[source]
Bases:
AstAn AST representing a
create_table_body.
- dataclassclass AstDropTable(table: AstTable)[source]
Bases:
AstAn AST representing a
drop_table_body.- Variables:
table (AstTable) – the
tableof thedrop_table_body
- dataclassclass AstCreateIndex(table: AstTable, attr: AstAttr)[source]
Bases:
AstAn AST representing a
create_index_body.
- dataclassclass AstDropIndex(table: AstTable, attr: AstAttr)[source]
Bases:
AstAn AST representing a
drop_index_body.
- dataclassclass AstDescribeTable(table: AstTable)[source]
Bases:
AstAn AST representing a
describe_table_statement.- Variables:
table (AstTable) – the
tableof thedescribe_table_statement