To support the LModel syntax, we have to match both the axiom and rule statements to how they are written in the model.
Let's get started by creating the lsys macro, as follows:
macro lsys(ex) return MacroTools.postwalk(walk, ex)end
The macro simply uses postwalk to traverse the abstract syntax tree. The resulting expression is returned as is. The main translation logic actually resides in the walk function as follows:
function walk(ex) match_axiom = @capture(ex, axiom : sym_) if match_axiom sym_str = String(sym) return :( model = LModel($sym_str) ) end match_rule = @capture(ex, rule : original_ → replacement_) if match_rule original_str = String(original) replacement_str = String(replacement) return :(