Forums

Block or Multiline Comment

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Re: Block or Multiline Comment

Postby hopscc » Sun Jul 20, 2008 5:00 am

Regardless of in-parens-contin theres no ambiguity for either leadin token (##{ or /#) if the
block comment delimiters always suck up the entire line ( as per patch implementation).

(or if the 2 (or 3) char token is always distinguished from the single char ones that are its components)
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Block or Multiline Comment

Postby hopscc » Wed Jul 30, 2008 9:43 pm

New patch on ticket#20 utilising /# and #/ instead of ##{ and ##} as suggested
- full line commenting including lines containing final #/
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Block or Multiline Comment

Postby Charles » Wed Aug 06, 2008 8:17 pm

Your patch is applied. I also added support for nesting the block comments.

I'll eventually add support for inline /# ... #/ comments.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Block or Multiline Comment

Postby nevdelap » Wed Jul 07, 2010 4:12 pm

2 cents - I certainly vote for a multiline comment. In Python it is tiresome to highlight a section and get the editor to comment it rather than just typing something at the beginning and end. I'd also vote for them to be nestable. Unnestable multiline comments are a pain in the butt when commenting out large chunks of code temporarily.

Code: Select all
#/ ... /#

seems as nice and Cobra/Pyhonesque as

Code: Select all
/# ... #/

But doesn't hae to worry about conflicting with divide + single line comment.

If using syntax highlighting it wont be confused with a single line comment because everything after will be coloured as a comment, especially if forgetting to put the /#. I'd be suprised editors can't handle that # and #/ are starting different types of comments, but I defer to others on that one.
call me Nev.
nevdelap
 
Posts: 61
Location: Buenos Aires

Re: Block or Multiline Comment

Postby Charles » Wed Jul 07, 2010 5:40 pm

But Cobra has this already. My last comment was "I'll eventually add support for inline /# ... #/ comments" (note the word "inline") meaning the ability to say:
x = /# -1 #/ * y

And we have that now.

I use block comments all the time. And the fact that they can be nested rocks.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Block or Multiline Comment

Postby nevdelap » Wed Jul 07, 2010 7:30 pm

Ah sweet!!! I searched for multiline comments and didn't find anything later than that post. I shouldn't have assumed when I'm reading couple of year old posts.

Thanks man.

The gedit cobra.lang doesn't handle nested comment syntax highlighting. I'll look into it.
call me Nev.
nevdelap
 
Posts: 61
Location: Buenos Aires

Re: Block or Multiline Comment

Postby Charles » Wed Jul 07, 2010 8:34 pm

Cool. I use gedit from time to time and overall it's syntax highlighting of Cobra is pretty good. Working out the last few wrinkles would be great. Maybe Todd A can chime in as well--he did the current version.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Block or Multiline Comment

Postby nevdelap » Fri Jul 09, 2010 6:16 am

I uploaded a cobra.lang that handles nested block comments. Was just a one line addition.

<context id="multiline-comment" style-ref="comment">
<start>\/#</start>
<end>#\/</end>
<include>
<span style="font-weight: bold"><context ref="multiline-comment"/></span>
<context ref="def:in-comment" />
</include>
</context>


I also sorted the keywords, added par, and fixed where it said dynamiceach. I assumed this is a typo. I made it just each since gedit highlights dynamic like it highlights anything else after an as, rather than as a keyword.

I also added result and value. Please let me know if not having result and value was deliberate.
call me Nev.
nevdelap
 
Posts: 61
Location: Buenos Aires

Re: Block or Multiline Comment

Postby Charles » Fri Jul 09, 2010 1:53 pm

That's great!

"result" and "value" are interesting in that they are semi-keywords. You could actually use them as parameters or local vars in a method. I don't know if GtkSourceView is sophisticated enough to distinguish the cases. "result" would be highlighted only under "ensure" and "value" would be highlighted only under "set".

If it can't be broken down like that then I suppose it's personal preference as to when they are highlighted. I would probably not highlight them differently than other local identifiers, but it's debatable.

Here's a handy link for our readers: wiki/GtkEditors
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Block or Multiline Comment

Postby nevdelap » Fri Jul 09, 2010 2:57 pm

Righto. I'll keep it in mind to investigate how to make it only high light them as keywords in the right places.
call me Nev.
nevdelap
 
Posts: 61
Location: Buenos Aires

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 47 guests