/* This generated file is licenced and copyrighted under the same * conditions as the sourcefile. Happy debugging:) */ /* defines: */ #define HOLD unsigned hold___BNF_level = __BNF_level; char *hold___BNF_input = __BNF_input, *hold___BNF_output = __BNF_output #define RESTORE {__BNF_level = hold___BNF_level; __BNF_input = hold___BNF_input; __BNF_output = hold___BNF_output;} #ifdef __TURBOC__ # pragma warn -pro # pragma warn -nod #endif #ifdef _MSC_VER # pragma warning (disable:4013) # pragma warning (disable:4005) #endif /* externals: */ extern char *__BNF_input, *__BNF_output; extern unsigned __BNF_level; extern unsigned int __BNF_tabsize; extern int __BNF_trans_string(char *), __BNF_input_string(char *), __BNF_output_string(char *), __BNF_trans_char(void), __BNF_swap(char *, char *, char *); extern void user_error(char *); /* user provided error handler must TERMINATE */ /**/ /* ---------------------------------------------------------------------*/ /**/ /* GRAMMAR SECTION*/ /**/ /* ---------------------------------------------------------------------*/ /**/ /* ---------------------------------------------------------------------*/ /* ::= [{ | | }] EOF*/ /**/ /**/ int grammar(void) { int state; do { HOLD; state = out_header( ); /* --- Call function --- */ if (state) break; { int firstloop = 1; do { do { HOLD; do { state = assignment( ); /* --- Call function --- */ if (!state) break; state = wc( ); /* --- Call function --- */ } while( 0 ); if (state) break; state = flush( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (firstloop) { if (state) break; firstloop = 0; } } while ( !state ); state = firstloop; } state = 0; if (state) { RESTORE; break; }; do { HOLD; state = __BNF_input_string( "%%" ); /* --- Call function --- */ if (state) break; { int firstloop = 1; do { state = __BNF_trans_char( ); /* --- Call function --- */ if (firstloop) { if (state) break; firstloop = 0; } } while ( !state ); state = firstloop; } state = 0; if (state) { RESTORE; break; }; } while( 0 ); state = 0; if (state) { RESTORE; break; }; do { do { HOLD; state = eoi( ); /* --- Call function --- */ if (state) break; state = out_footer( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; user_error( "Syntax error" ); /* --- Call function --- */ state = 0; } while( 0 ); if (state) { RESTORE; break; }; } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* ::= '#' ~[{ not '\n' }]~ '\n'*/ /**/ /* where the internal routine 'commentchars' does a transparent parse on*/ /* the expression '~[{ not '\n' }]~'.*/ /**/ int comment(void) { int state; do { do { HOLD; state = __BNF_input_string( "##" ); /* --- Call function --- */ if (state) break; state = ignorechars( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = __BNF_input_string( "\n" ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; do { HOLD; state = __BNF_input_string( "#" ); /* --- Call function --- */ if (state) break; state = out_comment_begin( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = commentchars( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = __BNF_input_string( "\n" ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_comment_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* ::= [] ('=' | '::=') ';'*/ /**/ int assignment(void) { int state; do { HOLD; state = out_func_type( ); /* --- Call function --- */ if (state) break; state = name( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; do { state = __BNF_input_string( "=" ); /* --- Call function --- */ if (!state) break; state = __BNF_input_string( "::=" ); /* --- Call function --- */ if (!state) break; user_error( " \'=\' or \'::=\' expected" ); /* --- Call function --- */ state = 0; } while( 0 ); if (state) { RESTORE; break; }; state = out_func_begin( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = expression( ); /* --- Call function --- */ if (state) { RESTORE; break; }; do { do { HOLD; state = __BNF_input_string( ";" ); /* --- Call function --- */ if (state) break; state = inc_rule( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; user_error( "\';\' expected" ); /* --- Call function --- */ state = 0; } while( 0 ); if (state) { RESTORE; break; }; state = out_func_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* ::= term [{ '|' term }]*/ /**/ int expression(void) { int state; do { do { HOLD; state = wc( ); /* --- Call function --- */ state = 0; if (state) break; do { do { HOLD; state = out_or_begin( ); /* --- Call function --- */ if (state) break; state = term( ); /* --- Call function --- */ if (state) { RESTORE; break; }; { int firstloop = 1; do { do { HOLD; state = wc( ); /* --- Call function --- */ state = 0; if (state) break; state = __BNF_input_string( "|" ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = out_or_operator( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = term( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (firstloop) { if (state) break; firstloop = 0; } } while ( !state ); state = firstloop; } if (state) { RESTORE; break; }; state = out_or_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; state = term( ); /* --- Call function --- */ } while( 0 ); if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; user_error( "Expression expected" ); /* --- Call function --- */ state = 0; } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* ::= | | */ /**/ int term(void) { int state; do { state = ordinary_and( ); /* --- Call function --- */ if (!state) break; state = swapped_and( ); /* --- Call function --- */ if (!state) break; state = factor( ); /* --- Call function --- */ } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* ::= factor { wc }*/ /**/ int ordinary_and(void) { int state; do { HOLD; state = out_and_begin( ); /* --- Call function --- */ if (state) break; state = factor( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_and_1( ); /* --- Call function --- */ if (state) { RESTORE; break; }; { int firstloop = 1; do { do { HOLD; state = wc( ); /* --- Call function --- */ if (state) break; state = factor( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_and_2( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (firstloop) { if (state) break; firstloop = 0; } } while ( !state ); state = firstloop; } if (state) { RESTORE; break; }; state = out_and_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* ::= factor { '#' }*/ /**/ int swapped_and(void) { int state; do { HOLD; state = out_swp_begin( ); /* --- Call function --- */ if (state) break; state = factor( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_swp_1( ); /* --- Call function --- */ if (state) { RESTORE; break; }; { int firstloop = 1; do { do { do { HOLD; state = wc( ); /* --- Call function --- */ state = 0; if (state) break; state = __BNF_input_string( "#" ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = out_swp_2( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = factor( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_swp_3( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; do { HOLD; state = wc( ); /* --- Call function --- */ if (state) break; state = factor( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_swp_4( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); } while( 0 ); if (firstloop) { if (state) break; firstloop = 0; } } while ( !state ); state = firstloop; } if (state) { RESTORE; break; }; state = out_swp_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* ::= | ident | '(' expression rparen | option | repetition*/ /**/ /* postfix operators are quite time consuming :(*/ int factor(void) { int state; do { do { HOLD; state = __BNF_input_string( "!" ); /* --- Call function --- */ if (state) break; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = simple_factor( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); /* The 'not' operator.*/ if (!state) break; do { HOLD; state = simple_factor( ); /* --- Call function --- */ if (state) break; do { HOLD; state = wc( ); /* --- Call function --- */ state = 0; if (state) break; do { state = __BNF_input_string( "*" ); /* --- Call function --- */ if (!state) break; state = __BNF_input_string( "+" ); /* --- Call function --- */ } while( 0 ); if (state) { RESTORE; break; }; } while( 0 ); state = 0; if (state) { RESTORE; break; }; } while( 0 ); } while( 0 ); return state;} /* Kleene's '*' and '+'.*/ int simple_factor(void) { int state; do { state = IO( ); /* --- Call function --- */ if (!state) break; state = function( ); /* --- Call function --- */ if (!state) break; state = identifier( ); /* --- Call function --- */ if (!state) break; state = option( ); /* --- Call function --- */ if (!state) break; state = repetition( ); /* --- Call function --- */ if (!state) break; do { HOLD; state = __BNF_input_string( "(" ); /* --- Call function --- */ if (state) break; state = expression( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = rparen( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); } while( 0 ); return state;} /* --------------------------------------------------------------------*/ /* ::= | | | '.' | */ /**/ int IO(void) { int state; do { state = input( ); /* --- Call function --- */ if (!state) break; state = output( ); /* --- Call function --- */ if (!state) break; state = trans( ); /* --- Call function --- */ if (!state) break; do { HOLD; state = __BNF_input_string( "." ); /* --- Call function --- */ if (state) break; state = out_trans_char( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; state = syntax_error( ); /* --- Call function --- */ } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* input ::= ['in' [wc] '(' [wc]] [ [wc] rparen]*/ /**/ int input(void) { int state; do { do { HOLD; state = __BNF_input_string( "in" ); /* --- Call function --- */ if (state) break; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = __BNF_input_string( "(" ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = out_str_begin( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = string( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_str_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = rparen( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; do { HOLD; state = out_str_begin( ); /* --- Call function --- */ if (state) break; state = string( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_str_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* output ::= 'out' [] '(' [] [] rparen*/ /* | '`' [{o_stringchar}] '`'*/ /**/ int output(void) { int state; do { do { HOLD; state = __BNF_input_string( "out" ); /* --- Call function --- */ if (state) break; state = out_out_1_begin( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = __BNF_input_string( "(" ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = string( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = rparen( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_out_1_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; do { HOLD; state = __BNF_input_string( "`" ); /* --- Call function --- */ if (state) break; state = out_out_2_begin( ); /* --- Call function --- */ if (state) { RESTORE; break; }; { int firstloop = 1; do { state = o_stringchar( ); /* --- Call function --- */ if (firstloop) { if (state) break; firstloop = 0; } } while ( !state ); state = firstloop; } state = 0; if (state) { RESTORE; break; }; do { do { HOLD; state = __BNF_input_string( "`" ); /* --- Call function --- */ if (state) break; state = out_out_2_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; user_error( "Unterminated output string" ); /* --- Call function --- */ state = 0; } while( 0 ); if (state) { RESTORE; break; }; } while( 0 ); } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* trans ::= 'trans' [] '(' [] [] rparen*/ /* | '\"' [{t_stringchar}] '\"'*/ /**/ int trans(void) { int state; do { do { HOLD; state = out_tran_1_begin( ); /* --- Call function --- */ if (state) break; state = __BNF_input_string( "trans" ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = __BNF_input_string( "(" ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = string( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = rparen( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_tran_1_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; do { HOLD; state = __BNF_input_string( "\"" ); /* --- Call function --- */ if (state) break; state = out_tran_2_begin( ); /* --- Call function --- */ if (state) { RESTORE; break; }; { int firstloop = 1; do { state = t_stringchar( ); /* --- Call function --- */ if (firstloop) { if (state) break; firstloop = 0; } } while ( !state ); state = firstloop; } state = 0; if (state) { RESTORE; break; }; do { do { HOLD; state = __BNF_input_string( "\"" ); /* --- Call function --- */ if (state) break; state = out_tran_2_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); if (!state) break; user_error( "Unterminated trans string" ); /* --- Call function --- */ state = 0; } while( 0 ); if (state) { RESTORE; break; }; } while( 0 ); } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* syntax_error ::= 'error' [wc] '(' [wc] string [wc] rparen*/ /**/ int syntax_error(void) { int state; do { HOLD; state = __BNF_input_string( "error" ); /* --- Call function --- */ if (state) break; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = __BNF_input_string( "(" ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = out_err_begin( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = string( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = wc( ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; state = rparen( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_err_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* There is NO white allowed between name and '(', or we would*/ /* have a serious problem. still I think that this solution is*/ /* NOT clear, and this should be changed in the future...*/ /**/ int function(void) { int state; do { state = valid_name( ); /* --- Call function --- */ if (!state) break; do { HOLD; state = name( ); /* --- Call function --- */ if (state) break; state = __BNF_input_string( "(" ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = expression( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = rparen( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /* ::= */ /**/ int identifier(void) { int state; do { state = valid_name( ); /* --- Call function --- */ if (!state) break; do { HOLD; state = out_call_begin( ); /* --- Call function --- */ if (state) break; state = name( ); /* --- Call function --- */ if (state) { RESTORE; break; }; state = out_call_end( ); /* --- Call function --- */ if (state) { RESTORE; break; }; } while( 0 ); } while( 0 ); return state;} /* --------------------------------------------------------------------*/ /**/ /**/ int valid_name(void) { int state; do { HOLD; state = __BNF_input_string( "__BNF_" ); /* --- Call function --- */ if (state) break; user_error( "names beginning with \'__BNF_\' are reserved" ); /* --- Call function --- */ state = 0; if (state) { RESTORE; break; }; } while( 0 ); return state;} /* ---------------------------------------------------------------------*/ /*