I have a package that implements much of vector autoregression estimation and I would like to develop a macro that would implement domain specific language for imposing linear restriction in multidimensional time-series models. Of course, the user could input the restrictions using some matrices, however I tend to think that they will be much less readable than if I implement this macro and I hope it should not be that bad. Typical example would be:
restr = @restrictions begin 2 beta[1,2,1] - beta[2,1,3] = 10 beta[1,3,1] - beta[1,4,1] = 0 end and the restr would be a tuple with matrix and vector after this. The beta has the following structure beta[from, to, lag]. The macro should take each line and parse it and form proper restriction matrix R that will be made from the signs and indexes at betas and vector r. So I need to parse the signs, constants, and indeces of betas and the thing that is after the equality. Am I right that the right direction is parsing the lines with regular expressions to create the right matrices, or do you have suggestion for better approach? Any further reference for something similar (or useful resource) that has been done before is also very appreciated. Related on that note, is there any function to return all matches from regex? That seems to be the biggest bottleneck so far. Any comments appreciated. Thanks!
