xref: /openbsd/usr.bin/rpcgen/rpc_scan.h (revision fe7ac6f2)
1 /*	$OpenBSD: rpc_scan.h,v 1.7 2017/01/21 08:33:07 krw Exp $	*/
2 /*	$NetBSD: rpc_scan.h,v 1.3 1995/06/11 21:50:04 pk Exp $	*/
3 
4 /*
5  * Copyright (c) 2010, Oracle America, Inc.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above
14  *       copyright notice, this list of conditions and the following
15  *       disclaimer in the documentation and/or other materials
16  *       provided with the distribution.
17  *     * Neither the name of the "Oracle America, Inc." nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /*      @(#)rpc_scan.h  1.3  90/08/29  (C) 1987 SMI   */
36 
37 /*
38  * rpc_scan.h, Definitions for the RPCL scanner
39  */
40 
41 /*
42  * kinds of tokens
43  */
44 enum tok_kind {
45 	TOK_IDENT,
46 	TOK_CHARCONST,
47 	TOK_STRCONST,
48 	TOK_LPAREN,
49 	TOK_RPAREN,
50 	TOK_LBRACE,
51 	TOK_RBRACE,
52 	TOK_LBRACKET,
53 	TOK_RBRACKET,
54 	TOK_LANGLE,
55 	TOK_RANGLE,
56 	TOK_STAR,
57 	TOK_COMMA,
58 	TOK_EQUAL,
59 	TOK_COLON,
60 	TOK_SEMICOLON,
61 	TOK_CONST,
62 	TOK_STRUCT,
63 	TOK_UNION,
64 	TOK_SWITCH,
65 	TOK_CASE,
66 	TOK_DEFAULT,
67 	TOK_ENUM,
68 	TOK_TYPEDEF,
69 	TOK_INT,
70 	TOK_SHORT,
71 	TOK_LONG,
72 	TOK_HYPER,
73 	TOK_UNSIGNED,
74 	TOK_FLOAT,
75 	TOK_DOUBLE,
76 	TOK_QUAD,
77 	TOK_OPAQUE,
78 	TOK_CHAR,
79 	TOK_STRING,
80 	TOK_BOOL,
81 	TOK_VOID,
82 	TOK_PROGRAM,
83 	TOK_VERSION,
84 	TOK_EOF
85 };
86 typedef enum tok_kind tok_kind;
87 
88 /*
89  * a token
90  */
91 struct token {
92 	tok_kind kind;
93 	char *str;
94 };
95 typedef struct token token;
96 
97 
98 /*
99  * routine interface
100  */
101 void scan(tok_kind, token *);
102 void scan2(tok_kind, tok_kind, token *);
103 void scan3(tok_kind, tok_kind, tok_kind, token *);
104 void scan_num(token *);
105 void peek(token *);
106 int peekscan(tok_kind, token *);
107 void get_token(token *);
108 void reinitialize(void);
109 
110 void expected1(tok_kind);
111 void expected2(tok_kind, tok_kind);
112 void expected3(tok_kind, tok_kind, tok_kind);
113