help-bison
[Top][All Lists]
Advanced

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

RE: grammar


From: by way of Hans Aberg
Subject: RE: grammar
Date: Tue, 17 Apr 2001 11:09:51 +0200

Hi,

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"?

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

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).
Message would then be a s t . c c c d

Thanks

Bertrand


> ----------
> From:         Hans Aberg[SMTP:address@hidden
> Sent:         Saturday, April 14, 2001 11:50
> To:   address@hidden
> Cc:   address@hidden
> Subject:      Re: grammar
>
> At 14:03 +0200 2001/04/13, address@hidden wrote:
> >Could someone tell me how I can write the grammar to parse such message:
> >
> >abbcccd
> >
> >in which
> >a is mandatory and non repetitive,
> >b is mandatory and repetitive,
> >c is optional and repetitive,
> >d is mandatory and non repetitive.
>
> If you are only interested in regular words, and do not intend to attach
> actions to the rules, you can use Flex
>   ftp://ftp.digital.com/pub/GNU/non-gnu/flex/flex-2.5.4a.tar.gz
> If you need greater generality, under C++, you could create a istream that
> outputs characters representing grammar symbols.
>
> Alternatively, using Bison, you could write your grammar as EBNF, and then
> apply the definitions reducing to BNF (using Bison notation)
>   a? := | a                      -- Optional.
>   a+ := x, where x: a | x a      -- One or more.
>   a* := x, where x:   | x a      -- Zero or more.
>
> One the more advanced level, one could try tweak Bison so that it
> understands EBNF directly. -- This is the way that mid-actions are
> implemented (i.e., by introducing a new empty rule with an action). If you
> do this, please don't report it to Bison bugs.
>
>   Hans Aberg
>
>


Visit us at http://www.clearstream.com
Check out current job vacancies at
http://www.clearstream.com/public/english/e_vacs.htm

IMPORTANT MESSAGE

Internet communications are not secure and therefore Clearstream
International does not
accept legal responsibility for the contents of this message.

The information contained in this e-mail is confidential and may be legally
privileged. It is
intended solely for the addressee. If you are not the intended recipient,
any disclosure,
copying, distribution or any action taken or omitted to be taken in
reliance on it, is
prohibited and may be unlawful. Any views expressed in this e-mail are
those of the
individual sender, except where the sender specifically states them to be
the views of
Clearstream International or of any of its affiliates or subsidiaries.

END OF DISCLAIMER





reply via email to

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