Template instantiation syntax
@certik This is what I came up with. It doesn't work yet. When trying to generate asr it says
Token ')' is unexpected here
--> examples/swap_m.f90:27:32
|
27 | instantiate swap_t(real), only: swap => swap_generic
| ^
-
Maybe it's because I used the wrong type for the var types list.
-
In this case I used
decl_star. Maybe that's where I went wrong. Should it just beidand convert it into types in ASR? -
Or should it be
var_type, in which case there is novar_type_staryet, which I think should be used in this case. -
If this is the case should I create a new type
var_type_star?
I would like some help to move forward.
Can you please rebase your work on top of the latest master? (Or just merge master into your PR and resolve all conflicts.)
Yes, you should create var_type_plus, which is one or more var_type, separated by a comma. Good point.
Otherwise I think you got it! Thanks for working on this. After this works, we can meet and work on getting it instantiated in ASR.
I think we can treat the instantiation like a "use" statement. So just add it next to the use statement in the parser. In AST I think it is already defined next to the use statement, so that should work.
I still can't get the Instantiate node to print. Maybe there is something missing in the printing function. Could you please tell me where that file is?
I am not sure, I would have to debug it. I can do that tomorrow.
TODO:
- [ ] implement
visit_Instantiatein the symbol table visitor (just empty function) - [ ] Get
--show-asrworking again, update tests
The ci fails because there is an unused parameter in visit_Instantiate(). But it'll be gone when I actually implement that function.
Merged as part of #90.