| 1 | /* syntax.h -- Syntax definitions for the shell */
|
|---|
| 2 |
|
|---|
| 3 | /* Copyright (C) 2000 Free Software Foundation, Inc.
|
|---|
| 4 |
|
|---|
| 5 | This file is part of GNU Bash, the Bourne Again SHell.
|
|---|
| 6 |
|
|---|
| 7 | Bash is free software; you can redistribute it and/or modify it under
|
|---|
| 8 | the terms of the GNU General Public License as published by the Free
|
|---|
| 9 | Software Foundation; either version 2, or (at your option) any later
|
|---|
| 10 | version.
|
|---|
| 11 |
|
|---|
| 12 | Bash is distributed in the hope that it will be useful, but WITHOUT ANY
|
|---|
| 13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|---|
| 14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|---|
| 15 | for more details.
|
|---|
| 16 |
|
|---|
| 17 | You should have received a copy of the GNU General Public License along
|
|---|
| 18 | with Bash; see the file COPYING. If not, write to the Free Software
|
|---|
| 19 | Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
|---|
| 20 |
|
|---|
| 21 | #ifndef _SYNTAX_H_
|
|---|
| 22 | #define _SYNTAX_H_
|
|---|
| 23 |
|
|---|
| 24 | /* Defines for use by mksyntax.c */
|
|---|
| 25 |
|
|---|
| 26 | #define slashify_in_quotes "\\`$\"\n"
|
|---|
| 27 | #define slashify_in_here_document "\\`$"
|
|---|
| 28 |
|
|---|
| 29 | #define shell_meta_chars "()<>;&|"
|
|---|
| 30 | #define shell_break_chars "()<>;&| \t\n"
|
|---|
| 31 |
|
|---|
| 32 | #define shell_quote_chars "\"`'"
|
|---|
| 33 |
|
|---|
| 34 | #if defined (PROCESS_SUBSTITUTION)
|
|---|
| 35 | # define shell_exp_chars "$<>"
|
|---|
| 36 | #else
|
|---|
| 37 | # define shell_exp_chars "$"
|
|---|
| 38 | #endif
|
|---|
| 39 |
|
|---|
| 40 | #if defined (EXTENDED_GLOB)
|
|---|
| 41 | # define ext_glob_chars "@*+?!"
|
|---|
| 42 | #else
|
|---|
| 43 | # define ext_glob_chars ""
|
|---|
| 44 | #endif
|
|---|
| 45 | #define shell_glob_chars "*?[]^"
|
|---|
| 46 |
|
|---|
| 47 | /* Defines shared by mksyntax.c and the rest of the shell code. */
|
|---|
| 48 |
|
|---|
| 49 | /* Values for character flags in syntax tables */
|
|---|
| 50 |
|
|---|
| 51 | #define CWORD 0x0000 /* nothing special; an ordinary character */
|
|---|
| 52 | #define CSHMETA 0x0001 /* shell meta character */
|
|---|
| 53 | #define CSHBRK 0x0002 /* shell break character */
|
|---|
| 54 | #define CBACKQ 0x0004 /* back quote */
|
|---|
| 55 | #define CQUOTE 0x0008 /* shell quote character */
|
|---|
| 56 | #define CSPECL 0x0010 /* special character that needs quoting */
|
|---|
| 57 | #define CEXP 0x0020 /* shell expansion character */
|
|---|
| 58 | #define CBSDQUOTE 0x0040 /* characters escaped by backslash in double quotes */
|
|---|
| 59 | #define CBSHDOC 0x0080 /* characters escaped by backslash in here doc */
|
|---|
| 60 | #define CGLOB 0x0100 /* globbing characters */
|
|---|
| 61 | #define CXGLOB 0x0200 /* extended globbing characters */
|
|---|
| 62 | #define CXQUOTE 0x0400 /* cquote + backslash */
|
|---|
| 63 | #define CSPECVAR 0x0800 /* single-character shell variable name */
|
|---|
| 64 | #define CSUBSTOP 0x1000 /* values of OP for ${word[:]OPstuff} */
|
|---|
| 65 |
|
|---|
| 66 | /* Defines for use by the rest of the shell. */
|
|---|
| 67 | extern int sh_syntaxtab[];
|
|---|
| 68 | extern int sh_syntabsiz;
|
|---|
| 69 |
|
|---|
| 70 | #define shellmeta(c) (sh_syntaxtab[(unsigned char)(c)] & CSHMETA)
|
|---|
| 71 | #define shellbreak(c) (sh_syntaxtab[(unsigned char)(c)] & CSHBRK)
|
|---|
| 72 | #define shellquote(c) (sh_syntaxtab[(unsigned char)(c)] & CQUOTE)
|
|---|
| 73 |
|
|---|
| 74 | #define shellxquote(c) (sh_syntaxtab[(unsigned char)(c)] & CXQUOTE)
|
|---|
| 75 |
|
|---|
| 76 | #define issyntype(c, t) ((sh_syntaxtab[(unsigned char)(c)] & (t)) != 0)
|
|---|
| 77 | #define notsyntype(c,t) ((sh_syntaxtab[(unsigned char)(c)] & (t)) == 0)
|
|---|
| 78 |
|
|---|
| 79 | #if defined (PROCESS_SUBSTITUTION)
|
|---|
| 80 | # define shellexp(c) ((c) == '$' || (c) == '<' || (c) == '>')
|
|---|
| 81 | #else
|
|---|
| 82 | # define shellexp(c) ((c) == '$')
|
|---|
| 83 | #endif
|
|---|
| 84 |
|
|---|
| 85 | #if defined (EXTENDED_GLOB)
|
|---|
| 86 | # define PATTERN_CHAR(c) \
|
|---|
| 87 | ((c) == '@' || (c) == '*' || (c) == '+' || (c) == '?' || (c) == '!')
|
|---|
| 88 | #else
|
|---|
| 89 | # define PATTERN_CHAR(c) 0
|
|---|
| 90 | #endif
|
|---|
| 91 |
|
|---|
| 92 | #define GLOB_CHAR(c) \
|
|---|
| 93 | ((c) == '*' || (c) == '?' || (c) == '[' || (c) == ']' || (c) == '^')
|
|---|
| 94 |
|
|---|
| 95 | #define CTLESC '\001'
|
|---|
| 96 | #define CTLNUL '\177'
|
|---|
| 97 |
|
|---|
| 98 | #if !defined (HAVE_ISBLANK) && !defined (isblank)
|
|---|
| 99 | # define isblank(x) ((x) == ' ' || (x) == '\t')
|
|---|
| 100 | #endif
|
|---|
| 101 |
|
|---|
| 102 | #endif /* _SYNTAX_H_ */
|
|---|