From: Baptiste L. <bl...@us...> - 2004-06-19 14:46:16
|
Update of /cvsroot/cpptool/CppParser/examples/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22086/examples/parser Modified Files: cpp_grammar.txt cppparsertest.cpp grammar_tree.txt Log Message: * renamed type_specifier_seq to type_specifier * refactoring occurence of cv_qualifiers_seq workaround_type_specifier cv_qualifiers_seq to type_specifier. Index: grammar_tree.txt =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/grammar_tree.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** grammar_tree.txt 19 Jun 2004 12:24:30 -0000 1.1 --- grammar_tree.txt 19 Jun 2004 14:46:07 -0000 1.2 *************** *** 5,15 **** | namespace_alias_def[ id ! namespace_specifier ! ~ n id] | using_declaration[ using_id ! ~ n id] | using_directive[ ! ~ n id] | simple_declaration[ [ typedef_decl_specifiers --- 5,15 ---- | namespace_alias_def[ id ! namespace_specifier[...] ! ~ n id] // +(namespace_name) | using_declaration[ using_id ! ~ n id] // @todo any_id | using_directive[ ! namespace_specifier[...] ] | simple_declaration[ [ typedef_decl_specifiers *************** *** 28,35 **** ? cv_qualifiers | friend_specifier[ ! !content same as declaration_specifier ! ] | declaration_specifier[ ! !content same as friend_specifier ? storage_class_specifier ? function_specifier --- 28,34 ---- ? cv_qualifiers | friend_specifier[ ! declaration_specifier[...] ] | declaration_specifier[ ! //content same as friend_specifier ? storage_class_specifier ? function_specifier Index: cpp_grammar.txt =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/cpp_grammar.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cpp_grammar.txt 19 Jun 2004 12:47:06 -0000 1.2 --- cpp_grammar.txt 19 Jun 2004 14:46:07 -0000 1.3 *************** *** 292,296 **** condition = expression ! | [ type_specifier_seq declarator '='assignment_expression ] ; --- 292,296 ---- condition = expression ! | [ type_specifier declarator '='assignment_expression ] ; *************** *** 357,361 **** # Notes: OK. No parsing issue qualified_namespace_specifier = :node( 'namespace_specifier', ! ?('::') ?(nested_name_specifier) namespace_name ); namespace_body = '{' declaration_seq '}'; named_namespace_definition = 'namespace' id namespace_body; --- 357,361 ---- # Notes: OK. No parsing issue qualified_namespace_specifier = :node( 'namespace_specifier', ! ?('::') *(id '::') namespace_name ); namespace_body = '{' declaration_seq '}'; named_namespace_definition = 'namespace' id namespace_body; *************** *** 446,451 **** standard_decl_specifier_impl = ?( storage_class_specifier ) ! ?( function_specifier ) ?( cv_qualifier_seq ) ! workaround_type_specifier ?( cv_qualifier_seq ); standard_decl_specifiers = :node( 'declaration_specifier', standard_decl_specifier_impl ); --- 446,450 ---- standard_decl_specifier_impl = ?( storage_class_specifier ) ! ?( function_specifier ) type_specifier; standard_decl_specifiers = :node( 'declaration_specifier', standard_decl_specifier_impl ); *************** *** 553,557 **** # defined in A71, declarators, p807 , after cv_qualifier ! type_id = :node( 'type_id', type_specifier_seq ?( abstract_declarator ) ); # removed infinite left recursion --- 552,556 ---- # defined in A71, declarators, p807 , after cv_qualifier ! type_id = :node( 'type_id', type_specifier ?( abstract_declarator ) ); # removed infinite left recursion *************** *** 581,587 **** init_declarator_list = :node( 'init_declarators', list( init_declarator, ',' ) ); ! type_specifier_seq = :node( 'type_specifier', ! ?(cv_qualifier_seq) workaround_type_specifier ! ?(cv_qualifier_seq) ); function_body = compound_statement; --- 580,586 ---- init_declarator_list = :node( 'init_declarators', list( init_declarator, ',' ) ); ! type_specifier = :node( 'type_specifier', ! ?(cv_qualifier_seq) workaround_type_specifier ! ?(cv_qualifier_seq) ); function_body = compound_statement; *************** *** 596,600 **** ?(cv_qualifier_seq) ?( :node( 'ptr_operator_declarator', +( ptr_operator ) ) ); - #function_return_type = ?(cv_qualifier_seq) workaround_type_specifier ?(cv_qualifier_seq); function_declarator = declarator_id direct_abstract_declarator_fn_suffix; --- 595,598 ---- *************** *** 674,678 **** conversion_type_id = :node('conversion_type', ! type_specifier_seq ?( conversion_declarator )); conversion_function_id = :node('conversion_function_ref', --- 672,676 ---- conversion_type_id = :node('conversion_type', ! type_specifier ?( conversion_declarator )); conversion_function_id = :node('conversion_function_ref', *************** *** 735,739 **** throw_expression = 'throw' ?( assignment_expression ); ! exception_declaration = [ type_specifier_seq ?( declarator | abstract_declarator ) ] | '...'; --- 733,737 ---- throw_expression = 'throw' ?( assignment_expression ); ! exception_declaration = [ type_specifier ?( declarator | abstract_declarator ) ] | '...'; Index: cppparsertest.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/cppparsertest.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cppparsertest.cpp 19 Jun 2004 12:47:06 -0000 1.3 --- cppparsertest.cpp 19 Jun 2004 14:46:07 -0000 1.4 *************** *** 1031,1034 **** --- 1031,1038 ---- CPPPARSER_ASSERT_MATCH( "namespace fs = ::boost::filesystem;", "namespace_alias_definition" ); CPPPARSER_ASSERT_MATCH( "namespace b = boost;", "namespace_alias_definition" ); + CPPPARSER_ASSERT_TREE( "namespace fs=boost::filesystem;", "namespace_alias_definition", + testNode( "namespace_alias_def", "namespace", spaces_t(1), id_t("fs"), "=", + testNode("namespace_specifier", id_t("boost"), "::", id_t("filesystem") ), + ";" ) ); } *************** *** 1052,1055 **** --- 1056,1064 ---- CPPPARSER_ASSERT_MATCH( "using namespace std;", "using_directive" ); CPPPARSER_ASSERT_MATCH( "using namespace ::std;", "using_directive" ); + CPPPARSER_ASSERT_TREE( "using namespace ::boost::filesystem;", "using_directive", + testNode( "using_directive", "using", spaces_t(1), "namespace", + testNode("namespace_specifier", spaces_t(1), + "::", id_t("boost"), "::", id_t("filesystem") ), + ";" ) ); } *************** *** 1127,1136 **** CppParserTest::testTypeSpecifierSeqParser() { ! CPPPARSER_ASSERT_MATCH( "const int", "type_specifier_seq" ); ! CPPPARSER_ASSERT_MATCH( "enum MyEnum {}", "type_specifier_seq" ); ! CPPPARSER_ASSERT_MATCH( "int const", "type_specifier_seq" ); ! CPPPARSER_ASSERT_MATCH( "volatile double", "type_specifier_seq" ); ! CPPPARSER_ASSERT_MATCH( "struct MyNamespace::MyStruct", "type_specifier_seq" ); ! CPPPARSER_ASSERT_MATCH( "class MyClass {}", "type_specifier_seq" ); // more case to test } --- 1136,1145 ---- CppParserTest::testTypeSpecifierSeqParser() { ! CPPPARSER_ASSERT_MATCH( "const int", "type_specifier" ); ! CPPPARSER_ASSERT_MATCH( "enum MyEnum {}", "type_specifier" ); ! CPPPARSER_ASSERT_MATCH( "int const", "type_specifier" ); ! CPPPARSER_ASSERT_MATCH( "volatile double", "type_specifier" ); ! CPPPARSER_ASSERT_MATCH( "struct MyNamespace::MyStruct", "type_specifier" ); ! CPPPARSER_ASSERT_MATCH( "class MyClass {}", "type_specifier" ); // more case to test } *************** *** 1178,1182 **** CPPPARSER_ASSERT_TREE( "int x=2;", "simple_declaration", testNode( "simple_declaration", ! testNode( "declaration_specifier", fundamentalTypeNode("int" ) ), testNode( "init_declarators", testNode( "init_declarator", --- 1187,1192 ---- CPPPARSER_ASSERT_TREE( "int x=2;", "simple_declaration", testNode( "simple_declaration", ! testNode( "declaration_specifier", ! testNode( "type_specifier", fundamentalTypeNode("int" ) ) ), testNode( "init_declarators", testNode( "init_declarator", *************** *** 1188,1193 **** testNode( "simple_declaration", testNode( "declaration_specifier", ! testNode( "forward_class_specifier", "class", ! testNode( "forwarded_type_id", spaces_t(1), id_t("Tools"), "::", id_t("String") ) ) ), ";" ) ); CPPPARSER_ASSERT_MATCH( "void main();", "simple_declaration" ); --- 1198,1205 ---- testNode( "simple_declaration", testNode( "declaration_specifier", ! testNode( "type_specifier", ! testNode( "forward_class_specifier", "class", ! testNode( "forwarded_type_id", ! spaces_t(1), id_t("Tools"), "::", id_t("String") ) ) ) ), ";" ) ); CPPPARSER_ASSERT_MATCH( "void main();", "simple_declaration" ); *************** *** 1337,1346 **** testNode( "compound_statement", "{", "}" ) ) ), testNode( "member_declaration", ! testNode( "declaration_specifier", fundamentalTypeNode("void") ), testNode( "declarator", declaratorIdNode( "initialize", 1 ), testNode( "function_parameters", "(", ")" ) ), ";" ), testNode( "member_declaration", ! testNode( "declaration_specifier", fundamentalTypeNode("int") ), testNode( "declarator", declaratorIdNode( "x_", 1 ) ), ";" ), --- 1349,1358 ---- testNode( "compound_statement", "{", "}" ) ) ), testNode( "member_declaration", ! testNode( "declaration_specifier", testNode( "type_specifier", fundamentalTypeNode("void") ) ), testNode( "declarator", declaratorIdNode( "initialize", 1 ), testNode( "function_parameters", "(", ")" ) ), ";" ), testNode( "member_declaration", ! testNode( "declaration_specifier", testNode( "type_specifier", fundamentalTypeNode("int") ) ), testNode( "declarator", declaratorIdNode( "x_", 1 ) ), ";" ), *************** *** 1596,1604 **** testNode( "simple_declaration", testNode( "declaration_specifier", ! testNode( "class_specifier", ! "class", ! testNode( "class_name", ! testNode( "id", spaces_t(1), id_t("C1") ) ), ! spaces_t(1), "{", "}" ) ), ";" ) ) ) ); --- 1608,1617 ---- testNode( "simple_declaration", testNode( "declaration_specifier", ! testNode( "type_specifier", ! testNode( "class_specifier", ! "class", ! testNode( "class_name", ! testNode( "id", spaces_t(1), id_t("C1") ) ), ! spaces_t(1), "{", "}" ) ) ), ";" ) ) ) ); |