I am having trouble writing the syntax file for a language that uses begin/end as the block start/end delimiters, like { and } in C.
I started with this:
<sequence format="keyword" parenthesis="be_block:open" indent="1" fold="1">begin</sequence>
<sequence format="keyword" parenthesis="be_block:close" indent="1" fold="1">end</sequence>
<sequence format="keyword" parenthesis="be_block:open" indent="1" fold="1">begin</sequence>
<sequence format="keyword" parenthesis="be_block:close" indent="1" fold="1">end</sequence>
To copy to clipboard, switch view to plain text mode
And the folding mostly worked well. Unfortunately it spotted the begin in
int beginning;
and marked it as the start of a fold-able block.
So I tried this:
<list id="keywords/blocks" format="keyword">
<word parenthesis="be_block:close" indent="1" fold="1">begin</word>
<word parenthesis="be_block:close" indent="1" fold="1">end</word>
</list>
<list id="keywords/blocks" format="keyword">
<word parenthesis="be_block:close" indent="1" fold="1">begin</word>
<word parenthesis="be_block:close" indent="1" fold="1">end</word>
</list>
To copy to clipboard, switch view to plain text mode
But that doesn't fold at all. Any suggestions on the solution for this?
A couple of related but somewhat pedantic questions. There seem to be some gremlins exposed by having begin and end markers on the same line. Try running the example editor, eg
example/example
And enter this:
if (1) {;} else {
}
if {
}
if (1) {;} else {
}
if {
}
To copy to clipboard, switch view to plain text mode
then collapse the fold starting on the if. For me this produces a corrupt screen showing three if lines. I appreciate that is an ugly example, and I wont be at all surprised if you choose to ignore it.
This one is a more reasonable code style.
if (1) {
} else {
}
if (1) {
} else {
}
To copy to clipboard, switch view to plain text mode
Here if you fold up the if statement it folds the complete program. I am not sure this is correct. I was expecting the else branch to remain expanded.
Bookmarks