Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error in VIM's AWK syntax file!

80 views
Skip to first unread message

Kenny McCormack

unread,
Dec 19, 2014, 7:47:06 AM12/19/14
to
I am using VIM 7.3 and my awk.vim file starts with:

" Vim syntax file
" Language: awk, nawk, gawk, mawk
" Maintainer: Antonio Colombo <azc...@gmail.com>
" Last Change: 2012 May 18

The following program:

#!/bin/gawk -f
function Days(x) {
return 28 + (x + int(x/8)) % 2 + 2 % x + 2 * int(1/x)
}
# Rest of program here

when viewed in VIM, shows an error (i.e., it highlights in red) on the
closing brace shown above and on the rest of the closing braces in the
file. I know this is the offending function because if I remove this
function, then the syntax highlighting cleans up and behaves normally.

The above is syntactically correct and works fine when the program is run.

So, it boils down to:

1) Is there a kludge/workaround to make the syntax highlighting work?

2) Is there a way to get the awk.vim file fixed?

--
BigBusiness types (aka,
Republicans/Conservatives/Independents/Liberatarians/whatevers)
don't hate big government. They *love* big government as a means for
them to get rich, sucking off the public teat. What they don't like is
*democracy* - little people actually having the right to vote and stuff
like that.

Janis Papanagnou

unread,
Dec 19, 2014, 7:56:59 AM12/19/14
to
On 19.12.2014 13:47, Kenny McCormack wrote:
> I am using VIM 7.3 and my awk.vim file starts with:
>
> " Vim syntax file
> " Language: awk, nawk, gawk, mawk
> " Maintainer: Antonio Colombo <azc...@gmail.com>
> " Last Change: 2012 May 18
>
> The following program:
>
> #!/bin/gawk -f
> function Days(x) {
> return 28 + (x + int(x/8)) % 2 + 2 % x + 2 * int(1/x)
> }
> # Rest of program here
>
> when viewed in VIM, shows an error (i.e., it highlights in red) on the
> closing brace shown above and on the rest of the closing braces in the
> file. I know this is the offending function because if I remove this
> function, then the syntax highlighting cleans up and behaves normally.
>
> The above is syntactically correct and works fine when the program is run.
>
> So, it boils down to:
>
> 1) Is there a kludge/workaround to make the syntax highlighting work?
>
> 2) Is there a way to get the awk.vim file fixed?
>

I observed the same source of error (with vim 7.2) that you see; as far
as I see the source is a different problem, not braces but regexps; the
mis-displaced braces are just a consequence of the basic error. Observe
the result of this work-around

#!/bin/gawk -f
function Days(x) {
return 28 + (x + int(x*0.125)) % 2 + 2 % x + 2 * int(1/x)
}

The effect is due to a wrong parsing of /8)) % 2 + 2 % x + 2 * int(1/
as a regexp constant. WRT the question of a fix I have no solution, sorry.

Janis

Kenny McCormack

unread,
Dec 19, 2014, 8:21:17 AM12/19/14
to
In article <m717aq$7gr$1...@news.m-online.net>,
Janis Papanagnou <janis_pa...@hotmail.com> wrote:
...
>I observed the same source of error (with vim 7.2) that you see; as far
>as I see the source is a different problem, not braces but regexps; the
>mis-displaced braces are just a consequence of the basic error.

Understood. I understand the need to point this out, but I certainly
understand how vim syntax highlighting works. It's like a compiler; an
error upstream often triggers errors downstream of the actual error (and
often lots of them for a single upstream typo).

>Observe the result of this work-around
>
>#!/bin/gawk -f
>function Days(x) {
> return 28 + (x + int(x*0.125)) % 2 + 2 % x + 2 * int(1/x)
> }
>
>The effect is due to a wrong parsing of /8)) % 2 + 2 % x + 2 * int(1/
>as a regexp constant.

Makes sense. In fact, I ended up changing it to: rshift(x,3), which
conveniently eliminates the need for the int() as well.

>WRT the question of a fix I have no solution, sorry.

Hoping the cross-post to comp.editors brings someone who can get it fixed.

--
Those on the right constantly remind us that America is not a
democracy; now they claim that Obama is a threat to democracy.

Bruce Horrocks

unread,
Dec 21, 2014, 6:47:59 PM12/21/14
to
On 19/12/2014 13:21, Kenny McCormack wrote:
> Hoping the cross-post to comp.editors brings someone who can get it fixed.

The error seems to be because the Awk operators section of the awk.vim
syntax file are commented out. Why they are commented out is not stated
and the 'to do' list just says to 'dig into them'.

So, at the risk that re-enabling them causes other problems, you can
make a local copy of 'awk.vim' in '~/.vim/syntax/awk.vim' and edit the
lines that start '"syn match awkOperator' to remove the leading
double-quote.

--
Bruce Horrocks
Surrey
England
(bruce at scorecrow dot com)

Kenny McCormack

unread,
Dec 21, 2014, 7:42:47 PM12/21/14
to
In article <54975C2D...@scorecrow.com>,
Bruce Horrocks <07....@scorecrow.com> wrote:
>On 19/12/2014 13:21, Kenny McCormack wrote:
>> Hoping the cross-post to comp.editors brings someone who can get it fixed.
>
>The error seems to be because the Awk operators section of the awk.vim
>syntax file are commented out. Why they are commented out is not stated
>and the 'to do' list just says to 'dig into them'.
>
>So, at the risk that re-enabling them causes other problems, you can
>make a local copy of 'awk.vim' in '~/.vim/syntax/awk.vim' and edit the
>lines that start '"syn match awkOperator' to remove the leading
>double-quote.

Interesting. I'll try that.

--
People who say they'll vote for someone else because Obama couldn't solve
all of Bush's messes are like people complaining that he couldn't cure cancer,
so they'll go and vote for cancer.

Janis Papanagnou

unread,
Dec 22, 2014, 12:30:41 AM12/22/14
to
On 22.12.2014 01:42, Kenny McCormack wrote:
> In article <54975C2D...@scorecrow.com>,
> Bruce Horrocks <07....@scorecrow.com> wrote:
>>
>> The error seems to be because the Awk operators section of the awk.vim
>> syntax file are commented out. Why they are commented out is not stated
>> and the 'to do' list just says to 'dig into them'.
>>
>> So, at the risk that re-enabling them causes other problems, you can
>> make a local copy of 'awk.vim' in '~/.vim/syntax/awk.vim' and edit the
>> lines that start '"syn match awkOperator' to remove the leading
>> double-quote.
>
> Interesting. I'll try that.

Please keep us informed about your practical experiences with that change.

Janis

Eli the Bearded

unread,
Dec 29, 2014, 7:02:39 PM12/29/14
to
In comp.editors, Kenny McCormack <gaz...@shell.xmission.com> wrote:
> Hoping the cross-post to comp.editors brings someone who can get it fixed.

Have you tried emailing the listed maintainer of that file? The 2012 May
18 is the version included in vim 7.4. The 7.0 to 7.3 vims used a 2005 Mar
16 version, so it seems like he might still be a valid contact.

I read comp.editors and autoselect vi and vim threads, but I almost always
use ":syntax off" and have no experience with the syntax definition
methods, so I cannot help you with this matter.

Most vim-specific discussion has moved to the the mailing lists. In vim,
a ":help maillist" will give details.

Elijah
------
happened to have source code for five versions of vim handy
0 new messages