Grammar definition problem.
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
RE: Grammar definition problem.
Atul wrote: > X -> letter { letter | digit }. > here letter and digit are terminals and X is the non terminal symbol. > 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? Use a nonterminal symbol with a recursive rule to define your { letter | digit } part. Ciao.Vincent. ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: %union errors that shouldn't be there
On Sun, 20 Mar 2005, DYP wrote: > In file included from misery.ll:30: > gram.yy:26: error: ISO C++ forbids declaration of `astNode' with no type > gram.yy:26: error: expected `;' before '*' token > gram.yy:27: error: ISO C++ forbids declaration of `string' with no type > gram.yy:27: error: expected `;' before '*' token > gram.yy:28: error: ISO C++ forbids declaration of `nodeList' with no > type > gram.yy:28: error: expected `;' before '*' token > Apparently, your types `astNode', `string', and `nodeList' are undefined when your `%union' declaration is being compiled. Assuming you're using C, My guess is that you're not including the header file or files that declare them in your parser input file. On the other hand, if you're using C++, it might be because these are types that can't be included in `unions'. I don't remember the rule off-hand --- it has something to do with constructors and/or destructors. I don't know whether this programming error would cause this particular compiler error to be signalled, though, and I don't have time to test this myself at the moment. Laurence Finston ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: Grammar definition problem.
On Mon, 21 Mar 2005, Atul Kulkarni wrote: > 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? x: letter extension extension: /* Empty */ extension: extension letter extension: extension digit Laurence Finston ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: Grammar definition problem.
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 ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: %union errors that shouldn't be there
At 11:55 +0100 2005/03/21, Laurence Finston wrote: On Sun, 20 Mar 2005, DYP wrote: In file included from misery.ll:30: gram.yy:26: error: ISO C++ forbids declaration of `astNode' with no type gram.yy:26: error: expected `;' before '*' token gram.yy:27: error: ISO C++ forbids declaration of `string' with no type gram.yy:27: error: expected `;' before '*' token gram.yy:28: error: ISO C++ forbids declaration of `nodeList' with no type gram.yy:28: error: expected `;' before '*' token Apparently, your types `astNode', `string', and `nodeList' are undefined when your `%union' declaration is being compiled. Assuming you're using C, My guess is that you're not including the header file or files that declare them in your parser input file. On the other hand, if you're using C++, it might be because these are types that can't be included in `unions'. I don't remember the rule off-hand --- it has something to do with constructors and/or destructors. I don't know whether this programming error would cause this particular compiler error to be signalled, though, and I don't have time to test this myself at the moment. 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. -- Hans Aberg ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: %union errors that shouldn't be there
It looks as though the C++ compiler does not see the declaration of the types astNode, string (is it std::string?), nodeList, before it sees the union that the parser implements. So, you have to make sure that info is included somewhere, perhaps in the %{ ... %} segment before the %union in the .y file. At 16:57 -0500 2005/03/20, DYP wrote: Hello, My %union is declared in the following way and does have the proper header file included but I still get errors that should not be there. %union{ float fconst; int type; astNode* node; string* name; nodeList* list; } Here are the errors that I get when trying to compile the bison generated file In file included from misery.ll:30: gram.yy:26: error: ISO C++ forbids declaration of `astNode' with no type gram.yy:26: error: expected `;' before '*' token gram.yy:27: error: ISO C++ forbids declaration of `string' with no type gram.yy:27: error: expected `;' before '*' token gram.yy:28: error: ISO C++ forbids declaration of `nodeList' with no type gram.yy:28: error: expected `;' before '*' token I just don't see what I am doing wrong. Your help is appreciated. ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison -- Hans Aberg ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
RE: %union errors that shouldn't be there
Don't forget to cc Help-Bison, so others know that your problem has been solved. At 13:26 -0500 2005/03/21, Dmitry Podkuiko wrote: Thanks for your response Hans. Indeed, it had do with #include's being in the right order. The y.tab.h file has to be the last included and I had it first in the list which caused it not to see the definitions of my classes and even the std::string even though I included using namespace std;. Thank You. Dmitry. -Original Message- From: Hans Aberg [mailto:[EMAIL PROTECTED] Sent: Monday, March 21, 2005 1:17 PM To: [EMAIL PROTECTED] Cc: help-bison@gnu.org Subject: Re: %union errors that shouldn't be there It looks as though the C++ compiler does not see the declaration of the types astNode, string (is it std::string?), nodeList, before it sees the union that the parser implements. So, you have to make sure that info is included somewhere, perhaps in the %{ ... %} segment before the %union in the .y file. At 16:57 -0500 2005/03/20, DYP wrote: Hello, My %union is declared in the following way and does have the proper header file included but I still get errors that should not be there. %union{ float fconst; int type; astNode* node; string* name; nodeList* list; } Here are the errors that I get when trying to compile the bison generated file In file included from misery.ll:30: gram.yy:26: error: ISO C++ forbids declaration of `astNode' with no type gram.yy:26: error: expected `;' before '*' token gram.yy:27: error: ISO C++ forbids declaration of `string' with no type gram.yy:27: error: expected `;' before '*' token gram.yy:28: error: ISO C++ forbids declaration of `nodeList' with no type gram.yy:28: error: expected `;' before '*' token I just don't see what I am doing wrong. Your help is appreciated. ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison -- Hans Aberg ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
RE: %union errors that shouldn't be there
Issue solved. It was the order in while y.tab.h was included in the flex file. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hans Aberg Sent: Monday, March 21, 2005 1:32 PM To: Dmitry Podkuiko Cc: help-bison@gnu.org Subject: RE: %union errors that shouldn't be there Don't forget to cc Help-Bison, so others know that your problem has been solved. At 13:26 -0500 2005/03/21, Dmitry Podkuiko wrote: >Thanks for your response Hans. Indeed, it had do with #include's being in >the right order. The y.tab.h file has to be the last included and I had it >first in the list which caused it not to see the definitions of my classes >and even the std::string even though I included using namespace std;. Thank >You. >Dmitry. > > >-Original Message- >From: Hans Aberg [mailto:[EMAIL PROTECTED] >Sent: Monday, March 21, 2005 1:17 PM >To: [EMAIL PROTECTED] >Cc: help-bison@gnu.org >Subject: Re: %union errors that shouldn't be there > >It looks as though the C++ compiler does not see the declaration of >the types astNode, string (is it std::string?), nodeList, before it >sees the union that the parser implements. So, you have to make sure >that info is included somewhere, perhaps in the %{ ... %} segment >before the %union in the .y file. > >At 16:57 -0500 2005/03/20, DYP wrote: >>Hello, >> >>My %union is declared in the following way and does have the proper >>header file included but I still get errors that should not be there. >> >>%union{ >> float fconst; >> int type; >> astNode* node; >> string* name; >> nodeList* list; >> } >> >>Here are the errors that I get when trying to compile the bison >>generated file >> >>In file included from misery.ll:30: >>gram.yy:26: error: ISO C++ forbids declaration of `astNode' with no type >>gram.yy:26: error: expected `;' before '*' token >>gram.yy:27: error: ISO C++ forbids declaration of `string' with no type >>gram.yy:27: error: expected `;' before '*' token >>gram.yy:28: error: ISO C++ forbids declaration of `nodeList' with no >>type >>gram.yy:28: error: expected `;' before '*' token >> >>I just don't see what I am doing wrong. >> >>Your help is appreciated. >> >> >> >> >>___ >>Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison > > >-- >Hans Aberg ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Your eBay account could be Suspended
>> Dear eBay member, We at eBay are sorry to inform you that we are having problems with the billing information of your account. We would appreciate it if you would visit our eBay Billing Center and fill out the proper information that we are needing to keep you as an eBay member. If you don't comply until the 15st April 2005, your eBay membership may be suspended, or even deleted. Click here to complete our web form. As outlined in our User Agreement, eBay will periodically send you information about site changes and enhancements. Visit our Privacy Policy and User Agreement if you have any questions. Thank you! Copyright © 1995-2005 eBay Inc. All Rights Reserved. Designated trademarks and brands are the property of their respective owners. eBay and the eBay logo are trademarks of eBay Inc. ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison