43 if (outputstream) fprintf(outputstream,
"\\\n");
45 else {ungetc(c,inputstream); c=
'\\';}
53 while ((c=fgetc(inputstream)) !=
']' && lc!=
']') lc=c;
57 {ungetc(c,inputstream); c=
'[';}
63 if (outputstream &&!feof(inputstream))
64 fputc(c,outputstream);
69 string token, lasttoken;
71 {inputstream=in; outputstream=out; getnextc(); lineno=1;}
73 int line()
const {
return lineno;}
77 void operator=(mark_t& x);
78 int operator>(mark_t& x);
84 token.swap(lasttoken);
88 if (feof(inputstream))
throw eof();
91 while (isspace(c)) getnextc();
94 while (c!=
'\n' && !feof(inputstream))
96 if (c!=
'\r') token+=c;
97 if (c==
'/' && getnextc()==
'*')
98 for (
char l=getnextc(); l!=
'*' || c!=
'/'; l=c, getnextc());
101 if (token.find(
"#pragma")==0)
105 while (isspace(c)) getnextc();
107 if (feof(inputstream))
throw eof();
109 if (c==
'"' || c==
'\'')
116 escape=c==
'\\' && !escape;
119 while (c!=terminal || escape);
123 else if (strchr(
"#\\!@$~(){}[]:;,.?%*|-+=<>^&/",c))
131 if (c==
'=' && !strchr(
"#\\!@$~(){}[]:;,.?",lc))
139 case '<':
case '>':
case '|':
case '&':
140 case '+':
case '-':
case ':':
145 if ((lc==
'<' || lc==
'>') && c==
'=')
151 else if (lc==
'-' && c==
'>')
186 while (lc!=
'*' || c!=
'/')
196 while (c!=
'\n') getnextc();
202 else if (!isalnum(c) && c!=
'_')
209 while (isalnum(c) || c==
'_')
221 friend void tokeninput::operator=(
mark_t& x);
222 friend int tokeninput::operator>(
mark_t& x);
231 fgetpos(x.inputstream,&fp);
233 offset=ftell(x.inputstream);
237 void tokeninput::operator=(
mark_t& x)
241 if (fseek(inputstream,x.offset,SEEK_SET))
throw eof();
243 if (fsetpos(inputstream,&(x.fp)))
throw eof();
247 int tokeninput::operator>(mark_t& x)
248 {
return ftell(inputstream) > x.offset;}
252 inline int isalpha(
char x)
253 {
return x==
'_' || (x>=
'a' && x<='z') || (x>=
'A' && x<=
'Z');}
257 template <
class K,
class T>
class hash_map:
public map<K,T> {};
258 template <
class K>
class hash_set:
public set<K> {};
261 string gobble_delimited(
tokeninput& input,
const char *left,
263 {
string argList = input.lasttoken;
264 argList +=
" " + input.token +
" ";
266 string tmp=(string)left+right;
267 if (input.token==tmp)
return argList;
268 for (input.nexttok(); input.token!=right || delim_count>0;
271 argList += input.token +
" ";
272 if (input.token==left) delim_count++;
273 if (input.token==right) delim_count--;
274 if (input.token==
">>" &&
string(left)==
"<")
277 if (delim_count<=0)
break;
287 size_t angle_count=0;
291 if (input.token[0]==
'=')
292 while (!strchr(
">,",input.token[0]))
294 if (input.token[0]==
'<') gobble_delimited(input,
"<",
">");
297 targs += input.token;
298 if (input.token!=
".") targs+=
" ";
299 if (input.token[0]==
'<') angle_count+=input.token.length();
300 else if (input.token[0]==
'>')
301 angle_count-=input.token.length();
304 while (angle_count>0);
Definition: tokeninput.h:257
Definition: tokeninput.h:258