Re: problem linking program containing bison-generated parser
On Thu, 10 Mar 2005, Volker Wegert wrote: > I'm currently trying to gain some experience with flex and bison. I've found that I prefer using Flex and Bison separately rather than together. If you're just starting out learning Bison, I think you might find it easier to write your own `yylex()' function rather than using Flex. > In one of my > projects, I'd like to use these two tools together with some Qt classes. I'm > not trying to create an object-oriented parser, I'm just using Qt's string and > list objects as I'm much more familiar with them. Perhaps it would simplify matters if you just used the `string' and `list' template classes from the C++ Standard Template Library. You don't need to generate a C++ parser function. I just generate an ordinary C parser function, use C++ in the actions, and compile with `g++'. > However, I get the following error message during linking (output > abbreviated): > | undefined reference to `yyparse()' > > So as far as I can see, the function yylex() should be present. Can anybody > tell me what's going wrong here? I didn't see an error message about an undefined reference to `yylex()'. Since you have an undefined reference to `yyparse()', I would check two things first: 1. Is `yyparse()' declared in a header file included by all compilation units containing a call to it? 2. Is the object file containing the definition of `yyparse()' included in the call to the linker? Laurence Finston http://www.gnu.org/software/3dldf/LDF.html ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: Question about "Conditions for Using Bison" in Bison 2.0 documentation
Paul Eggert wrote: Sylvain Schmitz <[EMAIL PROTECTED]> writes: It might have been true when these skeleton first appeared, but I don't think it is any more, since both commercial and open source implementations exist now. OK, let's solve the problem. The first step: could you please come up with a brief list of the commercial and other alternative implementations, as compared to Bison? If we present such a list to RMS in a concise and pragmatic way, he'll most likely change his mind, just as he changed his mind for the yacc skeleton. GLR parser generators: * Elkhound [http://www.cs.berkeley.edu/~smcpeak/elkhound/] generates GLR parsers in C++ or OCaml, and is distributed under the revised BSD license. The GLR algorithm used is AFAIR very close to the one in bison. * DParser [http://dparser.sourceforge.net/] generates GLR parsers in C, distributed under BSD license. It also provides scannerless support. * PyGgy [http://www.lava.net/~newsham/pyggy/] generates GLR parsers in Python, but based on SLR tables instead of the LALR ones. It is in the public domain. * Happy [http://haskell.cs.yale.edu/happy/] just added GLR support; it generates parsers in Haskell, and is distributed under a BSD-style license. * SGLR [http://www.cwi.nl/htbin/sen1/twiki/bin/view/SEN1/SGLR] also provides scannerless support, and is distributed under the GPL. There might be plenty of others. Some of these generate parsers in C++. Other parser generator targeting C++ include ANTLR predicated LL parser generator [http://www.antlr.org/] (in public domain), the GOLD LALR(1) parser [http://www.devincook.com/goldparser/] distributed under the zlib/libpng license, the Spirit framework [http://spirit.sourceforge.net/] for backtracking LL distributed under a permissive license, and so on and so forth. Commercial software is also available, but more difficult to find. -- Sylvain ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
lea.y:124.34-35: $1 of `program' has no declared type
Hi ! I'm developing an interpreter with C, bison and flex. Now I have already done the flex file, the bison file, and the header file were the rule/tokens type are defined. ###header file: A lot of thins like: typedef struct { int *foo; char *bar; } Tmy_type; ###flex file: It has needed includes similar to: #include "header.h" #include "y.tab.h" and tokens are used like: {D}+{ yylval.int_val = malloc(sizeof(int)); *(yylval.int_val) = atoi(yytext); printf("INT_VAL "); return INT_VAL; } ###bison file: It has proper includes: #include "header.h" Also an %union similar to: %union { int *int_val; Tmy_type *Tmy_type; } tokens with need of type : %token INT_VAL And rules types: %type myrule ### I've created a Makefile that compiles as usual: lea: header.o flex lea.l bison --verbose -d lea.y $(CC) -o lea header.o lex.yy.c y.tab.c -lfl -lm $(CFLAGS) But I'm having problems with the lea.y file. It just complains for every rule like this: $ bison --verbose -d lea.y lea.y:124.34-35: $1 of `program' has no declared type lea.y:124.42-43: $3 of `program' has no declared type Anyone can help me with this please? Any ideas? Any suggestions ? You can see actual code ifyou want - it's not much large :-). To gt it, just execute: svn checkout svn://svn.berlios.de/lea/trunk Thanks for your time, Edulix. ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
lea.y:124.34-35: $1 of `program' has no declared type
Hi ! I'm developing an interpreter with C, bison and flex. Now I have already done the flex file, the bison file, and the header file were the rule/tokens type are defined. ###header file: A lot of thins like: typedef struct { int *foo; char *bar; } Tmy_type; ###flex file: It has needed includes similar to: #include "header.h" #include "y.tab.h" and tokens are used like: {D}+{ yylval.int_val = malloc(sizeof(int)); *(yylval.int_val) = atoi(yytext); printf("INT_VAL "); return INT_VAL; } ###bison file: It has proper includes: #include "header.h" Also an %union similar to: %union { int *int_val; Tmy_type *Tmy_type; } tokens with need of type : %token INT_VAL And rules types: %type myrule ### I've created a Makefile that compiles as usual: lea: header.o flex lea.l bison --verbose -d lea.y $(CC) -o lea header.o lex.yy.c y.tab.c -lfl -lm $(CFLAGS) But I'm having problems with the lea.y file. It just complains for every rule like this: $ bison --verbose -d lea.y lea.y:124.34-35: $1 of `program' has no declared type lea.y:124.42-43: $3 of `program' has no declared type Anyone can help me with this please? Any ideas? Any suggestions ? You can see actual code ifyou want - it's not much large :-). To gt it, just execute: svn checkout svn://svn.berlios.de/lea/trunk Thanks for your time, Edulix. ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
lea.y:124.34-35: $1 of `program' has no declared type
Hi ! I'm developing an interpreter with C, bison and flex. Now I have already done the flex file, the bison file, and the header file were the rule/tokens type are defined. ###header file: A lot of thins like: typedef struct { int *foo; char *bar; } Tmy_type; ###flex file: It has needed includes similar to: #include "header.h" #include "y.tab.h" and tokens are used like: {D}+{ yylval.int_val = malloc(sizeof(int)); *(yylval.int_val) = atoi(yytext); printf("INT_VAL "); return INT_VAL; } ###bison file: It has proper includes: #include "header.h" Also an %union similar to: %union { int *int_val; Tmy_type *Tmy_type; } tokens with need of type : %token INT_VAL And rules types: %type myrule ### I've created a Makefile that compiles as usual: lea: header.o flex lea.l bison --verbose -d lea.y $(CC) -o lea header.o lex.yy.c y.tab.c -lfl -lm $(CFLAGS) But I'm having problems with the lea.y file. It just complains for every rule like this: $ bison --verbose -d lea.y lea.y:124.34-35: $1 of `program' has no declared type lea.y:124.42-43: $3 of `program' has no declared type Anyone can help me with this please? Any ideas? Any suggestions ? You can see actual code ifyou want - it's not much large :-). To gt it, just execute: svn checkout svn://svn.berlios.de/lea/trunk Thanks for your time, Edulix. ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: problem linking program containing bison-generated parser
Laurence Finston wrote: > On Thu, 10 Mar 2005, Volker Wegert wrote: > > > I'm currently trying to gain some experience with flex and bison. > > I've found that I prefer using Flex and Bison separately rather than > together. If you're just starting out learning Bison, I think you > might find it easier to write your own `yylex()' function rather than > using Flex. Actually why? For lexing identifiers, numbers, the usual stuff, it's one line in flex, and loops, sometimes switches and manual loop-ahead in C. And for similar-beginning tokens (e.g. `&', `&&', `&=' in C), IMHO it gets more readable in flex (one entry per item, can be group topically -- arithmetics, comparisons, ...) than in manual code (where they have to be handled together after reading the first `&'). I recently converted a complex lexer from manual to flex, and though I added some more special cases etc., the resulting flex code was shorter and more readable. So I'm interested why you find the manual way easier. Frank -- Frank Heckenbach, [EMAIL PROTECTED] http://fjf.gnu.de/ GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E) ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: lea.y:124.34-35: $1 of `program' has no declared type
On Fri, 11 Mar 2005, Edulix wrote: > But I'm having problems with the lea.y file. It just complains for every rule > like this: > $ bison --verbose -d lea.y > lea.y:124.34-35: $1 of `program' has no declared type > lea.y:124.42-43: $3 of `program' has no declared type > Anyone can help me with this please? Any ideas? Any suggestions ? > Apparently, you need to declare types for the symbols used on the right-hand side of your rule for `program'. Laurence Finston ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: problem linking program containing bison-generated parser
On Fri, 11 Mar 2005, Frank Heckenbach wrote: > Laurence Finston wrote: > > > I've found that I prefer using Flex and Bison separately rather than > > together. If you're just starting out learning Bison, I think you > > might find it easier to write your own `yylex()' function rather than > > using Flex. > > Actually why? For lexing identifiers, numbers, the usual stuff, it's > one line in flex, and loops, sometimes switches and manual > loop-ahead in C. > And for similar-beginning tokens (e.g. `&', `&&', > `&=' in C), IMHO it gets more readable in flex (one entry per item, > can be group topically -- arithmetics, comparisons, ...) than in > manual code (where they have to be handled together after reading > the first `&'). > So I'm interested why you find the manual way easier. I had problems generating a reentrant scanner using Flex, and I wasn't able to find out what was going wrong. There was some discussion about this on this list at the time, about a year ago. In my scanner, I use what I call the "category code" approach rather than regular expressions. It's the way Knuth used for TeX and Metafont. I'm pretty sure that any scanner written in one of these ways could be reformulated using the other one. However, I find that the category code approach allows for finer control. At least one other person has had problems with regular expressions and posted a question to this list since I've been a subscriber. It might not be possible to implement a couple of things that my scanner does in a straightforward way with Flex. Therefore, I think that using Flex might artificially limit the kinds of things people do with Bison. I don't recall the details, since it's been awhile since I've worked on this part of my program. Nor do I think that the power of Flex is needed for the kind of scanning Bison needs. I like to use Flex when I can implement functionality in its actions, rather than just passing tokens to Bison. If someone wants to learn Bison, I think it might simplify the task if he or she could just concentrate on Bison, rather than having to learn Flex at the same time. I also think that implementing `yylex()' oneself might give one a better insight into what it does and what Bison's requirements are. This might help one to understand how to use Flex well in combination with Bison, if one later decides to use it. I try to avoid using `switch' (I just don't like it), and I don't have to examine the lookahead token too often. Otherwise, I like doing the sort of somewhat low-level programming you describe. Clearly, this is a matter of taste, and I certainly don't think there's anything wrong with using Bison in combination with Flex, if someone prefers to do this. I might even do it myself, if I ever really needed regular expressions when scanning. However, I thought it was worthwhile to point out that it isn't necessarily the best way under all circumstances. Laurence ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: Question about "Conditions for Using Bison" in Bison 2.0 documentation
At 15:11 -0800 2005/03/10, Paul Eggert wrote: >> I don't know what the default status is of works produced by X's use >> of Y's copyrighted programs, but I rather suspect that such products >> belong to X > >It depends on whether the produced works are "derivative works" of Y's >copyrighted programs. For many programs (e.g., "cat") it's quite >clear that the program's output is not a derivative work of the >program. > >But in the case of Yacc, it's pretty clear that the C output file is a >derivative work of both the Yacc template file and the user's source >file. So, legally speaking, the user and Sun both have copyright >interest in the C output file, and you need permission from both >parties before you can redistribute that file. This is interesting: First it means that it is wrong for Yacc/Bison to put a single copyright on the output file. But also, second, it is a tricky question what copyrighted material one can use for free. I believe that news reporting can include copyrighted quotes and such, without having to oblige to the original copyright. Copyright is essentially a business protection law, and freedom of speech laws have precedence. Hans Aberg ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: Identifying rule responsible for lookahead
At 01:10 -0500 2005/03/11, Alfonso Urdaneta wrote: >> No, there is no such Bison design doc's: Only reading the Bison source code >> itself. (Apart from that somebody wrote something in Spanish, I think.) > >link ? It was a Spanish fellow "CJ" <[EMAIL PROTECTED]>, writing a thesis on his tutor's DR algorithm; see the Bug-Bison list around 2001-2002. For example: At 23:50 +0100 2001/06/17, CJ wrote: > I have allocated the tesis in ps format in this location FTP: host club2.telepolis.com password: chinijo the file is drlr.zip Perhaps Akim Demaille knows more about this, and what the stuff in Spanish is located. It might be interesting to produce some draft in English, and then make a description of Bison internals, as the question pos up every know and then. I also found this: At 21:19 + 2002/09/11 in Help-Bison, Carlos Javier Borges Villalba <[EMAIL PROTECTED]> wrote: Subject: Re: if you can speak spanish you wil be lucky >In this url http://club.telepolis.com/bisondr >there is a document where you can find information about Bison, how its >construct the LALR automaton, how it solve conflicts.. is in >spanish. It is not right version, next week it will be available. Sometimes >the url is wrong but try it later there is the document. > >I hope it will be useful. And if you have suggest you can email me. Surely I >will put the source latex in that url. Hans Aberg ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison