Regarding building bison-3.4.2 on Windows

2020-06-17 Thread Singh, Binay


Hi Support team ,


I am trying to build  GNU bison-3.4.2 on Windows / Visual studio 15 . I am not 
able to find any info in Readme or Install files.
Please let me know if there is any documentation .

Thanks,
Binay



Your Personal Data: We may collect and process information about you that may 
be subject to data protection laws. For more information about how we use and 
disclose your personal data, how we protect your information, our legal basis 
to use your information, your rights and who you can contact, please refer to: 
www.gs.com/privacy-notices


Token value in custom error reporting

2020-06-17 Thread Daniele Nicolodi
Hello,

error reporting has always been a pain point for me in the use of flex
and bison, especially in coordinated error handling between the scanner
and the grammar. I am very happy to see a lot of improvements in this
area in the 3.6 release!

Trying to use `%define parse.error custom` in a project I realized that
it would be very handy to have the value of the token that caused the
syntax error available in yyreport_syntax_error. Is there a way to get
to it?

Thank you!

Cheers,
Dan



Token value in custom error reporting

2020-06-17 Thread Daniele Nicolodi
Hello,

error reporting has always been a pain point for me in the use of flex
and bison, especially in coordinated error handling between the scanner
and the grammar. I am very happy to see a lot of improvements in this
area in the 3.6 release!

Trying to use `%define parse.error custom` in a project I realized that
it would be very handy to have the value of the token that caused the
syntax error available in yyreport_syntax_error. Is there a way to get
to it?

Thank you!

Cheers,
Dan



Re: Regarding building bison-3.4.2 on Windows

2020-06-17 Thread Akim Demaille
Hi Binay,

> Le 17 juin 2020 à 18:26, Singh, Binay  a écrit :
> 
> 
> Hi Support team ,
> 
> 
> I am trying to build  GNU bison-3.4.2

The current version is 3.6.4, there's not much point in trying to build 3.4.2.

> on Windows / Visual studio 15 . I am not able to find any info in Readme or 
> Install files.
> Please let me know if there is any documentation .

The INSTALL file contains all the information to build Bison on POSIX systems.  
You'll have to build Bison from the POSIX subsystem.

Cheers!


Re: Token value in custom error reporting

2020-06-17 Thread Akim Demaille
Hi Daniele,

> Le 17 juin 2020 à 21:56, Daniele Nicolodi  a écrit :
> 
> Hello,
> 
> error reporting has always been a pain point for me in the use of flex
> and bison, especially in coordinated error handling between the scanner
> and the grammar. I am very happy to see a lot of improvements in this
> area in the 3.6 release!
> 
> Trying to use `%define parse.error custom` in a project I realized that
> it would be very handy to have the value of the token that caused the
> syntax error available in yyreport_syntax_error. Is there a way to get
> to it?

I think it's a mistake to try to use the semantic value in error messages.
It's often different from what the user wrote (think of escapes in strings,
non decimal integer literals, rounding errors in floats, etc.).  It can
also be nasty to display (e.g., super long string literals).  Also, if
you want to build an error message string, you'll have to face the problem
of converting the union that contains all the value types into the string
that corresponds to your current semantic value.

The right way to report more details to the user is to quote the source:

$ gcc-mp-10 /tmp/foo.c
/tmp/foo.c:1:12: error: expected ',' or ';' before string constant
1 | int y = 12 "232";
  |^

Cheers!


Re: Token value in custom error reporting

2020-06-17 Thread Daniele Nicolodi
Hi Akim,

On 17/06/2020 23:43, Akim Demaille wrote:
> I think it's a mistake to try to use the semantic value in error messages.

The goal would not be to use the semantic value in the error message,
but to use additional context attached to the token by the lexer to
decide how to report the error.

Thank you.

Cheers,
Dan



Redefining the literal string associated to the YYerror symbol

2020-06-17 Thread Daniele Nicolodi
Hello,

in Bison 3.6 is it possible to redefine the literal string associated to
the YYerror symbol (and to the YYEOF, YYUNDEF ones, although I don't
have immediate need for this)?

Doing it in the naive way:

%token YYerror "ERROR"

results in a warning:

warning: symbol YYerror given more than one literal string [-Wother]
  180 | %token YYerror "ERROR"
  |^~~

and in the literal string not being updated.

Thank you.

Cheers,
Dan



Re: Token value in custom error reporting

2020-06-17 Thread Akim Demaille



> Le 18 juin 2020 à 07:49, Daniele Nicolodi  a écrit :
> 
> Hi Akim,
> 
> On 17/06/2020 23:43, Akim Demaille wrote:
>> I think it's a mistake to try to use the semantic value in error messages.
> 
> The goal would not be to use the semantic value in the error message,
> but to use additional context attached to the token by the lexer to
> decide how to report the error.

Would you have an example of what you mean?


Re: Redefining the literal string associated to the YYerror symbol

2020-06-17 Thread Akim Demaille
Daniele,

> Le 18 juin 2020 à 07:57, Daniele Nicolodi  a écrit :
> 
> Hello,
> 
> in Bison 3.6 is it possible to redefine the literal string associated to
> the YYerror symbol (and to the YYEOF, YYUNDEF ones, although I don't
> have immediate need for this)?

YYerror is exactly the error token, the one in

exp: '(' error ')'

> Doing it in the naive way:
> 
> %token YYerror "ERROR"
> 
> results in a warning:
> 
> warning: symbol YYerror given more than one literal string [-Wother]
>  180 | %token YYerror "ERROR"
>  |^~~
> 
> and in the literal string not being updated.

There is no way to rename it, and it wouldn't make sense as the error
token is never presented as an "expected token".  The error token never
shows to the (end) user.  It appears in the debug traces, but that's
for the developer.

Cheers!