HP3000-L Archives

February 1999, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Bruce Toback <[log in to unmask]>
Reply To:
Bruce Toback <[log in to unmask]>
Date:
Fri, 26 Feb 1999 19:35:56 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (41 lines)
Tom, [log in to unmask] writes:

>I notice the HP posix structure has Lex (Lexical Analyzer) and Yacc (Yet
>Another Compiler Compiler). I understand that Lex is supposed to analyze
>a Source Code document and produce a Formal Grammar document to be fed
>into Yacc which will create a Compiler for it.
>
>Is this correct and are there any online Lex and Yacc tutorials?

Lex is a program that will produce a lexical analyzer from a set of
patterns describing a language syntax. The lexical analyzer source code
is in C and expects to call some routines that you supply in order to get
input text. The analyzer is in the form of a couple of subroutines that
you call in order to analyze the input stream and retrieve individual
tokens. (Actually, Lex produces tables for the subroutines; the routines
themselves are part of a library that's supplied with Lex.)

Yacc takes a formal grammar and produces a compiler for it. The compiler
produced by Yacc calls routines that you supply in order to perform the
semantic actions associated with various language constructs, as well as
routines that you supply in order to provide it with tokens in the
grammar. Naturally, the compiler is perfectly happy to call the
Lex-produced lexical analyzer for this purpose.

There are lots of books about Lex and Yacc; I don't know of any extensive
material on-line. The O'Reilly book, titled simply _lex & yacc_ (Levine,
Mason & Brown 1992, ISBN 1-56592-000-7), is quite good.

-- Bruce


--------------------------------------------------------------------------
Bruce Toback    Tel: (602) 996-8601| My candle burns at both ends;
OPT, Inc.            (800) 858-4507| It will not last the night;
11801 N. Tatum Blvd. Ste. 142      | But ah, my foes, and oh, my friends -
Phoenix AZ 85028                   | It gives a lovely light.
btoback AT optc.com                |     -- Edna St. Vincent Millay
Mail sent to [log in to unmask] will be inspected for a
fee of US$250. Mailing to said address constitutes agreement to
pay, including collection costs.

ATOM RSS1 RSS2