MCPcopy Create free account
hub / github.com/Notgnoshi/generative / main

Function main

tools/parse-production-rules.py:115–135  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

113
114
115def 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
138if __name__ == "__main__":

Callers 1

Calls 5

loopMethod · 0.95
LSystemGrammarClass · 0.90
TokenClass · 0.90
parse_rulesFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected