|Validating references to variables, etc... [message #648053]
||Tue, 11 January 2011 01:36
| Carl Knight
Registered: December 2010
Having had no replies to my previous post http:// www.eclipse.org/forums/index.php?t=msg&th=202293&sta rt=0&S=5e41a4fe0e65ee76174aba7acb2f0c8f I've soldiered on.|
Given the outline of what I have done (below), my questions are these:
Given the DLTK, is this what I should have done?
Does the DLTK provide something well hidden to do it better? I can't find anything in the examples.
I've created a class called UIncludeStatement. It is created when the ANTLR generated parser finds an include/include_once statement. UIncludeStatement works in conjunction with a MRU cache called UModuleCache. When modules are parsed, the parser passes the result to UModuleCache. Additionally, if the cache is asked for a module and does not have it, it kicks off a parse of the requested module. By extension, when UIncludeStatement is asked for it's associated module, it asks the cache for it. Worst case, this kicks off a JIT parse of the include file.
The vast majority of time, this is plenty quick enough.
In the absence of being able to figure out how any DLTK examples verify variable/method references, etc. between modules, I've done the following:
A class called USymbolSearcher is called when a reference to a variable, type or method is found. It searches the most local scope first, outward to the module, and finally performs a breadth first search of any include/include_once files (obtained from UIncludeStatement nodes in the AST) until the symbol is either found or all available scopes are exhausted. ModuleDeclaration methods to get fields, methods, etc. are used. As are appropriate methods on the MethodDeclaration and FieldDeclaration, etc.
This is all done in the ANTLR generated parser. Errors are reported by RecognitionException.
[Updated on: Tue, 11 January 2011 01:39]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.09311 seconds