From: <bl...@us...> - 2003-08-03 09:24:09
|
Update of /cvsroot/cpptool/rfta/src/pyrfta/test/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv13447/src/pyrfta/test/rfta Modified Files: parser.py Log Message: * added grammar for statements Index: parser.py =================================================================== RCS file: /cvsroot/cpptool/rfta/src/pyrfta/test/rfta/parser.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** parser.py 3 Aug 2003 08:50:30 -0000 1.7 --- parser.py 3 Aug 2003 09:24:06 -0000 1.8 *************** *** 1065,1071 **** # ############################## A.6: Statements ############################ ! #dummy ! compound_statement_p = symbol_p('{') >> '}' # ############################## A.7.1: Declarators ############################ --- 1065,1115 ---- # ############################## A.6: Statements ############################ + # A.6, C++PL3 p.802-803 ! block_declaration_p = proxy_p() ! declarator_p = proxy_p() ! simple_declaration_p = proxy_p() ! statement_p = proxy_p() ! try_block_p = proxy_p() ! ! ! condition_p = expression_p \ ! | ( type_specifier_seq_p >> declarator_p >> '=' >> assignment_expression_p ) ! ! expression_statement_p = maybe_p(expression_p) >> eos_p ! ! jump_statement_p = (one_of_p( 'break continue' ) >> eos_p) \ ! | (symbol_p('return') >> maybe_p(expression_p) >> eos_p) \ ! | (symbol_p('goto') >> id_p) ! ! for_init_statement_p = expression_statement_p \ ! | simple_declaration_p ! ! iteration_statement_p = (symbol_p('while') >> '(' >> condition_p >> ')' >> statement_p) \ ! | (symbol_p('do') >> statement_p >> 'while' >> '(' >> expression_p >> ')' >> eos_p) \ ! | (symbol_p('for') >> '(' >> for_init_statement_p >> maybe_p( condition_p ) \ ! >> eos_p >> maybe_p( expression_p ) >> ')' >> statement_p ) ! ! selection_statement_p = ( symbol_p('if') >> '(' >> condition_p >> ')' >> statement_p \ ! >> maybe_p( symbol_p('else') >> statement_p ) ) \ ! | ( symbol_p('switch') >> '(' >> condition_p >> ')' >> statement_p ) ! ! compound_statement_p = symbol_p('{') >> repeat_p( 0, statement_p ) >> '}' ! ! labeled_statement_p = (id_p >> ':' >> statement_p) \ ! | ( symbol_p('case') >> constant_expression_p >> ':' >> statement_p ) \ ! | ( symbol_p('default') >> ':' >> statement_p ) ! ! declaration_statement_p = block_declaration_p ! ! statement_p.setParser( labeled_statement_p ! | expression_statement_p ! | compound_statement_p ! | selection_statement_p ! | iteration_statement_p ! | jump_statement_p ! | declaration_statement_p ! | try_block_p ) ! # ############################## A.7.1: Declarators ############################ *************** *** 1075,1079 **** class_specifier_p = proxy_p() ctor_initializer_p = proxy_p() - declarator_p = proxy_p() decl_specifier_p = proxy_p() # forward declaration for recursion exception_specification_p = proxy_p() --- 1119,1122 ---- *************** *** 1223,1234 **** | 'typedef' ) ! simple_declaration_p = repeat_p( 0, decl_specifier_p ) >> maybe_p( init_declarator_list_p ) >> eos_p # A.7, C++PL3 p.804 ! block_declaration_p = asm_definition_p \ ! | namespace_alias_definition_p \ ! | using_declaration_p \ ! | using_directive_p \ ! | simple_declaration_p declaration_p.setParser( block_declaration_p \ --- 1266,1277 ---- | 'typedef' ) ! simple_declaration_p.setParser( repeat_p( 0, decl_specifier_p ) >> maybe_p( init_declarator_list_p ) >> eos_p ) # A.7, C++PL3 p.804 ! block_declaration_p.setParser( asm_definition_p ! | namespace_alias_definition_p ! | using_declaration_p ! | using_directive_p ! | simple_declaration_p ) declaration_p.setParser( block_declaration_p \ *************** *** 1322,1326 **** exception_specification_p.setParser( symbol_p( 'throw' ) >> '(' >> maybe_p( type_id_list_p ) >> ')' ) ! try_block_p = symbol_p('try') >> compound_statement_p >> handler_seq_p function_try_block_p.setParser( symbol_p('try') >> maybe_p(ctor_initializer_p) >> function_body_p >> handler_seq_p ) --- 1365,1369 ---- exception_specification_p.setParser( symbol_p( 'throw' ) >> '(' >> maybe_p( type_id_list_p ) >> ')' ) ! try_block_p.setParser( symbol_p('try') >> compound_statement_p >> handler_seq_p ) function_try_block_p.setParser( symbol_p('try') >> maybe_p(ctor_initializer_p) >> function_body_p >> handler_seq_p ) |