how to work with Bison locations?

2009-06-02 Thread Kynn Jones
Hi. I'm working with Bison (and Flex) for the first time, and it's rough going. I can't get Bison locations to work. The following toy parser illustrates the problem. Here's the file for Flex, bug.l: --- %{ #include "

Re: how to work with Bison locations?

2009-06-02 Thread Hans Aberg
On 2 Jun 2009, at 22:27, Kynn Jones wrote: I can't get Bison locations to work. Bison now has a %locations option - see this link and its example. http://lists.gnu.org/archive/html/help-bison/2009-05/msg00040.html Compile with 'g++' or 'gcc -lstdc++'. It has some use of locations - perhaps

Re: how to work with Bison locations?

2009-06-02 Thread Kynn Jones
On Tue, Jun 2, 2009 at 5:06 PM, Hans Aberg wrote: > On 2 Jun 2009, at 22:27, Kynn Jones wrote: > >> I can't get Bison locations to work. > > Bison now has a %locations option - see this link and its example. > http://lists.gnu.org/archive/html/help-bison/2009-05/msg00040.html > Compile with 'g++'

Re: how to work with Bison locations?

2009-06-02 Thread Hans Aberg
Please keep the cc to the Help Bison list, so others can follow. You have to set it somehow, not just add %locations - Bison cannot know what values you want to have, as it just reads a stream of tokens. Bison had broken locations in the past, and and now Akim (I think) has made some new st

Re: how to work with Bison locations?

2009-06-02 Thread Luca
Location are created by lexer and "reduced" by the parser, so you have to create them using the lexer: #define YY_USER_ACTION {yylloc.first_line = yylineno; yylloc.first_column = colnum; colnum=colnum+yyleng; yylloc.last_column=colnum; yylloc.last_line = yylineno;} this macro is executed at