[R-gui] NEdit Highligth patterns for R
(Apologies if anyone sees this twice; my first attempt seemed to disappear.)
On Fri, 11 Oct 2002 10:00:03 +0200, Philippe Grosjean wrote:
2) Of course, one could statically define the dictionnary with, let's say, all functions and arguments in the base and recommended packages. I would prefer a dynamic construction of the dictionnary: when a library is loaded, terms are added, when it is unloaded, they are eliminated. This is only possible with a bidirectionnal communication between the editor and the R calculation kernel. I got this in SciViews but how to do that in Nedit or other separate script editors?
This can be done without bidirectional communication. R already maintains the dictionaries you need, so you could query R to find out how to colour each identifier. Distinguishing between local and global identifiers is hard. To do that the editor needs to parse the code to see if you're in a function, and to see what local identifiers have been defined. But in the editor, functions aren't fully written, so you need a parser that can handle lots of syntax errors and still do useful things, or at least one that can keep building the parse tree until it hits an error and save the partial results at that point. Adding flexibility like this to the parser would have lots of side benefits. It would let you write a debugger that knows the source file line corresponding to each bit of code being executed, editors could jump to syntax errors in the source file, hints about function arguments could be made available in the editor, etc. Duncan Murdoch