Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Gentoo User (http://www.linux-archive.org/gentoo-user/)
-   -   Query: any good venue for sample lex&yacc or flex&bison programs (http://www.linux-archive.org/gentoo-user/152505-query-any-good-venue-sample-lex-yacc-flex-bison-programs.html)

"Kevin O'Gorman" 09-02-2008 05:01 AM

Query: any good venue for sample lex&yacc or flex&bison programs
 
I've been teaching myself scanners over the summer, thinking to teach
my students this fall.

It was hard because just about all of the examples are inadequate for
one of these reasons:
1 They are pure lex, or pure yacc, not a combination. Ditto flex
and bison. Most of such sample programs work okay, but they're not
what's needed. Getting the parser and scanner to work together is the
key thing.
2 They are spotty in their coverage of features
3 They are incomplete and fail to compile as presented; the
documentation is very old-style UNIX in general, and very hard to
learn the necessary fixes from it.
4 They are old and fail on modern versions of the software
5 They are just plain broken

This applies to examples in the texinfo pages, the 2003 O'Reilly book,
and online manuals.

This is a very serious problem for learning these tools in their
combined form. I'm relatively good at dealing with such stuff (having
decades of practice), but I would not expect my undergrads to be able
to learn with these materials.

I was finally able to cobble together a working flex/bison parser from
the bison-bridge example in an appendix to the flex info page. I'd
like to share it, and perhaps other _working_ sample programs to the
web at large. Does anyone know of a better venue for this than just
some random page on my school's web server? I would like other people
to be able to find this stuff and perhaps add to it or otherwise
improve on it.

--
Kevin O'Gorman, PhD

"Kevin O'Gorman" 09-02-2008 05:07 AM

Query: any good venue for sample lex&yacc or flex&bison programs
 
Erratum:

On Mon, Sep 1, 2008 at 10:01 PM, Kevin O'Gorman <kogorman@gmail.com> wrote:
> ...
> This applies to examples in the texinfo pages, the 2003 O'Reilly book,
> and online manuals.

This book was actually published 11 years earlier, in 1992. Even a
current download
of the associated sample files had many build errors. I was unable to
get any samples
to work that used both tools. True, I got frustrated and quit trying
before working on
everything. That's sort of the point.

--
Kevin O'Gorman, PhD

Etaoin Shrdlu 09-02-2008 01:28 PM

Query: any good venue for sample lex&yacc or flex&bison programs
 
On Tuesday 2 September 2008, 07:01, Kevin O'Gorman wrote:

> I've been teaching myself scanners over the summer, thinking to teach
> my students this fall.
>
> It was hard because just about all of the examples are inadequate for
> one of these reasons:
> 1 They are pure lex, or pure yacc, not a combination. Ditto flex
> and bison. Most of such sample programs work okay, but they're not
> what's needed. Getting the parser and scanner to work together is the
> key thing.
> 2 They are spotty in their coverage of features
> 3 They are incomplete and fail to compile as presented; the
> documentation is very old-style UNIX in general, and very hard to
> learn the necessary fixes from it.
> 4 They are old and fail on modern versions of the software
> 5 They are just plain broken
>
> This applies to examples in the texinfo pages, the 2003 O'Reilly book,
> and online manuals.
>
> This is a very serious problem for learning these tools in their
> combined form. I'm relatively good at dealing with such stuff (having
> decades of practice), but I would not expect my undergrads to be able
> to learn with these materials.
>
> I was finally able to cobble together a working flex/bison parser from
> the bison-bridge example in an appendix to the flex info page. I'd
> like to share it, and perhaps other _working_ sample programs to the
> web at large. Does anyone know of a better venue for this than just
> some random page on my school's web server? I would like other people
> to be able to find this stuff and perhaps add to it or otherwise
> improve on it.

When I had to study the subject, I found these documents (in addition to
the dragon book, which was of course the primary source of information
for the underlying theory):

http://epaperpress.com/lexandyacc/
http://www.kiv.zcu.cz/~lobaz/fjp/yacc/compiler_flex_bison.pdf
http://www.ibm.com/developerworks/linux/library/l-lexyac.html

The above documents all contain examples of using lex+yacc together to
build an interpreter for simple languages, which is enough for an
undergrad course imho. Also, I seem to remember that the flex and bison
online manuals and the examples therein were quite accurate (but I might
be wrong, it was some time ago).

I think a good place to discuss lex/yacc issues and get pointers to
resources is the comp.compilers newsgroup, see
http://compilers.iecc.com/index.phtml for more information, especially
the FAQ section.

Another good place (maybe even better, since it's targeted to beginners)
is the compilers 101 mailing list, see
http://tech.groups.yahoo.com/group/compilers101/ for more information.

"Kevin O'Gorman" 09-03-2008 02:50 AM

Query: any good venue for sample lex&yacc or flex&bison programs
 
Okay, thanks for the responses. Some want this a lot, some not so
much. For the benefit of those who care, I created a GoogleGroup for
the purpose. It's called "Compilers", but the URL and email address
had to use compilerSamples to avoid conflicts.

http://groups.google.com/group/compilerSamples

There's a "files" section for holding stuff like the samples.
There's a "discussion" section for ongoing talk.
There's a "pages" section that works pretty much like a wiki.

It should do pretty well for a start.

++ kevin

On Tue, Sep 2, 2008 at 6:26 AM, Willie Wong <wwong@princeton.edu> wrote:
> On Mon, Sep 01, 2008 at 10:01:13PM -0700, Penguin Lover Kevin O'Gorman squawked:
>> I was finally able to cobble together a working flex/bison parser from
>> the bison-bridge example in an appendix to the flex info page. I'd
>> like to share it, and perhaps other _working_ sample programs to the
>> web at large. Does anyone know of a better venue for this than just
>> some random page on my school's web server? I would like other people
>> to be able to find this stuff and perhaps add to it or otherwise
>> improve on it.
>>
>
> Your school's web server is generally okay, IMHO. Tutorials from pages
> used in a course at a school I often find to be trustworthy. (And
> Google will find it!)
>
> Set up a Wiki somewhere if you want others to improve on it. (You can
> even set it up to be a closed Wiki where you have to be an approved
> user to edit; I've set up a Wiki for my school's local unix user
> group, and have had members of the community at large e-mailing us
> with suggestions for improvements on the content even though
> editing of the Wiki is restricted. I think just having a Wiki gives
> people the feeling that you are open to comments.)
>
> W
> --
> W: I love this dorm... one of the only underclassmen dorm buildings with
> a fully functional kitchen
> S: mm, ET kitchen...
> W: oh... go stick your head in an oven or something... why does MIT has to
> be better then princeton in every hair of a detail
> Sortir en Pantoufles: up 634 days, 11:59
>
>



--
Kevin O'Gorman, PhD

"Kevin O'Gorman" 09-03-2008 02:57 AM

Query: any good venue for sample lex&yacc or flex&bison programs
 
On Tue, Sep 2, 2008 at 6:28 AM, Etaoin Shrdlu <shrdlu@unlimitedmail.org> wrote:
> On Tuesday 2 September 2008, 07:01, Kevin O'Gorman wrote:
>
>> I've been teaching myself scanners over the summer, thinking to teach
>> my students this fall.
>>
>> It was hard because just about all of the examples are inadequate for
>> one of these reasons:
>> 1 They are pure lex, or pure yacc, not a combination. Ditto flex
>> and bison. Most of such sample programs work okay, but they're not
>> what's needed. Getting the parser and scanner to work together is the
>> key thing.
>> 2 They are spotty in their coverage of features
>> 3 They are incomplete and fail to compile as presented; the
>> documentation is very old-style UNIX in general, and very hard to
>> learn the necessary fixes from it.
>> 4 They are old and fail on modern versions of the software
>> 5 They are just plain broken
>>
>> This applies to examples in the texinfo pages, the 2003 O'Reilly book,
>> and online manuals.
>>
>> This is a very serious problem for learning these tools in their
>> combined form. I'm relatively good at dealing with such stuff (having
>> decades of practice), but I would not expect my undergrads to be able
>> to learn with these materials.
>>
>> I was finally able to cobble together a working flex/bison parser from
>> the bison-bridge example in an appendix to the flex info page. I'd
>> like to share it, and perhaps other _working_ sample programs to the
>> web at large. Does anyone know of a better venue for this than just
>> some random page on my school's web server? I would like other people
>> to be able to find this stuff and perhaps add to it or otherwise
>> improve on it.
>
> When I had to study the subject, I found these documents (in addition to
> the dragon book, which was of course the primary source of information
> for the underlying theory):
>
> http://epaperpress.com/lexandyacc/
> http://www.kiv.zcu.cz/~lobaz/fjp/yacc/compiler_flex_bison.pdf
> http://www.ibm.com/developerworks/linux/library/l-lexyac.html
>
> The above documents all contain examples of using lex+yacc together to
> build an interpreter for simple languages, which is enough for an
> undergrad course imho. Also, I seem to remember that the flex and bison
> online manuals and the examples therein were quite accurate (but I might
> be wrong, it was some time ago).
>
> I think a good place to discuss lex/yacc issues and get pointers to
> resources is the comp.compilers newsgroup, see
> http://compilers.iecc.com/index.phtml for more information, especially
> the FAQ section.
>
> Another good place (maybe even better, since it's targeted to beginners)
> is the compilers 101 mailing list, see
> http://tech.groups.yahoo.com/group/compilers101/ for more information.
>
>

Thanks, I've created a Google Group, and added these links to a page in it.
Check out http://groups.google.com/group/compilerSamples

--
Kevin O'Gorman, PhD

Etaoin Shrdlu 09-03-2008 09:00 AM

Query: any good venue for sample lex&yacc or flex&bison programs
 
On Wednesday 3 September 2008, 04:57, Kevin O'Gorman wrote:

> Thanks, I've created a Google Group, and added these links to a page
> in it. Check out http://groups.google.com/group/compilerSamples

I see that you are looking for the dragon book specs, here are some
links:

http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools
http://dragonbook.stanford.edu/
http://www.pearsonhighered.com/academic/product/0,3110,0321486811,00.html

It is universally regarded as "the" book about compilers.

Allan Gottlieb 09-03-2008 05:08 PM

Query: any good venue for sample lex&yacc or flex&bison programs
 
At Wed, 03 Sep 2008 11:00:34 +0200 Etaoin Shrdlu <shrdlu@unlimitedmail.org> wrote:

> On Wednesday 3 September 2008, 04:57, Kevin O'Gorman wrote:
>
>> Thanks, I've created a Google Group, and added these links to a page
>> in it. Check out http://groups.google.com/group/compilerSamples
>
> I see that you are looking for the dragon book specs, here are some
> links:
>
> http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools
> http://dragonbook.stanford.edu/
> http://www.pearsonhighered.com/academic/product/0,3110,0321486811,00.html
>
> It is universally regarded as "the" book about compilers.

I have extensive lecture notes based on the first 8 chapters.
They are available off my home page

http://cs.nyu.edu/~gottlieb

allan

"Kevin O'Gorman" 09-04-2008 02:24 AM

Query: any good venue for sample lex&yacc or flex&bison programs
 
On Wed, Sep 3, 2008 at 10:08 AM, Allan Gottlieb <gottlieb@nyu.edu> wrote:
> At Wed, 03 Sep 2008 11:00:34 +0200 Etaoin Shrdlu <shrdlu@unlimitedmail.org> wrote:
>
>> On Wednesday 3 September 2008, 04:57, Kevin O'Gorman wrote:
>>
>>> Thanks, I've created a Google Group, and added these links to a page
>>> in it. Check out http://groups.google.com/group/compilerSamples
>>
>> I see that you are looking for the dragon book specs, here are some
>> links:
>>
>> http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools
>> http://dragonbook.stanford.edu/
>> http://www.pearsonhighered.com/academic/product/0,3110,0321486811,00.html
>>
>> It is universally regarded as "the" book about compilers.
>
> I have extensive lecture notes based on the first 8 chapters.
> They are available off my home page
>
> http://cs.nyu.edu/~gottlieb
>
> allan
>
>

Thanks. I'll have a peek.


--
Kevin O'Gorman, PhD


All times are GMT. The time now is 09:50 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.