I meant 'punctuation' instead of 'control word' for ) and NB.  .

Henry Rich

On 12/26/2016 2:25 PM, Henry Rich wrote:
The parenthesis and comment delimiter in J have the part of speech 'control word'.

I didn't mean readable in the usual why-can't-anybody-write-comments-any-more sense, but as a reference to the Qt IDE's habit of treating quoted control words as active, and giving the wrong font to everything that follows. Half a line can get formatted as comments. If you actually DO have lots of comments, this is hard to sort out.

Henry rich

On 12/26/2016 1:42 PM, Raul Miller wrote:
I'm not sure what you mean by "containing control words" but code
readability issues are usually a call for better code.

For this, perhaps (warning: lightly tested code):

firstunmatched=:3 :0
   q=. unquoted=. -.~:/\y=''''
   c=. uncommented=. -. +./\ q * 'NB.' E. y
   n=. parendepth=. +/\q*c*-/'()'=/y
   if. 0 < {: n do.
     (n i. _1) <. 1+1 i:~0 1 E. n
   else.
     n i. _1
   end.
)

In other words: ignoring quoted and commented parenthesis, look for
the first occurrence of either an unbalanced right parenthesis or an
unbalanced left parenthesis.

Let me know, though, if you see any flaws in this implementation.

Thanks,


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to