Determining DSL location from AST [message #554281] |
Fri, 20 August 2010 21:39 |
eyrieowl Messages: 6 Registered: May 2010 |
Junior Member |
|
|
I was wondering if there is any way to determine where an Abstract Syntax Tree node came from? I know that when it's parsing, Antlr is able to spit out the line number and character offset where an error occurs, but I was wondering if it captured that information when constructing the syntax tree? I've tried inspecting the nodes in the debugger, and I'd imagine that if the information exists, it would probably be somewhere accessible from the methods on MinimalEObjectImpl.Container (that being the base class for the code generated nodes), but...I got to where it was difficult to tell what the information meant (i.e., there's no convenient "lineNumber" field or anything); and I also kept ending up in reference cycles. So...to save my sanity, is there anyone who can tell me if the information exists and what I need to do to get at it? It's great for the parser to tell people where they are lexically wrong, but I'd like to be able to post-process and let them know where errors occur processing their dsl. I.e., if I get a NPE processing a node they described in the DSL (because, say, it's referencing some other system component which throws an error), I'd like to be able to refer them back to where in the DSL that happened, not just where in the processing code I was at. Thanks!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04460 seconds