[...] > This is just a guess, but I suspect the reason for this is the > lack of the ability to have overloaded methods in C :) > Yes > In Java, you can have one method that accepts two different types > of parameters, so the template code for the version that passes in > a string and the version that passes in a token can be identical, > leaving it up to the Java compiler to figure out which one you > meant to call. > > In C, however, there's no overloading so this is not > possible. The template will have to generate calls to > differently-named functions depending on whether you are passing > in a string or a token -- and unfortunately, since this is > target-specific code, there's no (reliable) way for ANTLR to > detect the type of a single parameter. So the only option left > open to it is to settle for detecting whether you're passing one > parameter or two.
Indeed it does, but the single argument case can never be a text, it is always a token, at least if I understand this correctly. There are in fact two templates in AST.stg. There is one that does the right thing when a single argument is passed, while the other (which is unfortunately the one that gets invoked in my case) does not. > > (A native C++ target could remove this limitation again, of > course.) > > The workaround would be to change BAR[$b] to BAR[$b, $b.text], I > think. > Or, the one I picked BAR[$b, "" ], as I have no use for the text. Sven List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
