FreeBSD/Linux Kernel Cross Reference
sys/ddb/db_lex.h
1 /*-
2 * SPDX-License-Identifier: MIT-CMU
3 *
4 * Mach Operating System
5 * Copyright (c) 1991,1990 Carnegie Mellon University
6 * All Rights Reserved.
7 *
8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
27 *
28 * $FreeBSD$
29 */
30
31 #ifndef _DDB_DB_LEX_H_
32 #define _DDB_DB_LEX_H_
33
34 /*
35 * Author: David B. Golub, Carnegie Mellon University
36 * Date: 7/90
37 */
38 /*
39 * Lexical analyzer.
40 */
41
42 /*
43 * Options and flags can configure db_read_token() => db_lex() behavior.
44 *
45 * When a radix other than DRT_DEFAULT_RADIX is used, it overrides
46 * auto-detection, as well as the user-specified db_radix, in db_lex() of
47 * 'tNUMBER' tokens.
48 */
49 enum {
50 /* Infer or use db_radix using the old logic. */
51 DRT_DEFAULT_RADIX = 0,
52 /* The following set an explicit base for tNUMBER lex. */
53 DRT_OCTAL,
54 DRT_DECIMAL,
55 DRT_HEXADECIMAL,
56 };
57 #define DRT_RADIX_MASK 0x3
58 /*
59 * Flag bit powers of two for db_read_token_flags.
60 * The low 2 bits are reserved for radix selection.
61 *
62 * WSPACE: Yield explicit tWSPACE tokens when one or more whitespace characters
63 * is consumed.
64 * HEX: Allow tNUMBER tokens to start with 'A'-'F' without explicit "0x"
65 * prefix.
66 */
67 enum {
68 _DRT_WSPACE = 2,
69 _DRT_HEX,
70 };
71 #ifndef BIT
72 #define BIT(n) (1ull << (n))
73 #endif
74 enum {
75 DRT_WSPACE = BIT(_DRT_WSPACE),
76 DRT_HEX = BIT(_DRT_HEX),
77 };
78 #define DRT_VALID_FLAGS_MASK ((int)DRT_RADIX_MASK | \
79 DRT_WSPACE | \
80 DRT_HEX)
81
82 void db_flush_lex(void);
83 char *db_get_line(void);
84 void db_inject_line(const char *command);
85 int db_read_line(void);
86 int db_read_token_flags(int);
87 void db_unread_token(int t);
88
89 static inline int
90 db_read_token(void)
91 {
92 return (db_read_token_flags(0));
93 }
94
95 extern db_expr_t db_tok_number;
96 #define TOK_STRING_SIZE 120
97 extern char db_tok_string[TOK_STRING_SIZE];
98
99 #define tEOF (-1)
100 #define tEOL 1
101 #define tNUMBER 2
102 #define tIDENT 3
103 #define tPLUS 4
104 #define tMINUS 5
105 #define tDOT 6
106 #define tSTAR 7
107 #define tSLASH 8
108 #define tEQ 9
109 #define tLPAREN 10
110 #define tRPAREN 11
111 #define tPCT 12
112 #define tHASH 13
113 #define tCOMMA 14
114 #define tDITTO 15
115 #define tDOLLAR 16
116 #define tEXCL 17
117 #define tSHIFT_L 18
118 #define tSHIFT_R 19
119 #define tDOTDOT 20
120 #define tSEMI 21
121 #define tLOG_EQ 22
122 #define tLOG_NOT_EQ 23
123 #define tLESS 24
124 #define tLESS_EQ 25
125 #define tGREATER 26
126 #define tGREATER_EQ 27
127 #define tBIT_AND 28
128 #define tBIT_OR 29
129 #define tLOG_AND 30
130 #define tLOG_OR 31
131 #define tSTRING 32
132 #define tQUESTION 33
133 #define tBIT_NOT 34
134 #define tWSPACE 35
135 #define tCOLON 36
136 #define tCOLONCOLON 37
137
138 #endif /* !_DDB_DB_LEX_H_ */
Cache object: 9c4da0343d65058c47b9297d61f76926
|