Expand PMF_FN_* macros.
[netbsd-mini2440.git] / bin / sh / syntax.c
blob01cb075a5c7b696e5b6c281e2d35c9dfe0a22538
1 /* $NetBSD: syntax.c,v 1.1 2004/01/17 17:38:12 dsl Exp $ */
3 #include <sys/cdefs.h>
4 __RCSID("$NetBSD$");
6 #include "shell.h"
7 #include "syntax.h"
8 #include "parser.h"
10 #if CWORD != 0
11 #error initialisation assumes 'CWORD' is zero
12 #endif
14 #define ndx(ch) (ch + 1 - CHAR_MIN)
15 #define set(ch, val) [ndx(ch)] = val,
16 #define set_range(s, e, val) [ndx(s) ... ndx(e)] = val,
18 /* syntax table used when not in quotes */
19 const char basesyntax[257] = { CEOF,
20 set_range(CTL_FIRST, CTL_LAST, CCTL)
21 set('\n', CNL)
22 set('\\', CBACK)
23 set('\'', CSQUOTE)
24 set('"', CDQUOTE)
25 set('`', CBQUOTE)
26 set('$', CVAR)
27 set('}', CENDVAR)
28 set('<', CSPCL)
29 set('>', CSPCL)
30 set('(', CSPCL)
31 set(')', CSPCL)
32 set(';', CSPCL)
33 set('&', CSPCL)
34 set('|', CSPCL)
35 set(' ', CSPCL)
36 set('\t', CSPCL)
39 /* syntax table used when in double quotes */
40 const char dqsyntax[257] = { CEOF,
41 set_range(CTL_FIRST, CTL_LAST, CCTL)
42 set('\n', CNL)
43 set('\\', CBACK)
44 set('"', CDQUOTE)
45 set('`', CBQUOTE)
46 set('$', CVAR)
47 set('}', CENDVAR)
48 /* ':/' for tilde expansion, '-' for [a\-x] pattern ranges */
49 set('!', CCTL)
50 set('*', CCTL)
51 set('?', CCTL)
52 set('[', CCTL)
53 set('=', CCTL)
54 set('~', CCTL)
55 set(':', CCTL)
56 set('/', CCTL)
57 set('-', CCTL)
60 /* syntax table used when in single quotes */
61 const char sqsyntax[257] = { CEOF,
62 set_range(CTL_FIRST, CTL_LAST, CCTL)
63 set('\n', CNL)
64 set('\'', CSQUOTE)
65 /* ':/' for tilde expansion, '-' for [a\-x] pattern ranges */
66 set('!', CCTL)
67 set('*', CCTL)
68 set('?', CCTL)
69 set('[', CCTL)
70 set('=', CCTL)
71 set('~', CCTL)
72 set(':', CCTL)
73 set('/', CCTL)
74 set('-', CCTL)
77 /* syntax table used when in arithmetic */
78 const char arisyntax[257] = { CEOF,
79 set_range(CTL_FIRST, CTL_LAST, CCTL)
80 set('\n', CNL)
81 set('\\', CBACK)
82 set('`', CBQUOTE)
83 set('\'', CSQUOTE)
84 set('"', CDQUOTE)
85 set('$', CVAR)
86 set('}', CENDVAR)
87 set('(', CLP)
88 set(')', CRP)
91 /* character classification table */
92 const char is_type[257] = { 0,
93 set_range('0', '9', ISDIGIT)
94 set_range('a', 'z', ISLOWER)
95 set_range('A', 'Z', ISUPPER)
96 set('_', ISUNDER)
97 set('#', ISSPECL)
98 set('?', ISSPECL)
99 set('$', ISSPECL)
100 set('!', ISSPECL)
101 set('-', ISSPECL)
102 set('*', ISSPECL)
103 set('@', ISSPECL)