help-bison
[Top][All Lists]
Advanced

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

Re: problem with very simple gramma


From: Hans Aberg
Subject: Re: problem with very simple gramma
Date: Sun, 2 Dec 2007 20:06:30 +0100

On 1 Dec 2007, at 23:07, Natalia Wolyczko wrote:

I'm new to bison, first of all I've tried to write a simple "hello- world" like program using flex/bison. All I want is to see "boom!" message after reading two MLAH tokens, which corresponds to input string of the same name i.e. "mlah".

This works fine, I'm able to see "boom!" message after typing mlah twice, the things which I really don't get is why I see "syntax errror" once mlah is entered third time? What I expected is the situation in which I see "boom!" every two "mlah" occurences.
Can anybody please explain me what's going on?

Because you have written the grammar for a language matching exactly that token sequence and nothing else. If you want to do what you indicated, you need to do recursion - the Bison manual has some sections on that. Also, check out the calculator example - good starting point.

  Hans Aberg






reply via email to

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