1 /* $NetBSD: syntax.c,v 1.1 2004/01/17 17:38:12 dsl Exp $ */
5 #include <iso/limits_iso.h>
12 #ifdef _MSC_VER /* doesn't implement the fancy initializers I think... */
14 char basesyntax
[257] = {CEOF
};
15 char dqsyntax
[257] = {CEOF
};
16 char sqsyntax
[257] = {CEOF
};
17 char arisyntax
[257] = {CEOF
};
18 char is_type
[257] = {0};
20 void init_syntax(void)
25 #define ndx(ch) (ch + 1 - CHAR_MIN)
26 #define set(ch, val) tab[ndx(ch)] = val
27 #define set_range(s, e, val) for (i = ndx(s); i <= ndx(e); i++) tab[i] = val
31 set_range(CTL_FIRST
, CTL_LAST
, CCTL
);
50 set_range(CTL_FIRST
, CTL_LAST
, CCTL
);
57 /* ':/' for tilde expansion, '-' for [a\-x] pattern ranges */
69 set_range(CTL_FIRST
, CTL_LAST
, CCTL
);
72 /* ':/' for tilde expansion, '-' for [a\-x] pattern ranges */
84 set_range(CTL_FIRST
, CTL_LAST
, CCTL
);
96 set_range('0', '9', ISDIGIT
);
97 set_range('a', 'z', ISLOWER
);
98 set_range('A', 'Z', ISUPPER
);
109 #else /* !_MSC_VER */
112 #error initialisation assumes 'CWORD' is zero
115 #define ndx(ch) (ch + 1 - CHAR_MIN)
116 #define set(ch, val) [ndx(ch)] = val,
117 #define set_range(s, e, val) [ndx(s) ... ndx(e)] = val,
119 /* syntax table used when not in quotes */
120 const char basesyntax
[257] = { CEOF
,
121 set_range(CTL_FIRST
, CTL_LAST
, CCTL
)
140 /* syntax table used when in double quotes */
141 const char dqsyntax
[257] = { CEOF
,
142 set_range(CTL_FIRST
, CTL_LAST
, CCTL
)
149 /* ':/' for tilde expansion, '-' for [a\-x] pattern ranges */
161 /* syntax table used when in single quotes */
162 const char sqsyntax
[257] = { CEOF
,
163 set_range(CTL_FIRST
, CTL_LAST
, CCTL
)
166 /* ':/' for tilde expansion, '-' for [a\-x] pattern ranges */
178 /* syntax table used when in arithmetic */
179 const char arisyntax
[257] = { CEOF
,
180 set_range(CTL_FIRST
, CTL_LAST
, CCTL
)
192 /* character classification table */
193 const char is_type
[257] = { 0,
194 set_range('0', '9', ISDIGIT
)
195 set_range('a', 'z', ISLOWER
)
196 set_range('A', 'Z', ISUPPER
)
206 #endif /* !_MSC_VER */