Date: Sat, 1 Mar 2003 12:11:52 -0500 From: Andrew Arensburger <arensb+freebsd-questions@Glue.umd.edu> To: "Jack L. Stone" <jackstone@sage-one.net> Cc: FreeBSD Question List <freebsd-questions@FreeBSD.ORG> Subject: Re: Bison Message-ID: <20030301171152.GA2653@umd.edu> In-Reply-To: <3.0.5.32.20030228084349.01e0b3b8@sage-one.net> References: <courier.3E5F3B12.000043F0@perimeter.co.za> <courier.3E5F3B12.000043F0@perimeter.co.za> <3.0.5.32.20030228084349.01e0b3b8@sage-one.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Feb 28, 2003 at 08:43:49AM -0600, Jack L. Stone wrote: > I know this was discussed many months ago, but I've forgotten what Bison is > used for....?? 'bison' is the GNU version of 'yacc'. 'yacc' (Yet Another Compiler Compiler) is a massively-useful but evidently forgotten tool for generating parsers. Yacc reads a file containing a BNF-like grammar that describes the syntax of whatever it is that you want to parse, and outputs C code that parses input in that format. For instance, if you wanted to parse timestamps, you might specify the grammar as date_time: date time /* Date and time */ | date /* Just a date, no time */ ; date: NUMBER '/' NUMBER '/' NUMBER /* YYYY/MM/DD */ | DAY_ABBR ' ' MON_ABBR ' ' NUMBER /* "Mon Jan 13" */ ; time: NUMBER ':' NUMBER ':' NUMBER /* HH:MM:SS */ | NUMBER ':' NUMBER /* HH:MM */ ; Yacc is most often used in conjunction with 'lex' (or the GNU version, 'flex') which reads an input stream recognizes individual tokens (in this example: "NUMBER", "DAY_ABBR", and "MON_ABBR") and feeds them back to Yacc. -- Andrew Arensburger, Systems guy University of Maryland arensb+freebsd-questions@glue.umd.edu Office of Information Technology Enter any 12 digit prime number to continue: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030301171152.GA2653>