[prev in list] [next in list] [prev in thread] [next in thread]
List: jedit-cvs
Subject: [ jEdit-commits ] SF.net SVN: jedit: [9027] jEdit/trunk
From: vanza () users ! sourceforge ! net
Date: 2007-02-27 7:44:25
Message-ID: E1HLx0b-0007kV-8P () sc8-pr-svn4 ! sourceforge ! net
[Download RAW message or body]
Revision: 9027
http://svn.sourceforge.net/jedit/?rev=9027&view=rev
Author: vanza
Date: 2007-02-26 23:44:24 -0800 (Mon, 26 Feb 2007)
Log Message:
-----------
Change the way perl "quote operators" are matched. See SF Patch #1659666 for \
discussion, and CHANGES.txt for details.
Modified Paths:
--------------
jEdit/trunk/doc/CHANGES.txt
jEdit/trunk/modes/perl.xml
jEdit/trunk/org/gjt/sp/jedit/TextUtilities.java
jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java
Modified: jEdit/trunk/doc/CHANGES.txt
===================================================================
--- jEdit/trunk/doc/CHANGES.txt 2007-02-27 06:05:53 UTC (rev 9026)
+++ jEdit/trunk/doc/CHANGES.txt 2007-02-27 07:44:24 UTC (rev 9027)
@@ -109,6 +109,16 @@
- Applied SF Patch #1663485: perl.xml patch for variables
- Applied SF patch #1667234: clearer comments in certain parts of perl.xml
+- Change the way perl "quote operators" are matched. See SF Patch #1659666
+ for discussion. The fix is twofold: first, add a new "special" value for the
+ end tag in SPAN_REGEXP, "~[digit]", which tries to find the matching bracket
+ of the matched reference (if can't find the matching bracket, just use the tag
+ body as a literal string). Second, add a new rule that highlights everything
+ as "LITERAL1", used to maintain balanced brackets, and use it to highlight
+ everything inside a "q" operator. This probably needs more tweaking, i.e.,
+ supporting quote operators that allow interpolation, and change the other
+ operators that look like "q" (such as tr). (Marcelo Vanzin)
+
}}}
{{{ API Changes
Modified: jEdit/trunk/modes/perl.xml
===================================================================
--- jEdit/trunk/modes/perl.xml 2007-02-27 06:05:53 UTC (rev 9026)
+++ jEdit/trunk/modes/perl.xml 2007-02-27 07:44:24 UTC (rev 9027)
@@ -197,32 +197,11 @@
<SEQ_REGEXP TYPE="MARKUP" HASH_CHAR="/"
AT_WORD_START="TRUE">/.*?[^\\]/[cgimosx]*(?!\s*[\d\$\@\(\-])</SEQ_REGEXP>
- <!-- q//, qq//, qr//, qx//, tr///, y///, m//, s/// -->
- <SEQ_REGEXP TYPE="MARKUP"
- HASH_CHAR="q"
- AT_WORD_START="TRUE">q(?:|[qx])\{.*\}</SEQ_REGEXP>
- <SEQ_REGEXP TYPE="MARKUP"
- HASH_CHAR="qr"
- AT_WORD_START="TRUE">qr\{.*\}[imosx]*</SEQ_REGEXP>
-
- <!-- For multi-line 'q' statements.
- Do we really need one entry per possible delimiter? {, (, etc... -->
- <SPAN_REGEXP HASH_CHAR="q" TYPE="MARKUP" AT_WORD_START="TRUE" \
NO_LINE_BREAK="FALSE">
- <BEGIN>q(?:|[qrxw])\{</BEGIN>
- <END>}</END>
+ <!-- q//, qq//, qr//, qx// -->
+ <SPAN_REGEXP HASH_CHAR="q" TYPE="MARKUP" DELEGATE="QUOTED" AT_WORD_START="TRUE" \
NO_LINE_BREAK="FALSE"> + <BEGIN>q(?:|[qrxw])([#\[{(/|])</BEGIN>
+ <END>~1</END>
</SPAN_REGEXP>
- <SPAN_REGEXP HASH_CHAR="q" TYPE="MARKUP" AT_WORD_START="TRUE" \
NO_LINE_BREAK="FALSE">
- <BEGIN>q(?:|[qrxw])\(</BEGIN>
- <END>)</END>
- </SPAN_REGEXP>
- <SPAN_REGEXP HASH_CHAR="q" TYPE="MARKUP" AT_WORD_START="TRUE" \
NO_LINE_BREAK="FALSE">
- <BEGIN>q(?:|[qrxw])\/</BEGIN>
- <END>/</END>
- </SPAN_REGEXP>
- <SPAN_REGEXP HASH_CHAR="q" TYPE="MARKUP" AT_WORD_START="TRUE" \
NO_LINE_BREAK="FALSE">
- <BEGIN>q(?:|[qrxw])\|</BEGIN>
- <END>|</END>
- </SPAN_REGEXP>
<!-- tr/// transliteration -->
<SEQ_REGEXP TYPE="MARKUP" HASH_CHAR="tr"
@@ -732,4 +711,12 @@
<SEQ TYPE="LITERAL3">\</SEQ>
</RULES>
+ <!-- Used for quote-like operators; just makes sure the brackets are balanced. -->
+ <RULES SET="QUOTED" DEFAULT="LITERAL1">
+ <SPAN_REGEXP NO_LINE_BREAK="FALSE" TYPE="LITERAL1" DELEGATE="QUOTED" \
HASH_CHARS="|[{(/"> + <BEGIN>([|\[{\(])</BEGIN>
+ <END>~1</END>
+ </SPAN_REGEXP>
+ </RULES>
+
</MODE>
Modified: jEdit/trunk/org/gjt/sp/jedit/TextUtilities.java
===================================================================
--- jEdit/trunk/org/gjt/sp/jedit/TextUtilities.java 2007-02-27 06:05:53 UTC (rev \
9026)
+++ jEdit/trunk/org/gjt/sp/jedit/TextUtilities.java 2007-02-27 07:44:24 UTC (rev \
9027) @@ -85,12 +85,12 @@
{
switch(ch)
{
- case '(': direction[0] = true; return ')';
- case ')': direction[0] = false; return '(';
- case '[': direction[0] = true; return ']';
- case ']': direction[0] = false; return '[';
- case '{': direction[0] = true; return '}';
- case '}': direction[0] = false; return '{';
+ case '(': if (direction != null) direction[0] = true; return ')';
+ case ')': if (direction != null) direction[0] = false; return '(';
+ case '[': if (direction != null) direction[0] = true; return ']';
+ case ']': if (direction != null) direction[0] = false; return '[';
+ case '{': if (direction != null) direction[0] = true; return '}';
+ case '}': if (direction != null) direction[0] = false; return '{';
default: return '\0';
}
} //}}}
@@ -252,14 +252,14 @@
return findWordStart(line, pos, noWordSep, true, false);
} //}}}
-
+
/** Similar to perl's join() method on lists,
* but works with all collections.
- *
+ *
* @param c An iterable collection of Objects
* @param delim a string to put between each object
* @return a joined toString() representation of the collection
- *
+ *
* @since jedit 4.3pre3
*/
public static String join(Collection c, String delim) {
@@ -275,7 +275,7 @@
}
return retval.toString();
}
-
+
//{{{ findWordStart() method
/**
* Locates the start of the word at the specified position.
@@ -793,7 +793,7 @@
lineLength += word.length();
}
} //}}}
-
+
//{{{ indexIgnoringWhitespace() method
public static void indexIgnoringWhitespace(String text, int maxLineLength,
int tabSize, StringBuffer buf)
Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java
===================================================================
--- jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2007-02-27 06:05:53 UTC (rev \
9026)
+++ jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2007-02-27 07:44:24 UTC (rev \
9027) @@ -28,6 +28,7 @@
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.gjt.sp.jedit.TextUtilities;
import org.gjt.sp.util.SegmentCharSequence;
import org.gjt.sp.util.StandardUtilities;
//}}}
@@ -135,17 +136,12 @@
} //}}}
//{{{ check for end of delegate
- if(context.parent != null)
+ if (context.parent != null
+ && context.parent.inRule != null
+ && checkDelegateEnd(context.parent.inRule))
{
- ParserRule rule = context.parent.inRule;
- if(rule != null)
- {
- if(checkDelegateEnd(rule))
- {
- seenWhitespaceEnd = true;
- continue main_loop;
- }
- }
+ seenWhitespaceEnd = true;
+ continue main_loop;
} //}}}
//{{{ check every rule
@@ -166,7 +162,7 @@
{
break escape_checking;
}
- } //}}}
+ }
escaped = !escaped;
pos += escapeSequenceCount - 1;
}
@@ -808,7 +804,7 @@
for(int i = 0; i < end.length; i++)
{
char ch = end[i];
- if(ch == '$')
+ if(ch == '$' || ch == '~')
{
if(i == end.length - 1)
buf.append(ch);
@@ -817,12 +813,26 @@
char digit = end[i + 1];
if(!Character.isDigit(digit))
buf.append(ch);
- else
+ else if (ch == '$')
{
buf.append(match.group(
digit - '0'));
i++;
}
+ else
+ {
+ String s = match.group(digit - '0');
+ if (s.length() == 1)
+ {
+ char b = TextUtilities.getComplementaryBracket(s.charAt(0), null);
+ if (b == '\0')
+ b = s.charAt(0);
+ buf.append(b);
+ }
+ else
+ buf.append(ch);
+ i++;
+ }
}
}
else
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jEdit-CVS mailing list
jEdit-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic