help-bison
[Top][All Lists]
Advanced

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

Re: Advice needed, please


From: Hans Aberg
Subject: Re: Advice needed, please
Date: Mon, 8 Jun 2009 23:42:00 +0200

On 8 Jun 2009, at 22:37, xelanoimis wrote:

All right, I changed the grammar to be more like this ansi c here:
http://www.quut.com/c/ANSI-C-grammar-y.html
And I got rid of the conflicts :) All except the "if else" which I
understand is OK to have.

If it is the dangling "else", you can get rid of that, too, by setting %nonassoc on the "then" and "else" tokens.

The issue with the %%error_verbose was that I had bison v1.24 which didn't
support it.

It is ancient.

For the sake of more info, I installed v2.4 and managed to compile my
grammar with it. I'm not sure what is the standard procedure for correct installing, but I copied the bison.exe and m4.exe (whatever it is) in my working folder and then started to gather required dll-s from the net. Also I had to copy some bison/share... folder in my c:/programfiles. I saw the path hardcoded in bison.exe. Is this normal? Can't I have them somewhere
else?

It depends how you compiler treats it, but on Posix computers (don't know about your platform), the paths become hardcoded by ./configure before the compile in the sources. Then at runtime, 'bison' must find 'm4', which must be sufficiently recent.

Now I have two more questions:

1. As I said, I split the expression rule to ensure correct precedences (like in ansi C exp_add, exp_mul, exp_shift,...). How is this affecting the resulting parser? I guess the functionality it's the same as having a single expression rule and the tokens arranged correctly when declared. I think the parser is a little bigger with more rules (not really sure). But which one
is it faster?

Most time is typically spent in the lexer and the actions, so just write the grammar to be correct and well structured. If the lexer is generated by Flex, it should not gulp too much in each match - buffer problem.

2. Is it worth for me to use the new bison version over the old 1.24? The output parser.cpp file was smaller before (70KB vs 100KB). Is the new one
significantly faster or it just reports errors better?

The old one is so ancient, nobody here can remember :-). Only the latest version is supported.

  Hans






reply via email to

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