1 .\" Copyright (C) Caldera International Inc. 2001-2002. All rights reserved.
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions are
7 .\" Redistributions of source code and documentation must retain the above
8 .\" copyright notice, this list of conditions and the following
11 .\" Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
18 .\" This product includes software developed or owned by Caldera
19 .\" International, Inc. Neither the name of Caldera International, Inc.
20 .\" nor the names of other contributors may be used to endorse or promote
21 .\" products derived from this software without specific prior written
24 .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
25 .\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
26 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 .\" DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
29 .\" FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
34 .\" OR OTHERWISE) RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
35 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .\" @(#)ssb 8.1 (Berkeley) 6/8/93
41 Appendix B: Yacc Input Syntax
43 This Appendix has a description of the Yacc input syntax, as a Yacc specification.
44 Context dependencies, etc., are not considered.
45 Ironically, the Yacc input specification language
46 is most naturally specified as an LR(2) grammar; the sticky
47 part comes when an identifier is seen in a rule, immediately
49 If this identifier is followed by a colon, it is the start of the
51 it is a continuation of the current rule, which just happens to have
52 an action embedded in it.
53 As implemented, the lexical analyzer looks
54 ahead after seeing an identifier, and
55 decide whether the next token (skipping blanks, newlines, comments, etc.)
57 If so, it returns the token C_IDENTIFIER.
58 Otherwise, it returns IDENTIFIER.
59 Literals (quoted strings) are also returned as IDENTIFIERS,
60 but never as part of C_IDENTIFIERs.
63 .ta .6i 1.2i 1.8i 2.4i 3i 3.6i
65 /* grammar for the input to Yacc */
68 %token IDENTIFIER /* includes identifiers and literals */
69 %token C_IDENTIFIER /* identifier (but not literal) followed by colon */
70 %token NUMBER /* [0-9]+ */
72 /* reserved words: %type => TYPE, %left => LEFT, etc. */
74 %token LEFT RIGHT NONASSOC TOKEN PREC TYPE START UNION
76 %token MARK /* the %% mark */
77 %token LCURL /* the %{ mark */
78 %token RCURL /* the %} mark */
80 /* ascii character literals stand for themselves */
86 spec : defs MARK rules tail
89 tail : MARK { \fIIn this action, eat up the rest of the file\fR }
90 | /* empty: the second MARK is optional */
97 def : START IDENTIFIER
98 | UNION { \fICopy union definition to output\fR }
99 | LCURL { \fICopy C code to output file\fR } RCURL
100 | ndefs rword tag nlist
110 tag : /* empty: union tag is optional */
111 | \'<\' IDENTIFIER \'>\'
119 nmno : IDENTIFIER /* NOTE: literal illegal with %type */
120 | IDENTIFIER NUMBER /* NOTE: illegal with %type */
125 rules : C_IDENTIFIER rbody prec
129 rule : C_IDENTIFIER rbody prec
138 act : \'{\' { \fICopy action, translate $$, etc.\fR } \'}\'
143 | PREC IDENTIFIER act