Re: %union errors that shouldn't be there

2005-03-24 Thread Laurence Finston
On Thu, 24 Mar 2005, Hans Aberg wrote:

> It would not be the old union, but a new union with new required
> semantics, that is clear.

My point was that `union' is an element of the C and C++ languages,
whereas your new `Union' class would not be.  I think this is important,
others may not.

> >The compatibility of C++ to C is not complete but reasonably close.
> >I think this is one of the best and most important features of C++.

> Personally, I think this is one of the biggest hurdles with C++,
> because it inherits all C language quirks.

Stroustrup gives very thorough explanations of why he decided to do it
this way and is very open about the disadvantages.  There is no free
lunch.  It certainly makes it easier for a C programmer to start using
C++.  If it were not so, I suspect it would make it more difficult or even
impossible to do the kind of low-level programming with C++ that's
possible with C.  If this were so, it would make C++ useless from my
point of view.  (I know not everybody will agree me.)

Laurence


___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Flex Problem, I did not find a list for Flex hence postin here.

2005-03-24 Thread Atul Kulkarni
Hi All,
I am trying to redirect the standard input of flex to a character
pointer, I do not want to read a file for my input but want to
tokenize and parse a character string I have.
Also I can not want to store the character string in a file and then
read it from there.

So please can anyone tell me any mechanism to do this? I tried
changing yyin to char* but it failed miserably. or I will have to play
with machine generated code?

I am putting the problem of Flex in this list due to lack of knowledge
about Flex's mailing list and they are because normaly used in tandem
with each other!

Regards,
Atul.
On Wed, 23 Mar 2005 08:45:50 -0800 (PST), [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Send Help-bison mailing list submissions to
>help-bison@gnu.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>http://lists.gnu.org/mailman/listinfo/help-bison
> or, via email, send a message with subject or body 'help' to
>[EMAIL PROTECTED]
> 
> You can reach the person managing the list at
>[EMAIL PROTECTED]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Help-bison digest..."
> 
> Today's Topics:
> 
>   1. Re: Grammar definition problem. (Hans Aberg)
>   2. Re: %union errors that shouldn't be there (Hans Aberg)
>   3. Update Your Account (Service)
>   4. Re: %union errors that shouldn't be there (Laurence Finston)
> 
> --
> 
> Message: 1
> Date: Tue, 22 Mar 2005 14:36:27 +0100
> From: Hans Aberg <[EMAIL PROTECTED]>
> Subject: Re: Grammar definition problem.
> To: Atul Kulkarni <[EMAIL PROTECTED]>
> Cc: help-bison@gnu.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="us-ascii" ; format="flowed"
> 
> Please continue to cc the Help-Bison list, so that more can help.
> 
> Often one is using a program like Flex to generate a lexer, a program
> that tokenizes the input. Then the Bison generated parser gets token
> number to parse. This kind of setup is described, for example, in the
> book by Aho, Sethi & Ullman, "Compilers..." (the "Dragon Book").
> 
> At 10:12 +0530 2005/03/22, Atul Kulkarni wrote:
> >hi,
> >Read your reply on the Bison mailing list, but failed to under stand
> >your point. Can you please explain?
> >
> >Regards,
> >Atul.
> >
> >
> >On Mon, 21 Mar 2005 19:18:28 +0100, Hans Aberg <[EMAIL PROTECTED]> wrote:
> >>  In addition, note that most wold put this stuff in the lexer
> >>  (generated say by Flex).
> >>
> >>  At 14:55 +0530 2005/03/21, Atul Kulkarni wrote:
> >>  >Hi All,
> >>  >I am facing problem in defining the following grammar for Bison.
> >>  >
> >>  >X -> letter { letter | digit }.
> >>  >  here letter and digit are terminals and X is the non terminal symbol.
> >>  >
> >>  >I am not able to put this rule in the bison grammar form hence need
> >>  >some advice on this.
> >>  >
> >>  >in particular I am not able to express the
> >>  >
> >>  >letter AND {letter OR digit } rule in the Bison grammar.
> >>  >
> >>  >how do I put the OR part of the rule inconsideration of the fact that
> >>  >that scentence has to start with the "letter" and later have any
> >>  >number of of digit?
> >>  >
> >>  >
> >>  >Regards,
> >>  >Atul.
> >>  >
> >>  >
> >>  >___
> >>  >Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
> >>
> >>
> 
> --
> 
> Message: 2
> Date: Tue, 22 Mar 2005 14:38:56 +0100
> From: Hans Aberg <[EMAIL PROTECTED]>
> Subject: Re: %union errors that shouldn't be there
> To: Laurence Finston <[EMAIL PROTECTED]>
> Cc: help-bison@gnu.org, DYP <[EMAIL PROTECTED]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="us-ascii" ; format="flowed"
> 
> At 10:39 +0100 2005/03/22, Laurence Finston wrote:
> >On Mon, 21 Mar 2005, Hans Aberg wrote:
> >
> >>  They should be OK in C++, as pointers do not have non-trival
> >>  con-/de-structors. The compiler needs to see a declaration of the
> >>  name as a type, though, before it sees the pointer.
> >
> >If I remember correctly, it has to do with the size of the objects not
> >being known at the time the `union' declaration is compiled.  I'm not
> >sure, but I think I tested this once and discovered, somewhat to my
> >surprise, that using pointers in the `union' didn't work, either.  When I
> >get a chance, I'll check this carefully.
> 
> With unions, the problem is, if con-/de-structors are non-trivial,
> that it is impossible to know which ones to apply and when. The union
> does not contain any type information which field is selected. If one
> adds that, unions with non-trivial con-/de-Structors would be
> possible.
> --
>   Hans Aberg
> 
> --
> 
> Message: 3
> Date: Tue, 22 Mar 2005 14:35:12 -0800
> From: Service <[EMAIL PROTECTED]>
> Subject: Update Your Account
> To: help-bison@gnu.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: t

Re: %union errors that shouldn't be there

2005-03-24 Thread Hans Aberg
At 19:34 +0100 2005/03/23, Laurence Finston wrote:
 > One would need to
 be aware that the C++ unions
The rest of this sentence was missing.
If one adds such semantics to the C++ union, one needs to be aware of 
that it differs from that of the C union. I think this should be 
without problem, as one cannot only mix the two languages using 
'extern "C"' linkage from C++ for functions only. Perhaps there is a 
problem if the function has a C union as an argument. But then it 
does not have any non-trivial constructors to keep track of. So 
perhaps it works.
--
  Hans Aberg

___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: %union errors that shouldn't be there

2005-03-24 Thread Hans Aberg
At 11:10 +0100 2005/03/24, Laurence Finston wrote:
 > It would not be the old union, but a new union with new required
 semantics, that is clear.
My point was that `union' is an element of the C and C++ languages,
whereas your new `Union' class would not be.  I think this is important,
others may not.
This discussion is very confusing, because it mixes two topics: 
Extending C++, and what is appropriate for Bison. As for the latter 
question, one would have to give iyt a different name that %union. 
But with the %typed and other features suggested here (%define), that 
would not be a problem.

 > >The compatibility of C++ to C is not complete but reasonably close.
 >I think this is one of the best and most important features of C++.

 Personally, I think this is one of the biggest hurdles with C++,
 because it inherits all C language quirks.
Stroustrup gives very thorough explanations of why he decided to do it
this way and is very open about the disadvantages.  There is no free
lunch.  It certainly makes it easier for a C programmer to start using
C++.  If it were not so, I suspect it would make it more difficult or even
impossible to do the kind of low-level programming with C++ that's
possible with C.  If this were so, it would make C++ useless from my
point of view.  (I know not everybody will agree me.)
C++ has been developed over several decades. And some of the later 
C++ features have problems to coexist with C.
--
  Hans Aberg

___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: Flex Problem, I did not find a list for Flex hence postin here.

2005-03-24 Thread Hans Aberg
At 16:06 +0530 2005/03/24, Atul Kulkarni wrote:
I am putting the problem of Flex in this list due to lack of knowledge
about Flex's mailing list and they are because normaly used in tandem
with each other!
Try:
Help-flex mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/help-flex
http://lex.sourceforge.net/
--
  Hans Aberg
___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison