bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problematic syntax error format


From: arnold
Subject: Re: Problematic syntax error format
Date: Mon, 13 Nov 2023 13:22:58 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Hello.

Thank you for taking the time to submit an issue.

Gawk is following the GNU Coding Standards in the format
of its messages. See https://www.gnu.org/prep/standards/standards.html#Errors.

In addition, it has been doing so for literally decades; changing it
now would undoubtedly break things for other users.

I suspect that Vim can be customized to understand a different format
of output for its :make command; please check its help and perhaps
do some Internet searching.

Best wishes,

Arnold

Emanuele Torre <torreemanuele6@gmail.com> wrote:

> Hello.
>
> Currently, when GNU awk encounters a syntax error in a script file, it
> reports a error message in the following format:
>
>   awk: gen_enum_h.awk:7:     if {(!ename)
>   awk: gen_enum_h.awk:7:        ^ syntax error
>
> And, similarly, when it encounters a runtime error, it uses this format:
>
>   awk: gen_enum_h.awk:82: fatal: attempt to use scalar `enums' as an array
>
> So a line prefixed by  ARGV[0] ": " FILENAME ":" FNR ":"   basically.
>
> The problem with that is that I am using a awk script in a build step of
> one of my programs, and vim's :make command, when building fails, opens
> automatically the file specified by the first line on the stdout or
> stderr that contains :NUMBER: since that is usually how compilers and
> other programs (e.g. grep) report the location of a errors or matches.
> But the way it interprets that line is basically just:
> * everything up to the first :NUMBER: is the path to the file with the
>   problem
> * NUMBER is the line number
> * if there is another  NUMBER:   after the first :NUMBER:, that is the
>   column number
>
> When I accidentaly introduce a error in that script when I am modifying
> it, since gawk is prefixing ARGV[0]": " to FILENAME":"FNR":", for the
> previously mentioned error message, vim opens a new non-existing file
> named "awk: gen_enum_h.awk" instead of "gen_enum_h.awk" at line 7. Which
> is quite annoying.
>
> I agree that vim is not being very smart here, but I also think gawk
> should avoid outputing FILENAME:LINENUMBER with something at the start
> of the line since the general convention is to only output that kind of
> format from at the start of the line.
>
> Could you please change the output format of those syntax errors to make
> them play nicer with vim's :make command?
>
> Either don't use ":"NUMBER":"; and instead say "line NUMBER:" like mawk,
> nawk, GNU sed, bash, and others, so it is not recognised as
> FILENAME:NUMBER:
>
>   mawk: gen_enum_h.awk: line 7: syntax error at or near {
>
>   nawk: syntax error at source line 4 source file gen_enum_h.awk
>    context is
>               if >>>  { <<<
>   nawk: illegal statement at source line 4 source file gen_enum_h.awk
>   nawk: illegal statement at source line 4 source file gen_enum_h.awk
>           missing }
>
>   sed: file - line 1: extra characters after command
>
>   /dev/stdin: line 2: syntax error: unexpected end of file
>
> Or, even better, continue using FILENAME":"FNR":", but output don't
> prefix it with "awk: "; for example:
>
>   awk: description of the syntax error or just "syntax error"
>   gen_enum_h.awk:7:     if {(!ename)
>   gen_enum_h.awk:7:        ^ syntax error 
>
>   awk: description of the syntax error or just "syntax error"
>   gen_enum_h.awk:7:8:     if {(!ename)
>   gen_enum_h.awk:7:8:        ^ syntax error 
>
>   awk: runtime error
>   gen_enum_h.awk:82: fatal: attempt to use scalar `enums' as an array
>
>   awk: fatal: attempt to use scalar `enums' as an array
>   gen_enum_h.awk:82: content of the line here if available
>
> Thank you!
>
> o/
>  emanuele6



reply via email to

[Prev in Thread] Current Thread [Next in Thread]