Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@dataclass
class Variable:
name: str
start: int
length: int
@dataclass
class Plus:
first: Variable
second: Variable
class PlusParsers(TextParsers):
variable = positioned(reg('[A-Za-z][A-Za-z0-9_]*') > UnfinishedVariable)
plus = variable & '+' >> variable > splat(Plus)
if __name__ == '__main__':
print(PlusParsers.plus.parse('abc + xyz').or_die())