3
* This file contains code to be included in the scanner file using a
4
* generated trie-based FA.
10
static long CharMask[28] = {
11
0x0000001, 0x0000000, 0x0000004, 0x0000008,
12
0x0000010, 0x0000020, 0x0000040, 0x0000080,
13
0x0000100, 0x0000200, 0x0000400, 0x0000800,
14
0x0001000, 0x0002000, 0x0004000, 0x0008000,
15
0x0010000, 0x0020000, 0x0040000, 0x0080000,
16
0x0100000, 0x0200000, 0x0400000, 0x0800000,
17
0x1000000, 0x2000000, 0x4000000, 0x8000000,
20
#define IN_MASK_RANGE(C) (islower (C) || ((C) == '_'))
21
#define MASK_INDEX(C) ((C) - '_')
24
static long CharMask[26] = {
25
0x0000001, 0x0000002, 0x0000004, 0x0000008,
26
0x0000010, 0x0000020, 0x0000040, 0x0000080,
27
0x0000100, 0x0000200, 0x0000400, 0x0000800,
28
0x0001000, 0x0002000, 0x0004000, 0x0008000,
29
0x0010000, 0x0020000, 0x0040000, 0x0080000,
30
0x0100000, 0x0200000, 0x0400000, 0x0800000,
34
#define IN_MASK_RANGE(C) islower (C)
35
#define MASK_INDEX(C) ((C) - 'a')
39
static short TFA_State;
43
* Initialize the trie FA.
45
#define TFA_Init() TFA_State = 0
49
* Advance to the next state (or -1) on the lowercase letter c.
50
* This should be an inline routine, but the C++ implementation
51
* isn't advanced enough so we use a macro.
53
#define TFA_Advance(C) { \
55
if (TFA_State >= 0) { \
58
else if (! IN_MASK_RANGE (c)) { \
62
if (TrieStateTbl[TFA_State].mask & CharMask[MASK_INDEX (c)]) { \
63
short i = TrieStateTbl[TFA_State].trans_base; \
64
while (TrieTransTbl[i].c != c) \
66
TFA_State = TrieTransTbl[i].next_state; \
72
} /* end of TFA_Advance. */
76
* Return the definition (if any) associated with the current state.
78
#define TFA_Definition() \
79
((TFA_State < 0) ? -1 : TrieStateTbl[TFA_State].def)