44typedef std::list<std::string>
sl_t;
59 return (
c !=
'{') && (
c !=
'}') && (
c !=
'(') && (
c !=
')') &&
67 if( !isclass(
str[
i] ) )
return false;
83 bool (*mf)(
string ) ) {
84 if( tok.
size() < 1 )
return "";
85 if( mf(tok) && !mf(la) )
return tok;
else return "";
97 if( ((tok.
size() && tok[0] ==
q) ||
98 ((tok.
size() > 2) && tok[0] ==
'L' && tok[1] ==
q)) &&
100 if( (tok.
rfind(
"\\") != (tok.
size() - 2)) ||
111 string curtok, la,
op,
ident, qconst;
119 if( (!curtok.
size() ||
120 (curtok[0] !=
'\'' && curtok[0] !=
'\"')) &&
121 (curtok.
size() <= 2 ||
123 (curtok[1] !=
'\'' && curtok[1] !=
'\"')) &&
125 if( curtok.
size() )
out.push_back( curtok );
132 la = curtok +
line[
i+1];
142 if( la !=
"L\"" && la !=
"L\'" ) {
155 out.push_back( qconst
MAYBE(+
"q") );
163 out.push_back( qconst
MAYBE(+
"Q") );
175 int seen_slash =
false;
177 while( (ch = is.
get()) != -1 ) {
182 }
while( ch != -1 && ch !=
'\n' && ch !=
'\r' );
184 }
else if( ch ==
'*' ) {
190 }
while( ch !=
'/' );
197 if( ch ==
'/' ) seen_slash =
true;
198 else if( ch ==
'\r' || ch ==
'\n' )
break;
216 if(
line[0] ==
'#' ) {
217 tok.push_back(
line );
218 while(
line[
line.size()-1] ==
'\\' ) {
220 tok.push_back(
line );
221 tok.push_back(
"\n" );
223 tok.push_back(
"\n" );
226 tok.splice( tok.end(), new_tokens );
227 tok.push_back(
"\n" );
241 if( *
i == start_ch )
bc++;
242 if( *
i == end_ch )
bc--;
267 if( (*
i)[0] ==
'#' ) {
269 cerr <<
"*standard-input*:" <<
line <<
": " <<
l;
289 sl_t pseh_clause, temp_tok;
290 string finally_name, filter_name;
291 sl_it try_block, try_block_end, except_kw, paren, end_paren,
292 except_block, except_block_end, todelete,
293 finally_kw, finally_block, finally_block_end, clause_end;
299 if( try_block_end ==
end )
302 except_kw = try_block_end;
305 finally_kw = except_kw;
310 except_block_end =
end;
314 if( *paren ==
"(" ) {
316 except_block = end_paren;
318 except_block = paren;
323 finally_kw = except_block_end;
325 except_kw = paren = end_paren = except_block = except_block_end =
326 finally_kw = finally_block = finally_block_end =
end;
332 finally_block_end =
end;
334 finally_block = finally_kw;
339 if( finally_block_end !=
end ) clause_end = finally_block_end;
340 else if( except_block_end !=
end ) clause_end = except_block_end;
341 else clause_end = try_block_end;
348 finally_name =
makename(
"_Finally");
351 pseh_clause.push_back(
"_SEH_FINALLY" );
352 pseh_clause.push_back(
"(" );
353 pseh_clause.push_back( finally_name );
354 pseh_clause.push_back(
")" );
355 if( finally_kw !=
end )
356 append_block( pseh_clause, finally_block, finally_block_end );
358 pseh_clause.push_back(
"{" );
359 pseh_clause.push_back(
"}" );
362 pseh_clause.push_back(
"_SEH_FILTER" );
363 pseh_clause.push_back(
"(" );
364 pseh_clause.push_back( filter_name );
365 pseh_clause.push_back(
")" );
366 pseh_clause.push_back(
"{" );
367 pseh_clause.push_back(
"return" );
371 pseh_clause.push_back(
"EXCEPTION_EXECUTE_HANDLER" );
372 pseh_clause.push_back(
";" );
373 pseh_clause.push_back(
"}" );
375 pseh_clause.push_back(
"_SEH_TRY_FILTER_FINALLY" );
376 pseh_clause.push_back(
"(" );
377 pseh_clause.push_back( filter_name );
378 pseh_clause.push_back(
"," );
379 pseh_clause.push_back( finally_name );
380 pseh_clause.push_back(
")" );
382 pseh_clause.push_back(
"_SEH_HANDLE" );
383 pseh_clause.push_back(
"{" );
384 if( except_block !=
end )
385 append_block( pseh_clause, except_block, except_block_end );
386 pseh_clause.push_back(
"}" );
387 pseh_clause.push_back(
"_SEH_END" );
388 pseh_clause.push_back(
";" );
391 while( try_kw != clause_end ) {
400 if( *
i ==
"\n" )
cout << *
i;
401 else cout << *
i <<
" ";
410 if(
string(
argv[
i]) ==
"-try" &&
i <
argc - 1 ) {
413 }
else if(
string(
argv[
i]) ==
"-except" &&
i <
argc - 1 ) {
416 }
else if(
string(
argv[
i]) ==
"-finally" &&
i <
argc - 1 ) {
425 while( (try_found =
find( tok.begin(), tok.end(),
TRY_TOKEN )) !=
430 tok.push_front(
"#include <pseh/framebased.h>\n");
const _CharT * c_str() const
size_type rfind(const _Self &__s, size_type __pos=npos) const
void push_back(_CharT __c)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLdouble GLdouble GLdouble GLdouble q
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define sprintf(buf, format,...)
string match_ident(string tok, string la)
std::list< std::string > sl_t
string generic_match(string tok, string la, bool(*mf)(string))
string match_quoted_const(string tok, string la, char q)
istream & getline_no_comments(istream &is, string &line)
sl_it complete_block(sl_it i, sl_it end, string start_ch, string end_ch)
bool areinclass(string str, int(*isclass)(int))
void append_block(sl_t &t, sl_it b, sl_it e)
string match_operator(string tok, string la)
void handle_try(sl_t &container, sl_it try_kw, sl_it end)
void print_tokens(sl_it begin, sl_it end)
bool expand_input(sl_t &tok)
sl_t snarf_tokens(string line)
string makename(string intro)
_In_ ULONG _In_ ULONG_PTR ident