From owner-freebsd-questions Sat Mar 1 9:12: 2 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8D90137B401 for ; Sat, 1 Mar 2003 09:12:00 -0800 (PST) Received: from po4.glue.umd.edu (po4.glue.umd.edu [128.8.10.124]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8127743FBD for ; Sat, 1 Mar 2003 09:11:59 -0800 (PST) (envelope-from arensb@Glue.umd.edu) Received: from nerafo.umd.edu (IDENT:root@nerafo.umd.edu [129.2.8.118]) by po4.glue.umd.edu (8.11.6/8.11.6) with ESMTP id h21HBqa19994; Sat, 1 Mar 2003 12:11:53 -0500 (EST) Received: from nerafo.umd.edu (IDENT:sendmail@localhost [127.0.0.1]) by nerafo.umd.edu (8.9.3/8.9.3) with SMTP id MAA02863; Sat, 1 Mar 2003 12:11:52 -0500 (EST) Received: (from arensb@localhost) by nerafo.umd.edu (8.9.3/8.9.3) id MAA02859; Sat, 1 Mar 2003 12:11:52 -0500 (EST) Date: Sat, 1 Mar 2003 12:11:52 -0500 From: Andrew Arensburger To: "Jack L. Stone" Cc: FreeBSD Question List Subject: Re: Bison Message-ID: <20030301171152.GA2653@umd.edu> Mail-Followup-To: "Jack L. Stone" , FreeBSD Question List References: <3.0.5.32.20030228084349.01e0b3b8@sage-one.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3.0.5.32.20030228084349.01e0b3b8@sage-one.net> User-Agent: Mutt/1.4i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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