class Hash(ast.Node): _debug = True content = ast.seq(KVP, null=True) @property def _template(self): if len(self.content): return "{\n%(content)s\n}" return "{}"
class Entity(Entry): id = pyast.field(Identifier) index = pyast.seq(Expression, null=True) value = pyast.field(Value, null=True) attrs = pyast.dict(Attribute, null=True) local = pyast.field(bool, default=False) def _template(self): return "<%(id)s %(value)s>"
class LOL(Node): body = pyast.seq(Entry, null=True) _template = '%(body)s' def _template_body(self): return [''] + ['\n'] * (len(self.body) - 1) _template_body_fillvalue = "\n"
class ComplexString(String): content = pyast.seq((str, Expression)) def _template_content(self): ws = [] for n, elem in enumerate(self.content): if isinstance(self.content[n], String): self.content[n]._template = "%(content)s" if not isinstance(self.content[n], String): ws.append("{{") elif not isinstance(self.content[n - 1], String): ws.append("}}") else: ws.append("") return ws
class Example(pyast.Node): seq = pyast.seq(pyast.re("[a-z]{2}"))
class Macro(Entry): id = pyast.field(Identifier) args = pyast.seq(VariableExpression) expression = pyast.field(Expression) attrs = pyast.seq(Attribute, null=True)
class CallExpression(MemberExpression): callee = pyast.field(Expression) arguments = pyast.seq(Expression, null=True)
class Hash(Value): content = pyast.seq(HashItem, null=True)
class Array(Value): content = pyast.seq(Value, null=True)
class Example(ast.Node): _debug = True field = ast.field(str, null=True) seq = ast.seq((str, int), null=True)
class Example(ast.Node): _debug = True key = ast.field(Literal, null=True) value = ast.seq(Literal, null=True)
class Example(ast.Node): _debug = True seq = ast.seq((ast.re("[a-z]{2}"), ast.re("[1-9]{1}")))
class Example(ast.Node): _debug = True seq = ast.seq(ast.re("[a-z]{2}"))
class Example(ast.Node): seq = ast.seq(str, null=False)
class Example(ast.Node): _debug = True seq = ast.seq(str, null=True)