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