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 [EMAIL PROTECTED] Office of Information Technology Enter any 12 digit prime number to continue: To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-questions" in the body of the message