[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: grammar
From: |
Hans Aberg |
Subject: |
RE: grammar |
Date: |
Tue, 17 Apr 2001 11:10:01 +0200 |
[Please keep the Bison Help cc. In replies, please only quote relevant
context.]
At 08:29 +0200 2001/04/17, address@hidden wrote:
>thanks for your answer, but I need some explanation on the third rule you
>gave to me ( I am just starting learning).
>
>> a* := x, where x: | x a -- Zero or more
>>
>Does that mean that if we cannot apply any rule, then consider an empty
>string and read a "a"?
The empty string will also be an "a", just as you wanted.
>For example, if I have those rules:
>x= a s t d
>s = b ¦ s b
>t = ¦ t c
>
>and I want to parse a b b c c c d
>
>I'll get to a s . c c c d
I can't parse this stuff. :-)
>Does the 3rd rule mean : I cannot do anythind, so consider an empty string
>and push t? (in which case it would allow me to parse correctly the
>message).
If you have a rule in EBNF that looks like a ::= b c* d, plug it in Bison as
a: b x d { action }
x:
{ action for empty rule }
| x c { action }
where "x" is a name that does not appear elsewhere. (Popular names: c_list
or c_sequence.)
For the rule a ::= b c+ d, it would have been
x:
c { action }
| x c { action }
Hans Aberg
- grammar, bvermaut . cs, 2001/04/13
- RE: grammar, by way of Hans Aberg, 2001/04/17
- RE: grammar,
Hans Aberg <=