14 #define TK_NameSep 197
16 #define TK_PlusPlus 212
17 #define TK_MinusMinus 213
18 #define TK_ArrowStar 214
19 #define TK_DotStar 215
20 #define TK_ShiftLeft 216
21 #define TK_ShiftRight 217
22 #define TK_IntegerDecimal 218
23 #define TK_IntegerOctal 219
24 #define TK_IntegerHex 220
25 #define TK_EqualsEquals 223
26 #define TK_NotEquals 224
29 #define TK_MultAssign 227
30 #define TK_DivAssign 228
31 #define TK_PercentAssign 229
32 #define TK_PlusAssign 230
33 #define TK_MinusAssign 231
34 #define TK_AmpAssign 232
35 #define TK_CaretAssign 233
36 #define TK_BarAssign 234
37 #define TK_DotDotDot 240
39 /* A growable buffer for collecting headers. */
42 Buffer() : data(0), allocated(0), length(0) { }
43 Buffer( const Buffer &other ) {
44 data = (char*)malloc( other.allocated );
45 memcpy( data, other.data, other.length );
46 allocated = other.allocated;
47 length = other.length;
49 ~Buffer() { empty(); }
51 void append( char p ) {
52 if ( ++length > allocated )
53 upAllocate( length*2 );
56 void append( char *str, int len ) {
57 if ( (length += len) > allocated )
58 upAllocate( length*2 );
59 memcpy( data+length-len, str, len );
62 void clear() { length = 0; }
63 void upAllocate( int len );
74 Scanner( std::ostream &out )
86 void pass(char c) { nonTokBuf.append(c); }
87 void buf(char c) { tokBuf.append(c); }
92 // Initialize the machine. Invokes any init statement blocks. Returns 0
93 // if the machine begins in a non-accepting state and 1 if the machine
94 // begins in an accepting state.
97 // Execute the machine on a block of data. Returns -1 if after processing
98 // the data, the machine is in the error state and can never accept, 0 if
99 // the machine is in a non-accepting state and 1 if the machine is in an
101 int execute( char *data, int len );
103 // Indicate that there is no more data. Returns -1 if the machine finishes
104 // in the error state and does not accept, 0 if the machine finishes
105 // in any other non-accepting state and 1 if the machine finishes in an