Home > Archive > Compilers > October 2005 > Using Flex and Bison
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Using Flex and Bison
|
|
| girvinator@gmail.com 2005-10-23, 7:56 am |
| Hi there everyone.
I am fairly new to programming compilers, although not to programming
in general.
I downloaded Parser Generator (http://www.bumblebeesoftware.com/) which
is simply an IDE for Lex and YACC.
I was just wondering, which way is the best to work on a compiler. Work
on the Lex file first, then the YACC file, and compile? Or the other
way round. I have read many tutorials, and some of the do it the other
way to others.
Also, does anyone know of a good tutorial that I could read, that will
actually COMPILE! All of the ones I have read have needed MAJOR changes
to even attempt to compile!
Anyways, thanks for everything.
-Girvo
| |
| Hans Aberg 2005-10-26, 7:01 pm |
| girvinator@gmail.com wrote:
> I was just wondering, which way is the best to work on a compiler. Work
> on the Lex file first, then the YACC file, and compile? Or the other
> way round. I have read many tutorials, and some of the do it the other
> way to others.
Just compile the file you have edited, be it the .l or the .y
file. Often these two hangs together, so that they often need to be
edited together, so that both needs to be compiled. So might want
writing a "make" script to automate it.
> Also, does anyone know of a good tutorial that I could read, that will
> actually COMPILE! All of the ones I have read have needed MAJOR changes
> to even attempt to compile!
The book by Aho, Sethi & Ullman, "Compilers..." (the "Dragon book")
has a simple Lex/Yacc calculator example, which can easily be made
working with Flex/Bison. Play around with it. Look into the Bison
manual, which shows how to use operator precedents. Then just move
along, either by building or to more advanced examples.
--
Hans Aberg
[The examples from lex&yacc in the comp.compilers archive work. You
may have to remove -ll and -ly from the Makefiles if you have a modern
version of lex and yacc without the separate libraries. -John]
| |
|
|
|
|
|
| Girvo wrote:
> toby wrote:
>
> Also, what is the bset compiler to use? GCC? I am using Dev-C++ and it
> comes up with errors for any Lex of YACC file i compile.
(According to http://www.bloodshed.net/devcpp.html) Dev-C++ is MinGW
based, which means it is in fact gcc. I have built flex/bison projects
with MinGW, native gcc, CodeWarrior, motorola mrc, and probably others.
--Toby
> [Lex and yacc produce quite portable C. I suspect there are errors in
> your action code. -John]
|
|
|
|
|