Problem with Compound Statements

13 views
Skip to first unread message

Pete H

unread,
Jul 22, 2011, 6:16:18 AM7/22/11
to Colorer
Hi

I'm attempting to put together a hrc based on UniVision Basic (a
variant of Pick Basic), initially based on the vbasic.hrc.

I'm stuggling to get the IF THEN/ELSE END compound statement to match
up for folding purposes, mainly when there are multiple of them within
each other, i.e:

IF this THEN
IF that THEN
IF theOther THEN
GOSUB thisAndThatAndTheOther
END ELSE
GOSUB thisAndThat
END
END ELSE
GOSUB this
END
END ELSE
IF theOther THEN
GOSUB theOther
END ELSE
CRT "Stumped!"
END
END

Perhaps a tad convoluted, but I'm finding that the IF and ENDs are not
matching up correctly, and only the inner IFs can be folded. If I
click on the inner END, the first IF is highlighted, but if I then
click on the inner IF, it correctly highlights the END I previously
click on. The relevant part from my hrc is:

<block start="/\b(IF|OPEN|PROCREAD|REWIND|(MAT)?READ(V|U|VU)?|READ(T|
TX|NEXT|PREVIOUS)|MATWRITE(U)?(IF)?|WRITE(V|VU|U)?(IF)?|DELETEIF|
INPUTIF|COPYLIST|GIVELIST|SAVELIST|KEY|ROOT|LOCATE|SEND(X|BREAK)?|
UCLOSE|UCREATE|UOPEN|UREAD(LINE)?|UUNLINK|UWRITE|WEOF)\b\M (.*\b(THEN|
ELSE|LOCKED)\b\s*($|\;\s*(REM|\!|\*).*$))?=/x"
end="/\M \b(END)\b(\s+(THEN|ELSE)\b)?!/x"
scheme="PairedConstructions"
region00="ubWord" region10="ubWord"
region01="PairStart" region11="PairEnd"/>

It looks more complicated than it is, there's just quite a few
statements in UniVision Basic that can have a THEN/ELSE tagged to
them.

Is this a known problem, or is it down to my RE statements?

Many thanks.

Pete

Igor Russkih

unread,
Jul 29, 2011, 3:50:50 AM7/29/11
to col...@googlegroups.com
Hi.

The reason is in \M operand inside your "end" tag.

It orders not to shift parse position, and as a consequence "higher level" IFs are able to "reuse" the same END to closeup.

Just remove \M - in my case everything became fine after this.

  Igor

Pete H

unread,
Aug 8, 2011, 4:28:49 AM8/8/11
to col...@googlegroups.com
Thanks Igor, I'll give that a go.

Pete H

unread,
Aug 8, 2011, 4:37:39 AM8/8/11
to col...@googlegroups.com
That change now matches the correct IF and ENDs, but it still doesn't allow me to fold the outer IF's, just the innermost one.

Any ideas?

Thanks.

Pete

lillie kittredge

unread,
Mar 20, 2013, 7:35:20 PM3/20/13
to col...@googlegroups.com
Hi Pete, 

I found your post while looking for a syntax highlighting solution for Pick BASIC.  Did you ever get this working and would you be willing to share the results?

Thanks!
Reply all
Reply to author
Forward
0 new messages