On Sun, Dec 28, 2008 at 6:29 AM, Luca <yel...@tin.it> wrote: > Yeah it was only an idea, only a an hint! I simply suggest WHERE to modify > the grammar without introducing conflicts, then you have to do it according > to your purposes. ... > Anyway the following productions are what you need: > > declaration > : declaration_specifiers ';' > | declaration_specifiers init_declarator_list ';' > | declaration_specifiers array_square init_declarator_list ';' > ; > > array_square > : > '[' constant_expression ']' > |array_square '[' constant_expression ']' > ; > > brackets like "int[4][4] a, b;" are now allowed and correctly parsed! > You can do the same with pointers! > > Once you understand where function declarations are managed, you can also > fix them.
Thank you, now I see why your comment was more helpful than I thought it was. I wasn't reading into it at first. > Anyway I think it is more convenient for you to rewrite a C-like grammar > subset rather than try to modify the ANSI C grammar according to your > purposes. ... > So I thought it was easiest for you to rewrite a grammar, because C grammar > isn't easy to understand if you never used tools like bison. ... > I always wrote grammar by myself rather than modify standard grammars; in > this way I can understand very well all the problems. Of course, this is a > time expensive way. I want to be able to do that, but judging by the progress of my (2) attempts I've gotten much further starting from a working grammar than from an empty file. It works now, except the conflict. > As you can read in the "red dragon", it is better to use %left, %prec and > similar keyword rather than grammar rules, because in the latter way the > parser has many states. Ahh, that book has been on my wish list. I think I should finally get it. -- Tom Lieber http://AllTom.com/ _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison