| 3 | |
| 4 | |
| 5 | class js: |
| 6 | def __init__(self, script: str): |
| 7 | self.script = script |
| 8 | self.length = len(self.script) |
| 9 | self.key = 0 |
| 10 | |
| 11 | def parser(self, init=True): |
| 12 | output = js_data() |
| 13 | value = "" |
| 14 | while self.length > self.key: |
| 15 | char = self.script[self.key] |
| 16 | self.key += 1 |
| 17 | if char == "{": |
| 18 | output.children.append(value) |
| 19 | value = "" |
| 20 | output.children.append(self.parser(init=False)) |
| 21 | output.children[-1].parent = output |
| 22 | output.children[-1].before = output.children[-2] |
| 23 | elif char == "}": |
| 24 | if value != "": |
| 25 | output.children.append(value) |
| 26 | if init: |
| 27 | value = "" |
| 28 | else: |
| 29 | return output |
| 30 | else: |
| 31 | value += char |
| 32 | if value != "": |
| 33 | output.children.append(value) |
| 34 | return output |
| 35 | |
| 36 | |
| 37 | class js_data: |