/*-1* SPDX-License-Identifier: MIT-CMU2*3* Mach Operating System4* Copyright (c) 1991,1990 Carnegie Mellon University5* All Rights Reserved.6*7* Permission to use, copy, modify and distribute this software and its8* documentation is hereby granted, provided that both the copyright9* notice and this permission notice appear in all copies of the10* software, derivative works or modified versions, and any portions11* thereof, and that both notices appear in supporting documentation.12*13* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS14* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR15* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.16*17* Carnegie Mellon requests users of this software to return to18*19* Software Distribution Coordinator or [email protected]20* School of Computer Science21* Carnegie Mellon University22* Pittsburgh PA 15213-389023*24* any improvements or extensions that they make and grant Carnegie the25* rights to redistribute these changes.26*/2728#ifndef _DDB_DB_LEX_H_29#define _DDB_DB_LEX_H_3031/*32* Author: David B. Golub, Carnegie Mellon University33* Date: 7/9034*/35/*36* Lexical analyzer.37*/3839/*40* Options and flags can configure db_read_token() => db_lex() behavior.41*42* When a radix other than DRT_DEFAULT_RADIX is used, it overrides43* auto-detection, as well as the user-specified db_radix, in db_lex() of44* 'tNUMBER' tokens.45*/46enum {47/* Infer or use db_radix using the old logic. */48DRT_DEFAULT_RADIX = 0,49/* The following set an explicit base for tNUMBER lex. */50DRT_OCTAL,51DRT_DECIMAL,52DRT_HEXADECIMAL,53};54#define DRT_RADIX_MASK 0x355/*56* Flag bit powers of two for db_read_token_flags.57* The low 2 bits are reserved for radix selection.58*59* WSPACE: Yield explicit tWSPACE tokens when one or more whitespace characters60* is consumed.61* HEX: Allow tNUMBER tokens to start with 'A'-'F' without explicit "0x"62* prefix.63*/64enum {65_DRT_WSPACE = 2,66_DRT_HEX,67};68#ifndef BIT69#define BIT(n) (1ull << (n))70#endif71enum {72DRT_WSPACE = BIT(_DRT_WSPACE),73DRT_HEX = BIT(_DRT_HEX),74};75#define DRT_VALID_FLAGS_MASK ((int)DRT_RADIX_MASK | \76DRT_WSPACE | \77DRT_HEX)7879void db_flush_lex(void);80char *db_get_line(void);81void db_inject_line(const char *command);82int db_read_line(void);83int db_read_token_flags(int);84void db_unread_token(int t);8586static inline int87db_read_token(void)88{89return (db_read_token_flags(0));90}9192extern db_expr_t db_tok_number;93#define TOK_STRING_SIZE 12094extern char db_tok_string[TOK_STRING_SIZE];9596#define tEOF (-1)97#define tEOL 198#define tNUMBER 299#define tIDENT 3100#define tPLUS 4101#define tMINUS 5102#define tDOT 6103#define tSTAR 7104#define tSLASH 8105#define tEQ 9106#define tLPAREN 10107#define tRPAREN 11108#define tPCT 12109#define tHASH 13110#define tCOMMA 14111#define tDITTO 15112#define tDOLLAR 16113#define tEXCL 17114#define tSHIFT_L 18115#define tSHIFT_R 19116#define tDOTDOT 20117#define tSEMI 21118#define tLOG_EQ 22119#define tLOG_NOT_EQ 23120#define tLESS 24121#define tLESS_EQ 25122#define tGREATER 26123#define tGREATER_EQ 27124#define tBIT_AND 28125#define tBIT_OR 29126#define tLOG_AND 30127#define tLOG_OR 31128#define tSTRING 32129#define tQUESTION 33130#define tBIT_NOT 34131#define tWSPACE 35132#define tCOLON 36133#define tCOLONCOLON 37134135#endif /* !_DDB_DB_LEX_H_ */136137138