Re: [Lazarus] Regex and Syntax Highlighting

2010-05-28 Thread Juha Manninen
Graeme Geldenhuys wrote: I installed jEdit yesterday. It supports a mammoth 177 different syntax highlighter styles for all types of source code, text files like xml/html/css, config files etc. They also use a combination of regex and various code rules. Hi, as noted, regex can't parse any

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-27 Thread Graeme Geldenhuys
On 27 May 2010 02:33, Hans-Peter Diettrich wrote: Multi-line comments, or even worse: nested comments, require to pre-scan an file, before the highlighter can be used. I don't think this is true. I briefly looked at the jEdit code that manages the syntax highlighting, and it doesn't do

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-27 Thread Marco van de Voort
On Wed, May 26, 2010 at 03:47:02PM +0200, Graeme Geldenhuys wrote: BTW: I tried all the examples listed on this page (which FPC doesn't support in most cases), and jEdit formatted then without problems - perfectly, just like the website shows. Yes, nested types, nested classes etc.. Lazarus

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-27 Thread Hans-Peter Diettrich
Graeme Geldenhuys schrieb: Multi-line comments, or even worse: nested comments, require to pre-scan an file, before the highlighter can be used. I don't think this is true. I briefly looked at the jEdit code that manages the syntax highlighting, and it doesn't do multiple passes over the

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-27 Thread Graeme Geldenhuys
On 27 May 2010 11:42, Hans-Peter Diettrich wrote: Multi-line comments, or even worse: nested comments, require to pre-scan an file, before the highlighter can be used. I don't think this is true. I briefly looked at the jEdit code that manages the syntax highlighting, and it doesn't do

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Graeme Geldenhuys
On 25 May 2010 20:23, Marco van de Voort wrote: Standard regex can't deal with nested structures like nesting of comments. OK. Do you know of some complex code maybe included in Lazarus or FPC that I could use as sample code to test? Since you already identified several editors with support

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Graeme Geldenhuys
On 25 May 2010 20:01, Marcos Douglas wrote: Do you know TextAdept? No I don't, but thanks for the link. I'll take a look. -- Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ --

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Graeme Geldenhuys
2010/5/25 Zaher Dirkey : I beleave regex is not a good choice. If you compare the speed you will find SynEdit is more faster. Again, I think this is more related to implementation details. Some editors do it great, some others don't. Some of the editors I looked at that uses regular expressions

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Marco van de Voort
In our previous episode, Graeme Geldenhuys said: [ Charset UTF-8 unsupported, converting... ] On 25 May 2010 20:23, Marco van de Voort wrote: Standard regex can't deal with nested structures like nesting of comments. OK. Do you know of some complex code maybe included in Lazarus or FPC

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Florian Klaempfl
But are they complete/correct ? :-) I know that many editors aren't. They support a basic easy subset and that is it. Stuff like using directive names as variables where allowed, support for to escape keywords etc. A nice test is also const eof = ^Z; --

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Florian Klaempfl
Florian Klaempfl schrieb: But are they complete/correct ? :-) I know that many editors aren't. They support a basic easy subset and that is it. Stuff like using directive names as variables where allowed, support for to escape keywords etc. A nice test is also const eof = ^Z; .. which

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Florian Klaempfl
Florian Klaempfl schrieb: Florian Klaempfl schrieb: But are they complete/correct ? :-) I know that many editors aren't. They support a basic easy subset and that is it. Stuff like using directive names as variables where allowed, support for to escape keywords etc. A nice test is also

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Zaher Dirkey
On Wed, May 26, 2010 at 11:43 AM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: 2010/5/25 Zaher Dirkey : I beleave regex is not a good choice. If you compare the speed you will find SynEdit is more faster. Again, I think this is more related to implementation details. Some editors do

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Martin
On 26/05/2010 12:06, Graeme Geldenhuys wrote: 2010/5/26 Zaher Dirkey : I meant the mechanism of SynEdit not SynEdit it self, Let us call Line Feeding Highlighting, LFH if you like :P RegEx used on whale file in memory, but that LFH do it line by line, you can generate the colored and syntax

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Martin Schreiber
On Wednesday 26 May 2010 12:59:39 Graeme Geldenhuys wrote: I tested: jEdit, gEdit, MSEide, Lazarus IDE and mcedit. Only Lazarus IDE syntax highlighted the above code as one single block of commented code. MSEide has another definition file (pascal2.sdef) which handles nested comments. The

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Mattias Gärtner
Zitat von Graeme Geldenhuys graemeg.li...@gmail.com: 2010/5/26 Zaher Dirkey : I meant the mechanism of SynEdit not SynEdit it self, Let us call Line Feeding Highlighting, LFH if you like :P LFH normally comes with a line state (some booleans or counters). Same as synedit. But synedit

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Graeme Geldenhuys
On 26 May 2010 13:19, Martin laza...@mfriebe.de wrote: Thanks for the SynEdit implementation details. try MacOsAll.pp (30 lines) in your egex highlighter You guys don't listen! :-) MacOSAll.pp was split some time ago into multiple include files. No problems, I checked out an older

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Mattias Gärtner
Zitat von Martin Schreiber fp...@bluewin.ch: On Wednesday 26 May 2010 12:59:39 Graeme Geldenhuys wrote: I tested: jEdit, gEdit, MSEide, Lazarus IDE and mcedit. Only Lazarus IDE syntax highlighted the above code as one single block of commented code. MSEide has another definition file

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Martin Schreiber
On Wednesday 26 May 2010 14:27:13 Mattias Gärtner wrote: MSEide has another definition file (pascal2.sdef) which handles nested comments. The default is pascal.sdef for Delphi compatibility. Why not choose the right highlighter automatically by parsing the mode directive and the compiler

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Martin
On 26/05/2010 13:24, Mattias Gärtner wrote: Zitat von Graeme Geldenhuys graemeg.li...@gmail.com: 2010/5/26 Zaher Dirkey : I meant the mechanism of SynEdit not SynEdit it self, Let us call Line Feeding Highlighting, LFH if you like :P LFH normally comes with a line state (some booleans or

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Graeme Geldenhuys
2010/5/26 Mattias Gärtner : line by line basis, but I doubt that is the best way of doing it, because it will also produce problems with things like comment blocks. AFAIK they do. Because regex can not count nor save states, you need a state machine, which selects which set of regex to use.

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Mattias Gärtner
Zitat von Graeme Geldenhuys graemeg.li...@gmail.com: [...] try MacOsAll.pp (30 lines) in your egex highlighter You guys don't listen! :-) MacOSAll.pp was split some time ago into multiple include files. No problems, I checked out an older version which was 10MB in size (277,380 lines of

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Marco van de Voort
On Wed, May 26, 2010 at 12:59:39PM +0200, Graeme Geldenhuys wrote: and that will produce a nice compiler warning (and for good reason, and why I, and none of my team will ever use that format). It's basic Pascal 101! :-) Not really, since TP didn't even supported it.

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Graeme Geldenhuys
2010/5/26 Mattias Gärtner : This is a fake. But a nice one. See below. I still don't understand why you say it's fake? I see syntax highlighter code, so it works. Indeed. For a regex highlighter jedit is very fast. Just replace all (* and *) with { } in macosall.pp. Then add a (* at the

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Graeme Geldenhuys
On 26 May 2010 15:10, Marco van de Voort wrote: Not really, since TP didn't even supported it. I honestly can't say, except that I know about (* and { style formatting for very long and somewhere in that time I was taught never to nest two of the same comment styles, always alternate then.

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Marco van de Voort
On Wed, May 26, 2010 at 03:47:02PM +0200, Graeme Geldenhuys wrote: where regex will have more problems than other principles, namely nested constructs. Nested if statements, nested procedures, nested comments (the correct style) all work fine with most regex highlighters, so I really don't

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Mattias Gaertner
On Wed, 26 May 2010 15:24:33 +0200 Graeme Geldenhuys graemeg.li...@gmail.com wrote: 2010/5/26 Mattias Gärtner : This is a fake. But a nice one. See below. I still don't understand why you say it's fake? I see syntax highlighter code, so it works. I apologize. Apparently the machine

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Martin
On 26/05/2010 19:54, Mattias Gaertner wrote: Apparently it uses some kind of line state too and only updates till the visible area. Maybe synedit can do the same. At the moment syndit updates everything too often. It's been on my todo for a long time (and some prep work, like moving

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Mattias Gaertner
On Wed, 26 May 2010 20:09:47 +0100 Martin laza...@mfriebe.de wrote: On 26/05/2010 19:54, Mattias Gaertner wrote: Apparently it uses some kind of line state too and only updates till the visible area. Maybe synedit can do the same. At the moment syndit updates everything too often.

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Martin
On 26/05/2010 20:29, Mattias Gaertner wrote: On Wed, 26 May 2010 20:09:47 +0100 Martinlaza...@mfriebe.de wrote: On 26/05/2010 19:54, Mattias Gaertner wrote: Apparently it uses some kind of line state too and only updates till the visible area. Maybe synedit can do the same. At the

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Martin
On 26/05/2010 20:29, Mattias Gaertner wrote: On Wed, 26 May 2010 20:09:47 +0100 Martinlaza...@mfriebe.de wrote: On 26/05/2010 19:54, Mattias Gaertner wrote: Apparently it uses some kind of line state too and only updates till the visible area. Maybe synedit can do the same. At the

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Mattias Gaertner
On Wed, 26 May 2010 20:41:39 +0100 Martin laza...@mfriebe.de wrote: On 26/05/2010 20:29, Mattias Gaertner wrote: On Wed, 26 May 2010 20:09:47 +0100 Martinlaza...@mfriebe.de wrote: On 26/05/2010 19:54, Mattias Gaertner wrote: Apparently it uses some kind of line state too

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-26 Thread Hans-Peter Diettrich
Graeme Geldenhuys schrieb: THE SLOWNESS YOU GUYS ARE MENTIONING IS BASED ON AN CRAP IMPLEMENTATION. Well, the goal has shifted away from only *syntax* highlighting. I don't know what editor you guys used to test syntax highlighting, but clearly it was a crap editor. jEdit being a Java

[Lazarus] Regex and Syntax Highlighting

2010-05-25 Thread Graeme Geldenhuys
Hi, Does anybody know of a website or article I can read about how to integrate regular expressions with an editor to end up with a editor that can handle syntax highlighting. It doesn't need to be specific to Object Pascal (that would be too easy and ideal). ;-) For example, mcedit (from

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-25 Thread Marco van de Voort
On Tue, May 25, 2010 at 02:34:15PM +0200, Graeme Geldenhuys wrote: And yes I was told before that using regex for syntax highlighting is slow, but I think that's a matter of implementation. The editors I have seen and used are more that fast enough even on large files. The huge benefit of

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-25 Thread Graeme Geldenhuys
On 25 May 2010 14:38, Marco van de Voort wrote: But the main problem IMHO is that regex is not suited to highlight many languages that require correct detection of matching tokens, like the Pascal nested comments. mcedit (editor part of Midnight Commander) supports 68 different file formats

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-25 Thread João Marcelo Vaz
Hi Graeme, Have you seen Colorer-take5 on the following URL http://colorer.sourceforge.net/ ? It's cited in the tutorial you pointed at http://www.catch22.net/tuts/neatpad/18 . João Marcelo 2010/5/25 Graeme Geldenhuys graemeg.li...@gmail.com Hi, Does anybody know of a website or article I

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-25 Thread Hans-Peter Diettrich
Graeme Geldenhuys schrieb: Does anybody know of a website or article I can read about how to integrate regular expressions with an editor to end up with a editor that can handle syntax highlighting. It doesn't need to be specific to Object Pascal (that would be too easy and ideal). ;-) I

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-25 Thread Marcos Douglas
On Tue, May 25, 2010 at 9:34 AM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: Hi, Does anybody know of a website or article I can read about how to integrate regular expressions with an editor to end up with a editor that can handle syntax highlighting. It doesn't need to be specific to

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-25 Thread Zaher Dirkey
I beleave regex is not a good choice. If you compare the speed you will find SynEdit is more faster. I import it to make my syntax for my site using PHP i found my Highlighter is more faster (10 time) than the famous one (Geshi) that use the regex.

Re: [Lazarus] Regex and Syntax Highlighting

2010-05-25 Thread Marco van de Voort
On Tue, May 25, 2010 at 03:14:01PM +0200, Graeme Geldenhuys wrote: syntax definition files to get the Object Pascal syntax correct for Free Pascal specific features I use and for my code. So this is clearly not so much of a problem and regex is sufficiently flexible for most (if not all)