syn problem

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
bartab
Posts: 1
Joined: Thu Aug 10, 2006 7:45 am

syn problem

Post by bartab »

I think my problem comes from the fact I have the

Code: Select all

|
symbol being used as a comment AND as an operator, I copy the beginning of my .syn for sake of clarity :

Code: Select all

C=1

[Syntax]
Namespace1=5
IgnoreCase=Yes
KeyWordLength=
BracketChars={[()]}
OperatorChars=-+*<>!~%^&|=
PreprocStart=#
SyntaxStart=
SyntaxEnd=
HexPrefix=
CommentStart=|**
CommentEnd=**|
CommentStartAlt=
CommentEndAlt=
SingleComment=|
this said, a line like
/if (!${Target.ID} || ${Target.Type.NotEqual[NPC]} || ${Target.State.Equal[DEAD]}) { is displayed like this :

/if (!${Target.ID} || ${Target.Type.NotEqual[NPC]} || ${Target.State.Equal[DEAD]}) {

whereas it should be displayed like this :

/if (!${Target.ID} || ${Target.Type.NotEqual[NPC]} || ${Target.State.Equal[DEAD]}) {

can someone help on this please ?
Cringing Dragon
Posts: 7
Joined: Fri May 04, 2007 11:39 pm

Post by Cringing Dragon »

I think it's the "SingleComment = |" that's causing this - everything after the first pipe (|) is treated as a comment. Try leaving the SingleComment blank, and remove | from the operator list. I suspect what you'll get then is that every pair of pipes (||) will be coloured as comments, as will any text between single pipes (eg |hi there|), but text between pairs of pipes, such as in your example, will be treated normally. If it's only an operator when paired (||), then this might be good enough (the || will colour as a comment, not an operator, but will nonetheless be highlighted).

If you also use single pipes as operators, this won't work for you because the first single pipe that's encountered will make everything following it be highlighted as a comment until another pipe is encountered.

Another option is that if the pipe only indicates a comment when it occurs at the beginning of the line, then you could use the combination of "SingleComment = |" and "SingleCommentCol = Leading" to flag the comments, leave the CommentStart and CommentEnd blank, and leave | in the operator list. Then any lines that begin with | will be highlighted as comments and all other pipes will be highlighted as operators.

As an aside, experimentation leads me to believe that the SingleComment has precendence over the operator, which has precedence over the CommentStart and CommentEnd.
Post Reply