help-bison
[Top][All Lists]
Advanced

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

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


From: Atul Kulkarni
Subject: Flex Problem, I did not find a list for Flex hence postin here.
Date: Thu, 24 Mar 2005 16:06:33 +0530

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), address@hidden
<address@hidden> wrote:
> Send Help-bison mailing list submissions to
>        address@hidden
> 
> 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
>        address@hidden
> 
> You can reach the person managing the list at
>        address@hidden
> 
> 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 <address@hidden>
> Subject: Re: Grammar definition problem.
> To: Atul Kulkarni <address@hidden>
> Cc: address@hidden
> Message-ID: <address@hidden>
> 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 <address@hidden> 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.
> >>  >
> >>  >
> >>  >_______________________________________________
> >>  >address@hidden http://lists.gnu.org/mailman/listinfo/help-bison
> >>
> >>
> 
> ------------------------------
> 
> Message: 2
> Date: Tue, 22 Mar 2005 14:38:56 +0100
> From: Hans Aberg <address@hidden>
> Subject: Re: %union errors that shouldn't be there
> To: Laurence Finston <address@hidden>
> Cc: address@hidden, DYP <address@hidden>
> Message-ID: <address@hidden>
> 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 <address@hidden>
> Subject: Update Your Account
> To: address@hidden
> Message-ID: <address@hidden>
> Content-Type: text/plain; charset="us-ascii"
> 
> An HTML attachment was scrubbed...
> URL: 
> http://lists.gnu.org/pipermail/help-bison/attachments/20050322/5d941ac2/attachment.html
> 
> ------------------------------
> 
> Message: 4
> Date: Wed, 23 Mar 2005 14:16:09 +0100 (MET)
> From: Laurence Finston <address@hidden>
> Subject: Re: %union errors that shouldn't be there
> To: Hans Aberg <address@hidden>
> Cc: address@hidden, DYP <address@hidden>
> Message-ID: <address@hidden>
> Content-Type: TEXT/PLAIN; charset=US-ASCII
> 
> Hans Aberg wrote:
> 
> > With unions, the problem is, if con-/de-structors are non-trivial, that it
> > is impossible to know which ones to apply and when.
> 
> Stroustrup, _The C++ Programming Language_, Special Edition, 2000,
> p. 257, Section 10.4.12:
> 
> "Consequently, a union may not have members with constructors or
> destructors.  It wouldn't be possible to protect that object against
> corruption or to guarantee that the right destructor is called when
> the union goes out of scope."
> 
> > 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.
> 
> Add it where?  I suspect that doing so in C++ would break compatibility
> to C.  I haven't checked whether any C++ implementation has
> implemented such a facility as an extension, though.
> 
> It might be possible to implement a way of using class types with
> constructors and destructors in a `%union' in Bison, but not with an
> unextended C or C++ union.  This is just my opinion, but I think it's
> simpler to just use `void*'.
> 
> Laurence
> 
> ------------------------------
> 
> _______________________________________________
> Help-bison mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-bison
> 
> End of Help-bison Digest, Vol 17, Issue 26
> ******************************************
>




reply via email to

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