Twistpad Carthago Software forums / Twistpad /  

 Syntax Highlighting is somewhat broken (Example provided)

 
Dirhael
Member
#1 | Posted: 19 Apr 2007 11:03 
Yes, it's me again...with a new problem :)

This time, it has to do with the syntax highlighting. In my example I will be using CSS, but I suppose you could encounter similar problems in other languages. I wrote a example .css with comments on what is broken and how to reproduce, so I will keep this post short.

Just open this stylesheet in Twistpad and read the comments. You should notice the problems right away...

---

Now I have tried for a couple of days now to solve it, but there aren't really any good solutions seeing as you can't add several alternatives to the "First= & Last=" parameters in the syntax definition files or better yet, regular expressions.

I have managed to get it working better (less broken syntax highlighting and crashes), but there are some drawbacks doing it the way I have done in the syntax def file below:
- It doesn't really separate keywords from values, though it may appear to.
- Doesn't really inform you where you've missed a delimiter.

Other than that, at least it doesn't break as badly as the default one...

Here's my custom file (please note that this isn't a solution, just a partially working workaround)


***

Now to my question, is there any hope of this being fixed in the next release? The only really good solution to this as far as I can see is to allow regular expressions in the "First=" and "Last=" parts of syntax files, but I'm sure there could be other ways around this as well. If you need more details, my e-mail can be found at the top of the .css file.

Andre Santos
Carthago
Moderator
#2 | Posted: 23 Apr 2007 04:20 
Hi Dirhael,

Sorry for the late reply.

You are right about that syntax issue. It was changed recently as I was convinced that an ; was always there after the values, and it's not.

There are certain limitations in some languages for syntax. It works quite ok for most languages, but on others there may be an issue and some "gymnastic" must have to be done.

I noticed some editors have "behind the scenes" helping stuff for syntax, I mean, additional hard coded code for some languages. Twistpad only uses the SDF files to make the syntax, and while i feel that way is more honest and easier to add new syntax's, on the other hand on some occasions it can be limited for more complex languages.

I could easily do a hard coded syntax highlighter for CSS which would work without any problem, but since Twistpad is not an CSS editor, and it's not a path I'd like to take, since Twistpad could end up with all syntax's hard coded and that is not at all what I had in mind. Some compromise has to be made although improvements to the syntax engine could and will be made.

Regular expressions are a possibility in the future, a version was implemented with regular expressions, but performance was a big issue, and that version was canceled, I have several other tests in standby for a syntax's to work with RE.

Anyway, back in this particular case what would you use if you could use an RE expression ? Without going deep into it i can just think of "}|;" which would not work anyway because the section would be stopped in the first ; it finds, and not on the one we want (the last one)

Your syntax seems to work properly, the only thing I would do , would be omitting the values section, you don't really need them, that was how the CSS syntax was some time ago.

I will update the CSS syntax for the next release to avoid this issue you mentioned. I will try to came with a solution on this particular problem.

Thanks,

André Santos
Carthago Software Support
http://www.carthagosoft.net

Twistpad Carthago Software forums / Twistpad /
 Syntax Highlighting is somewhat broken (Example provided)

Your Reply Click this icon to move up to the quoted message


 
Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.

 

  Powered By minibb