| 168 | self._syntax = expr[...] + ("\n" | comment)[...] + pp.StringEnd() |
| 169 | |
| 170 | def parse_blueprint(self, s, loc, tok): |
| 171 | blueprint = tok[0] |
| 172 | if isinstance(blueprint, TableBlueprint): |
| 173 | self.tables.append(blueprint) |
| 174 | ref_bps = blueprint.get_reference_blueprints() |
| 175 | col_bps = blueprint.columns or [] |
| 176 | index_bps = blueprint.indexes or [] |
| 177 | for ref_bp in ref_bps: |
| 178 | self.refs.append(ref_bp) |
| 179 | ref_bp.parser = self |
| 180 | for col_bp in col_bps: |
| 181 | col_bp.parser = self |
| 182 | if col_bp.note: |
| 183 | col_bp.note.parser = self |
| 184 | for index_bp in index_bps: |
| 185 | index_bp.parser = self |
| 186 | if index_bp.note: |
| 187 | index_bp.note.parser = self |
| 188 | if blueprint.note: |
| 189 | blueprint.note.parser = self |
| 190 | elif isinstance(blueprint, ReferenceBlueprint): |
| 191 | self.refs.append(blueprint) |
| 192 | elif isinstance(blueprint, EnumBlueprint): |
| 193 | self.enums.append(blueprint) |
| 194 | for enum_item in blueprint.items: |
| 195 | if enum_item.note: |
| 196 | enum_item.note.parser = self |
| 197 | elif isinstance(blueprint, TableGroupBlueprint): |
| 198 | self.table_groups.append(blueprint) |
| 199 | elif isinstance(blueprint, ProjectBlueprint): |
| 200 | self.project = blueprint |
| 201 | if blueprint.note: |
| 202 | blueprint.note.parser = self |
| 203 | elif isinstance(blueprint, StickyNoteBlueprint): |
| 204 | self.sticky_notes.append(blueprint) |
| 205 | else: |
| 206 | raise RuntimeError(f"type unknown: {blueprint}") |
| 207 | blueprint.parser = self |
| 208 | |
| 209 | def locate_table(self, schema: str, name: str) -> "Table": |
| 210 | if not self.database: |