Damien Cassou wrote:
Any node. The idea is that this gives you the range of your error. So for instance, say you had:On Tue, Jun 9, 2009 at 7:57 PM, Jim Idle<[email protected]> wrote: foo: bar e=_expression_; And _expression_ shoudl be int but returns float instead. So, pass $e.tree to your message handler and cast it to CommonTree. This reference then has access to the documented methods of CommonTree. So: public void logMsg(MessageDescriptor m, CommonTree ct, Object... args) { CommonToken st; CommonToken et; st = (CommonToken)(tokens.get(ct.getTokenStartIndex())); et = (CommonToken)(tokens.get(ct.getTokenStopIndex())); // Call the standard logger, using the information in the tokens // logMsg(m, st.getLine(), st.getStartIndex(), et.getStopIndex(), args); } You can then print out something like: Warning: (6, 33) : _expression_ should result in an integer value but gives a float: bar 84/3 ^^^^ Jim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- |
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
