jEdit Community - Resources for users of the jEdit Text Editor
Highlighting Issue
Submitted by Lance on Friday, 9 March, 2007 - 20:29
I am having trouble getting my syntax highlighting to work with one form of comments. I am making a highlighter for Pick BASIC. Comments can be in the following format:

REM This is a comment
* This is a comment
A = A + 1 ;* Everything after the * is a comment
100 * Everything after the * is a comment. The 100 is a label.
MYLABEL: * Everything after the * is a comment. The MYLABEL: part is a label.

Currently everything is highlighting fine except the last two comment types. It doesn't seem to recognize them as comments. Here's the relevant part of the highlighter xml:

<MODE>
	<PROPS>
<!--		<PROPERTY NAME="lineComment" VALUE="*" /> -->
	</PROPS>

	<RULES IGNORE_CASE="TRUE" HIGHLIGHT_DIGITS="TRUE">
		<SPAN TYPE="LITERAL1" NO_LINE_BREAK="TRUE">
			<BEGIN>"</BEGIN>
			<END>"</END>
		</SPAN>
		<SPAN TYPE="LITERAL2" NO_LINE_BREAK="TRUE">
			<BEGIN>'</BEGIN>
			<END>'</END>
		</SPAN>


		<!-- conditional compilation -->
		<EOL_SPAN_REGEXP TYPE="COMMENT1" AT_LINE_START="TRUE">\d+ \*</EOL_SPAN_REGEXP>
		<EOL_SPAN TYPE="KEYWORD2">#if</EOL_SPAN>
		<EOL_SPAN TYPE="KEYWORD2">#else</EOL_SPAN>
		<EOL_SPAN TYPE="KEYWORD2">#end</EOL_SPAN>

		<EOL_SPAN TYPE="COMMENT1" AT_WHITESPACE_END="TRUE">*</EOL_SPAN>
		<EOL_SPAN TYPE="COMMENT1">;*</EOL_SPAN>
		<EOL_SPAN TYPE="COMMENT1">; *</EOL_SPAN>
		<EOL_SPAN TYPE="COMMENT1">REM</EOL_SPAN>

Functions and operators are listed below here but didn't seem relevant to the problem. Any help on getting this working would be appreciated. Thank you in advance!

Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Any help?
by Lance on Tue, 20/03/2007 - 17:32
No comments?
Oops?
by Lance on Fri, 09/03/2007 - 20:31
I thought I had put this in the Using jEdit section... My apologies for having it appear here... Requesting an admin move this. Thank you!
 
Highlighting Issue
by Axel on Thu, 22/03/2007 - 08:17
Hi Lance,

I just wanted to answer you, but when I paste my lines into the edit field of this forum and press the "Preview Comment"-button, my lines are completely changed... . Didn't find out, how to switch this behaviour off. You could either tell me, how _you_ succeeded in posting _your_ code and have it displayed correct, or you can give me your email address (maybe in some spam save "encryption").

In your span_regexp is missing the HASH_CHAR Attribute.
I tried out a solution on my jEdit4.2, and it worked.
I have almost no knowledge of BASIC, so maybe my solution has to be adjusted slightly.
And, the RegExp-parser of jEdit4.3 is slightly different to jEdit 4.2, so there is a minor risk, that my lines are not working for jEdit4.3.

- Axel
 
HASH_CHAR
by Lance on Thu, 22/03/2007 - 22:16
The problem with HASH_CHAR is that the line could begin with ANY number, or any ALPHANUMERIC followed by a colon. This is why I omitted HASH_CHAR. According to what I've read in the release notes, HASH_CHAR is optional, and if omitted, jEdit will check every line for a potential match as if the hash character had been found.

I was able to get this working by putting in the EOL_SPAN_REGEXP line 9 times, specifying a different numeric (0-9) as HASH_CHAR. I shouldn't have to do that though. Perhaps this is a bug?

Lance...
 
hash_char
by Axel on Fri, 23/03/2007 - 06:36
You are right. I just compared, what help file of jEdit4.2 and 4.3 say:

- For jEdit4.2, hash_char is a must
- For jEdit4.3, hash_char is optional Smiling

My solution was using 9 + 26 different hash_char ... , and I tried it on 4.2.

Does hash_chars (with the trailing "s") work for you?

- Axel

Just curious: How did you get your code into this forum and getting it displayed correct?

.
 
Pasting Code
by Lance on Fri, 23/03/2007 - 21:41
I pasted the code in to the comment box, then I replaced all > and < chars with &gt; and &lt; . I then enclosed the whole thing between <PRE> and </PRE> HTML tags... If you know your html, this will make sense. Let me know if you need more info on how to do this. =)

Lance...
 
Mode File for BASIC
by Axel on Sat, 24/03/2007 - 08:33
Oh, nice, this works! So I show you the code for jEdit4.2. Think, this will work on 4.3, too. But on 4.3, it should be easyer with the hash_char being optional and having the "hash_charS". - Axel
REPLACE your line:

<EOL_SPAN_REGEXP TYPE="COMMENT1" AT_LINE_START="TRUE">\d+ \*</EOL_SPAN_REGEXP>

BY:

<EOL_SPAN_REGEXP HASH_CHAR="1" TYPE="COMMENT1" AT_LINE_START="TRUE">1\d*[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="2" TYPE="COMMENT1" AT_LINE_START="TRUE">2\d*[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="3" TYPE="COMMENT1" AT_LINE_START="TRUE">3\d*[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="4" TYPE="COMMENT1" AT_LINE_START="TRUE">4\d*[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="5" TYPE="COMMENT1" AT_LINE_START="TRUE">5\d*[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="6" TYPE="COMMENT1" AT_LINE_START="TRUE">6\d*[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="7" TYPE="COMMENT1" AT_LINE_START="TRUE">7\d*[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="8" TYPE="COMMENT1" AT_LINE_START="TRUE">8\d*[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="9" TYPE="COMMENT1" AT_LINE_START="TRUE">9\d*[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="0" TYPE="COMMENT1" AT_LINE_START="TRUE">9\d*[\ \t]+\*</EOL_SPAN_REGEXP>

<EOL_SPAN_REGEXP HASH_CHAR="A" TYPE="COMMENT1" AT_LINE_START="TRUE">A.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="B" TYPE="COMMENT1" AT_LINE_START="TRUE">B.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="C" TYPE="COMMENT1" AT_LINE_START="TRUE">C.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="D" TYPE="COMMENT1" AT_LINE_START="TRUE">D.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="E" TYPE="COMMENT1" AT_LINE_START="TRUE">E.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="F" TYPE="COMMENT1" AT_LINE_START="TRUE">F.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="G" TYPE="COMMENT1" AT_LINE_START="TRUE">G.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="H" TYPE="COMMENT1" AT_LINE_START="TRUE">H.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="I" TYPE="COMMENT1" AT_LINE_START="TRUE">I.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="J" TYPE="COMMENT1" AT_LINE_START="TRUE">J.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="K" TYPE="COMMENT1" AT_LINE_START="TRUE">K.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="L" TYPE="COMMENT1" AT_LINE_START="TRUE">L.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="M" TYPE="COMMENT1" AT_LINE_START="TRUE">M.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="N" TYPE="COMMENT1" AT_LINE_START="TRUE">N.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="O" TYPE="COMMENT1" AT_LINE_START="TRUE">O.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="P" TYPE="COMMENT1" AT_LINE_START="TRUE">P.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="Q" TYPE="COMMENT1" AT_LINE_START="TRUE">Q.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="R" TYPE="COMMENT1" AT_LINE_START="TRUE">R.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="S" TYPE="COMMENT1" AT_LINE_START="TRUE">S.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="T" TYPE="COMMENT1" AT_LINE_START="TRUE">T.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="U" TYPE="COMMENT1" AT_LINE_START="TRUE">U.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="V" TYPE="COMMENT1" AT_LINE_START="TRUE">V.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="W" TYPE="COMMENT1" AT_LINE_START="TRUE">W.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="X" TYPE="COMMENT1" AT_LINE_START="TRUE">X.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="Y" TYPE="COMMENT1" AT_LINE_START="TRUE">Y.*:[\ \t]+\*</EOL_SPAN_REGEXP>
<EOL_SPAN_REGEXP HASH_CHAR="Z" TYPE="COMMENT1" AT_LINE_START="TRUE">Z.*:[\ \t]+\*</EOL_SPAN_REGEXP>
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300