I’d like to create a macro that takes a variable number of lines, each of which consists of a lhs and a varible number of Rhys elements. It’s to specify a BNF grammar and it’s own BNF grammar is approximately
Rules <- (Rule;)+
Rule <- RhsName : (LhsItem LhsType),*
So, for instance:
Express : Binary Expr, Unary Expr, Literal Expr;
Binary : Op1 Expr, Operator Token, Op2 Expr;
... for variable number of rules
So I need a pattern with repetition that has repetition within that repetition. I got a macro working that produces a class for a single rule but I also need to produce a class which references all the LhsName’s so that’s what the outer repetition is all about. I’m sorry I’m not including my code but I don’t have wi-fi in the house at the moment so am writing from my iPad at a coffee shop. If I don’t get an answer but I do get internet on my home machine I will put up my attempted code, etc. and in the meantime apologize for not being able to do so. Hopefully somebody will understand the situation (which really boils down to exactly what the title says) and be able to give a few ideas. Thanks very much. I’ve looked at similar topics on various forums and haven’t been able to form an answer.