I'm trying to get variable declarations to fold in my syntax file or the
SCL language. Here are some examples of variable declarations:-


    STRING ( 80 )
        PROGRESS                    := ""

    STRING ( 32 )
        CALLING                     := "",
        RETURNING                   := ""

    STRING
        METERS                      := "N",
        DISPLAY                     := "N"

    STRING ( 16 )
        OPTIONS_UON                 := "NR_COMPILE_SCL(OPTONS)"

            SUPERSTRING
                HEADERS

A statement is terminated either by a semi-colon, or by end-of-line,
unless the statement is 'obviously' incomplete. All the lines that
start 'STRING...' are obviously incomplete, because a variabl
declaration needs a variable as well as a type. The commas explicitly
say that there is more to come.

Here's what I put in my syntax file:-

syntax  region  sclDeclaration
\       fold keepend extend
\       contains=sclIdentifier,sclType,sclComment,sclStringConst,sclError
\       containedin=sclBlock,sclThenClause,sclElseClause,sclDoClause
\       start=/\<int\>\_s\+\<\a\k*\>/
\       start=/\<bool\>\_s\+\<\a\k*\>/
\       start=/\<string\>\_s\+\<\a\k*\>/
\       start=/\<string\>\s*(\s*[0-9]\+\s*)\_s\+\<\a\k*\>/
\       start=/\<superstring\>\_s\+\<\a\k*\>/
\       start=/\<superstring\>\s*(\s*[0-9]\+\s*,\s*[0-9]\+\s*)\_s\+\<\a\k*\>/
\       skip=/\(,\|\<is\>\|:=\|+\|+_\|-\|\*\|\/\|\<and\>\|\<or\>\)\_s\+/
\       end=/;/ end=/$/

What I THOUGHT I had was a hard fault, differentiated by whether or not
the type was followed by the advisory length (the numbers in brackets)
In the top part of my sample program file, all types that weren't
followed by advisory lengths folded, and all types that WERE followed by
an advisory length didn't; then I looked down the file a little bit
further and found an example of a string, with an advisory length, that
DID fold. It's the declaration of OPTIONS_UON. This statement folds
wherever I put it in the file.

Looking further there was a declaration WITHOUT an advisory length that
DOESN'T fold, and this one also refuses to fold no matter where it is in
the file; it's the declaration of HEADERS.

Now what I thought I had (at first) was a problem where the parentheses
were messing up the syntax context, and interfering with the detection
of the identifier (which is an integral part of the declaration start
pattern), but the two anomalies have made me even more confused than
before.

I'm using Dr. Chip's highlight trace plugin to look at the actual syntax
stack, and the declaration seems to be playing out correctly, except for
when it isn't (if you see what I mean!) In all cases where the construct
folds correctly, the sclDeclarative context is continuing on the line
following the type; in all ases where it doesn't fold, the context is
terminate early by the end of the line.

Now I've been staring at this for a couple of hours now, and trying
various little hacks (changing the contents of the strings, playing with
the keepend and extend qualifiers, splitting the start pattern into
multiple patterns (as it is now) and putting it into a single pattern
(how it was when I started). Nothing I do makes it any better, only
worse (getting rid of the keepend made the declaration eat all further
content)

Can anyone throw some light on what I've got wrong here? I think I'd
almost welcome back what I thought was the original fault... at least
with a consistent fault you have some hope that you can either fix it or
it can't be fixed, but there's obviously something different about the
lines that fold when their companions don't.

All help appreciated

Regards, Andy
-- 
Andrew Long
andrew dot long at mac dot com






--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to