[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Re: problem with very simple gramma
From: |
Natalia Wolyczko |
Subject: |
Re: Re: problem with very simple gramma |
Date: |
Sun, 02 Dec 2007 22:58:45 +0100 |
>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
Hi Hans,
Many thanks for your replay.
I read calculator examples within the manual several times, but still have some
difficulties.
What I didn't mention in my previous email is that I also tried several
different grammas like this one below:
$ cat fb.l
%{
#include "fb.y.h"
%}
%%
mlah {return MLAH;}
\n {return NL;}
.* {}
%%
$ cat fb.y
%{
#include <stdio.h>
yydebug=1;
%}
%debug
%token MLAH NL
%%
input: /* empty */
| input line
;
line: NL
| boom NL { printf ("boom!\n"); }
| error NL { yyerrok; }
;
boom: MLAH MLAH
;
%%
and also didn't manage to succeed.
Would be nice to see an example of such a simple gramma somewhere. Can you
recommend any url where can I find some useful examples which are simple than
calculators?
Thanks,
--
Natalia Wolyczko