VirtualBox

source: kBuild/trunk/src/ash/syntax.h@ 1158

Last change on this file since 1158 was 809, checked in by bird, 18 years ago

Solaris + cleanup.

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/* $NetBSD: syntax.h,v 1.2 2004/01/17 17:38:12 dsl Exp $ */
2
3/*-
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Kenneth Almquist.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#ifdef HAVE_SYS_CDEFS_H
36#include <sys/cdefs.h>
37#endif
38#include <ctype.h>
39
40/* Syntax classes */
41#define CWORD 0 /* character is nothing special */
42#define CNL 1 /* newline character */
43#define CBACK 2 /* a backslash character */
44#define CSQUOTE 3 /* single quote */
45#define CDQUOTE 4 /* double quote */
46#define CBQUOTE 5 /* backwards single quote */
47#define CVAR 6 /* a dollar sign */
48#define CENDVAR 7 /* a '}' character */
49#define CLP 8 /* a left paren in arithmetic */
50#define CRP 9 /* a right paren in arithmetic */
51#define CEOF 10 /* end of file */
52#define CCTL 11 /* like CWORD, except it must be escaped */
53#define CSPCL 12 /* these terminate a word */
54
55/* Syntax classes for is_ functions */
56#define ISDIGIT 01 /* a digit */
57#define ISUPPER 02 /* an upper case letter */
58#define ISLOWER 04 /* a lower case letter */
59#define ISUNDER 010 /* an underscore */
60#define ISSPECL 020 /* the name of a special parameter */
61
62#define PEOF (CHAR_MIN - 1)
63#define SYNBASE (-PEOF)
64/* XXX UPEOF is CHAR_MAX, so is a valid 'char' value... */
65#define UPEOF ((char)PEOF)
66
67
68#define BASESYNTAX (basesyntax + SYNBASE)
69#define DQSYNTAX (dqsyntax + SYNBASE)
70#define SQSYNTAX (sqsyntax + SYNBASE)
71#define ARISYNTAX (arisyntax + SYNBASE)
72
73/* These defines assume that the digits are contiguous */
74#define is_digit(c) ((unsigned)((c) - '0') <= 9)
75#define is_alpha(c) (((char)(c)) != UPEOF && ((c) < CTL_FIRST || (c) > CTL_LAST) && isalpha((unsigned char)(c)))
76#define is_name(c) (((char)(c)) != UPEOF && ((c) < CTL_FIRST || (c) > CTL_LAST) && ((c) == '_' || isalpha((unsigned char)(c))))
77#define is_in_name(c) (((char)(c)) != UPEOF && ((c) < CTL_FIRST || (c) > CTL_LAST) && ((c) == '_' || isalnum((unsigned char)(c))))
78#define is_special(c) ((is_type+SYNBASE)[c] & (ISSPECL|ISDIGIT))
79#define digit_val(c) ((c) - '0')
80
81#ifdef _MSC_VER
82extern char basesyntax[];
83extern char dqsyntax[];
84extern char sqsyntax[];
85extern char arisyntax[];
86extern char is_type[];
87#else
88extern const char basesyntax[];
89extern const char dqsyntax[];
90extern const char sqsyntax[];
91extern const char arisyntax[];
92extern const char is_type[];
93#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette