From: Nik Trevallyn-J. <ni...@us...> - 2010-08-03 03:05:05
|
Hi Dale, Thanks for your comments. Antlr is a parser-generator. Similar in ways to yacc or bison. There are many grammars already built for Antlr: http://www.antlr.org/grammar/list Although building a generic incremental parser that can use any grammar may not be straight forward - I'll look at it, because if it can be made to work, it is certainly a generic solution. I'll also look at the TokenMarker code again. Thanks for your comments. Cheers! Nik On 08/03/2010 12:13 PM, Dale Anson wrote: > I think you can eliminate #3 as a general solution. PMD is for java and > jsp code. I think #4 and #5 will be difficult to implement in a general > way, but I'm not at all familiar with Antlr, so probably have a better > grasp of what's possible that I do. I would think that a solution based > on the TokenManager somehow would be the best bet for a general > solution, but I have no advice on how to proceed. > > Dale > > > On Mon, Aug 2, 2010 at 7:32 PM, Nik Trevallyn-Jones <ni...@us... > <mailto:ni...@us...>> wrote: > > Hi Folks, > > I've been looking at the jEdit source with a view to implementing syntax > error highlighting. > > (I've seen nothing in the GUI or code that indicates this is already > implemented - correct me if I'm wrong.) > > Dale Anson pointed me to the PMD plugin which I really like, but it is > focused on being a "best-practice" plugin, it is typically triggered on > file save, and any syntax errors it encounters cause long and not very > readable exception messages to be displayed - one at a time, with no > ability to click on the error and go to the broken line. > > Dale also indicated the SideKick plugins will flag errors and will parse > per keystroke, but I don't see that behaviour, nor any option to enable > it (I'm running JaveSidekick 3.0.0). > > So I'm thinking on how best to help the developer with syntax errors. > > My initial idea had been to detect text that the syntax highlighter > didn't understand as a warning/error, but I'm not sure that is actually > viable. > > One thing that is important is incremental parsing: the the ability to > parse only part of a module (eg just a C++ or Java method; a single > line; or even part of a line). > > So, I can see 5 implementation options: > > 1. Implement a set of syntax error rules for TokenMarker that recognise > "error" and "warning" patterns. > Such an option is necessarily incomplete, but it requires zero new code. > Basically, it would recognise various "common" syntax error patterns > rather than validating every piece of code as correct. > > 2. Implement a set of syntax rules for TokenMarker and implement new > code that flags all text that doesn't match these syntax rules as a > warning/error. > > 3. Improve the error handling in PMDPlugin to flag errors in the gutter > as it does with the warnings, and to enable incremental parsing and > parsing on either code-completion, or keystroke. > > 4. Use a full grammar (say in Antlr) and implement the code necessary to > parse the buffer or modified part of the buffer (method, line or > part-line) using this grammar. > This has the potential to be the most efficient and correct, but would > require some extra code or grammar rules to support incremental parsing. > It's been ages since I looked at Antlr parsers, but I suspect that > engineering incremental parsing could involve quite a bit of complex > code. > > 5. Implement a grammar parser based on Java RE that supports incremental > parsing - ie something along the lines of TokenMarker. > This is more code, and would quite probably run slower than an Anltr > parser, but would probably require simpler or even less code to engineer > the incremental parsing support. > > Since I am quite new to the jEdit code base, I may well have missed > important code, so any and all comments are most welcome. > > Cheers! > Nik > > ------------------------------------------------------------------------------ > The Palm PDK Hot Apps Program offers developers who use the > Plug-In Development Kit to bring their C/C++ apps to Palm for a share > of $1 Million in cash or HP Products. Visit us here for more details: > http://p.sf.net/sfu/dev2dev-palm > -- > ----------------------------------------------- > jEdit Developers' List > jEd...@li... > <mailto:jEd...@li...> > https://lists.sourceforge.net/lists/listinfo/jedit-devel > > |