PreviousNextTracker indexSee it online !

(70/212) 208 - Edit modes: Make SPAN_REGEXP (etc.) more flexible

In SPAN_REGEXP rules,
(a) Optionally start the delegation in the next line instead of immediately after the BEGIN token.
(b) Make it possible to describe the END token as a regexp (with $1 style back references to the BEGIN regexp) that may or may not be anchored to line start and/or end.

This should make it possible to correctly describe the Ruby "heredoc" syntax (among other things). Note that Ruby allows several heredocs to be declared in the same line. In that case, the contents of the second one starts in the line after the end token of the first one, etc.

For Ruby, BEGIN would have to match something like /<<-?(\['"\]?)(\w+)\1/ somewhere in the line (wherever a string literal is allowed), and END would match /^$2$/, i.e., the Word from the BEGIN token in a line all of its own.

Another example that is similar, but not identical to the ruby syntax, and that I would like to be able to describe in a mode file:

- BEGIN token: /<<\s\*(\w\*)/ ("<<" somewhere in the line, followed by optional whitespace and a possibly empty Word)

- "DELEGATEd" text should start _after_ the line with the BEGIN token (or after any delegations initiated earlier in that line).

- END token: /^>>\s\*$1/ (">>" at beginning of line, followed by optional whitespace and the (mandatory) Word from the BEGIN token; normal parsing resumes immediately after the Word in the same line, allowing for comments etc.)

Submitted itowi - 2008-03-14 11:00:08 Assigned
Priority 5 Labels core
Status open Group None
Resolution None

Comments

2009-02-02 21:36:46
blitzcoder

There is currently a discussion about adding this feature and the reasons for forbidding regex on the mailing list jedit-devel.

Here are some useful links:

\*\* A comment in TokenMarker.java \*\*
http://jedit.svn.sourceforge.net/viewvc/jedit/jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java?revision=14027&view=markup#l_390
\*\* First revision with this comment (development of SPAN_REGEXP) \*\*
http://jedit.svn.sourceforge.net/viewvc/jedit/jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java?revision=4314&view=markup
\*\* 4.1pre3 changelog (Search for "the end cannot be")\*\*
http://marc.info/?l=jedit-announce&m=102995676808759&w=2

If somebody knows more about that or think he can help implement this feature, please write a message to the mailing list.