Date: Sun, 07 Sep 2003 17:38:44 +0300 From: Diomidis Spinellis <dds@aueb.gr> To: Bruce Evans <bde@zeta.org.au> Cc: Jens Schweikhardt <schweikh@FreeBSD.org> Subject: Re: cvs commit: src/bin/sh arith.h arith.y arith_lex.l shell.h Message-ID: <3F5B42F4.D854AA26@aueb.gr> References: <200309041828.h84ISga9035283@repoman.freebsd.org> <20030907191013.U3442@gamplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans wrote: > Thanks. I don't know of any style rules for lex and yacc sources other > than very general ones, but it looks reasonable now. Amazingly, style rules for yacc appear in the original Steve Johnson's paper "Yacc: yet Another Compiler-Compiler", contributed by Brian Kernighan, no less. The paper was part of the 7th edition Unix Programmer's Manual, Volume 2, Supplementary Documents (PSD), which is available in PDF format at <http://www.cs.bell-labs.com/7thEdMan/v7vol2b.pdf>. "Input Style It is difficult to provide rules with substantial actions and still have a readable specification file. The following style hints owe much to Brian Kernighan. a. Use all capital letters for token names, all lower case letters for nonterminal names. This rule comes under the heading of ``knowing who to blame when things go wrong.'' b. Put grammar rules and actions on separate lines. This allows either to be changed without an automatic need to change the other. c. Put all rules with the same left hand side together. Put the left hand side in only once, and let all following rules begin with a vertical bar. d. Put a semicolon only after the last rule with a given left hand side, and put the semicolon on a separate line. This allows new rules to be easily added. e. Indent rule bodies by two tab stops, and action bodies by three tab stops. " Diomidis - dds@
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F5B42F4.D854AA26>