(args)
| 113 | |
| 114 | |
| 115 | def main(args): |
| 116 | rules, ignore = parse_rules(args.rule, args.long_tokens) |
| 117 | logger.debug(f"Parsed rules: {rules}") |
| 118 | grammar = LSystemGrammar(rules, ignore, args.seed) |
| 119 | |
| 120 | n = args.iterations or 4 |
| 121 | if args.long_tokens: |
| 122 | axiom = args.axiom.replace(",", " ") |
| 123 | axiom = axiom.split() |
| 124 | axiom = [Token(t) for t in axiom] |
| 125 | else: |
| 126 | axiom = args.axiom.replace(",", " ") |
| 127 | axiom = "".join(axiom.split()) |
| 128 | axiom = [Token(c) for c in axiom] |
| 129 | |
| 130 | result = grammar.loop(axiom, n) |
| 131 | |
| 132 | for token in result: |
| 133 | # TODO: Build an internal buffer and write the output in chunks |
| 134 | args.output.write(token.name + " " * args.long_tokens) |
| 135 | args.output.write("\n") |
| 136 | |
| 137 | |
| 138 | if __name__ == "__main__": |
no test coverage detected