At 23:49 12/12/2008, Sven Van Echelpoel wrote: >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.
No, I believe you are mistaken there. -> FOO["bar"] -> FOO[$bar] -> FOO[$bar, "baz"] -> FOO[FigureSomethingOut($bar, $baz)] -> FOO All of these are perfectly valid ANTLR syntax, and only the first, third, and last cases are obvious to ANTLR. (The second could possibly be guessed if a label is being referenced, but if it's a parameter then it gets complicated again. The fourth is just impossible.) >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. I haven't actually looked at the templates myself, so I'm just going by what you've posted earlier, but this is how it looks to me: Template "createImaginaryNode": - if two parameters, call createTypeTokenText, passing in a type, a token, and some text. - if one parameter, call createTypeText, passing in a type and some text. - if no parameters, call createTypeText, passing in a type and the stringified type. This template ought to (always!) be called by rewrites of the forms shown above. Template "createRewriteNodeFromElement": - if two parameters, call createTypeTokenText, passing in a type, a token, and some text. - if one parameter, call createTypeToken, passing in a type and a token. - if no parameters, insert it directly. This template ought to be called by rewrites of the following forms: -> FOO -> $b -> $b["foo"] (The first one I'm not entirely sure about; if it can produce this then it'll only be if there was a FOO matched on the left side of the rewrite. If there couldn't be one then it'll definitely have to use the first template instead.) 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 -~----------~----~----~----~------~----~------~--~---
