AST representation.
(self)
| 192 | return ssf_string + ssfs[-1] |
| 193 | |
| 194 | def ast(self): |
| 195 | """AST representation.""" |
| 196 | # The caller must adjust the context appropriately. |
| 197 | if self.has_subscript(): |
| 198 | return gast.Subscript( |
| 199 | value=self.parent.ast(), |
| 200 | slice=gast.Index(self.qn[-1].ast()), |
| 201 | ctx=CallerMustSetThis) |
| 202 | if self.has_attr(): |
| 203 | return gast.Attribute( |
| 204 | value=self.parent.ast(), attr=self.qn[-1], ctx=CallerMustSetThis) |
| 205 | |
| 206 | base = self.qn[0] |
| 207 | if isinstance(base, str): |
| 208 | return gast.Name( |
| 209 | base, ctx=CallerMustSetThis, annotation=None, type_comment=None) |
| 210 | elif isinstance(base, StringLiteral): |
| 211 | return gast.Constant(base.value, kind=None) |
| 212 | elif isinstance(base, NumberLiteral): |
| 213 | return gast.Constant(base.value, kind=None) |
| 214 | else: |
| 215 | assert False, ('the constructor should prevent types other than ' |
| 216 | 'str, StringLiteral and NumberLiteral') |
| 217 | |
| 218 | |
| 219 | class QnResolver(gast.NodeTransformer): |