From: Baptiste L. <bl...@us...> - 2004-06-19 12:47:16
|
Update of /cvsroot/cpptool/CppParser/examples/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9867/examples/parser Modified Files: cpp_grammar.txt cppparsertest.cpp Log Message: * cleaned up declaration_seq tree structure Index: cpp_grammar.txt =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/cpp_grammar.txt,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cpp_grammar.txt 8 Jun 2004 20:23:13 -0000 1.1.1.1 --- cpp_grammar.txt 19 Jun 2004 12:47:06 -0000 1.2 *************** *** 91,95 **** # A.4, C++PL3 p.798 ! translation_unit = :node( 'translation_unit', ?( declaration_seq ) ); --- 91,95 ---- # A.4, C++PL3 p.798 ! translation_unit = :node( 'translation_unit', declaration_seq ); *************** *** 351,364 **** declaration_error_recovery = :node( 'declaration_error', :cpp_block_error_recovery() ); ! declaration_seq = +( declaration | declaration_error_recovery ); # A.7, C++PL3 p.805-806 # => parse namespace declaration and namespace alias declaration # Notes: OK. No parsing issue - namespace_body = ?( :node( 'namespace_body', declaration_seq ) ); qualified_namespace_specifier = :node( 'namespace_specifier', ?('::') ?(nested_name_specifier) namespace_name ); ! named_namespace_definition = 'namespace' id '{' namespace_body '}'; ! unnamed_namespace_definition = 'namespace' '{' namespace_body '}'; namespace_definition = :node( 'named_namespace_def', named_namespace_definition ) | :node( 'unnamed_namespace_def', unnamed_namespace_definition ) --- 351,364 ---- declaration_error_recovery = :node( 'declaration_error', :cpp_block_error_recovery() ); ! declaration_seq = :node('declarations', *( declaration | declaration_error_recovery ) ); # A.7, C++PL3 p.805-806 # => parse namespace declaration and namespace alias declaration # 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; ! unnamed_namespace_definition = 'namespace' namespace_body; namespace_definition = :node( 'named_namespace_def', named_namespace_definition ) | :node( 'unnamed_namespace_def', unnamed_namespace_definition ) *************** *** 375,379 **** using_declaration = :node('using_declaration', 'using' using_id ';' ); ! using_directive = 'using' 'namespace' qualified_namespace_specifier ';'; # A.7, C++PL3 p.806 --- 375,380 ---- using_declaration = :node('using_declaration', 'using' using_id ';' ); ! using_directive = :node( 'using_directive', ! 'using' 'namespace' qualified_namespace_specifier ';' ); # A.7, C++PL3 p.806 *************** *** 381,385 **** asm_keyword = %'asm __asm'; ! asm_definition = asm_keyword '(' $string ')' ';'; # A.7, C++PL3 p.806 --- 382,386 ---- asm_keyword = %'asm __asm'; ! asm_definition = :node( 'asm_definition', asm_keyword '(' $string ')' ';' ); # A.7, C++PL3 p.806 *************** *** 387,391 **** linkage_specification_begin = 'extern' $string; linkage_specification = :node( 'linkage_specification', ! linkage_specification_begin [ [ '{' ?(declaration_seq) '}' ] | declaration ] ); --- 388,392 ---- linkage_specification_begin = 'extern' $string; linkage_specification = :node( 'linkage_specification', ! linkage_specification_begin [ [ '{' declaration_seq '}' ] | declaration ] ); *************** *** 708,712 **** # don't you this until we can now for sure that the id of the template_name is really an id # => would otherwise be confused with expression such as x < y && x > z. ! template_id = template_name '<' ?( template_argument_list ) '>'; type_parameter = --- 709,713 ---- # don't you this until we can now for sure that the id of the template_name is really an id # => would otherwise be confused with expression such as x < y && x > z. ! template_id = :node( 'template_id', template_name '<' ?( template_argument_list ) '>' ); type_parameter = Index: cppparsertest.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/cppparsertest.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cppparsertest.cpp 14 Jun 2004 23:08:11 -0000 1.2 --- cppparsertest.cpp 19 Jun 2004 12:47:06 -0000 1.3 *************** *** 1060,1063 **** --- 1060,1070 ---- CPPPARSER_ASSERT_MATCH( "namespace { } ", "namespace_definition" ); CPPPARSER_ASSERT_MATCH( "namespace MyWork { } ", "namespace_definition" ); + CPPPARSER_ASSERT_TREE( "namespace MyWork{} ", "namespace_definition", + testNode( "named_namespace_def", + "namespace", spaces_t(1), id_t( "MyWork" ), "{", + jokerNode( "declarations" ), "}" ) ); + CPPPARSER_ASSERT_TREE( "namespace{} ", "namespace_definition", + testNode( "unnamed_namespace_def", + "namespace", "{", jokerNode( "declarations" ), "}" ) ); } *************** *** 1100,1103 **** --- 1107,1114 ---- CPPPARSER_ASSERT_MATCH( "extern \"C\" { int x; void fn(); }", "linkage_specification" ); CPPPARSER_ASSERT_MATCH( "extern \"C\" int x;", "linkage_specification" ); + CPPPARSER_ASSERT_TREE( "extern \"C\"{}", "linkage_specification", + testNode( "linkage_specification", + "extern", spaces_t(1), string_t("C"), "{", + jokerNode("declarations"), "}" ) ); } *************** *** 1582,1593 **** "translation_unit", testNode( "translation_unit", ! testNode( "simple_declaration", ! testNode( "declaration_specifier", ! testNode( "class_specifier", ! "class", ! testNode( "class_name", ! testNode( "id", spaces_t(1), id_t("C1") ) ), ! spaces_t(1), "{", "}" ) ), ! ";" ) ) ); //CPPPARSER_ASSERT_TREE( "namespace N1 { namespace N2 {} }", --- 1593,1605 ---- "translation_unit", testNode( "translation_unit", ! testNode( "declarations", ! testNode( "simple_declaration", ! testNode( "declaration_specifier", ! testNode( "class_specifier", ! "class", ! testNode( "class_name", ! testNode( "id", spaces_t(1), id_t("C1") ) ), ! spaces_t(1), "{", "}" ) ), ! ";" ) ) ) ); //CPPPARSER_ASSERT_TREE( "namespace N1 { namespace N2 {} }", *************** *** 1613,1620 **** , "translation_unit", testNode( "translation_unit", ! jokerNode("simple_declaration"), ! testNode("declaration_error", ! id_t("WEIRD_MACRO"), "(",int_t("12"),")", ! "int", spaces_t(1), id_t("x"), ";" ), ! jokerNode("simple_declaration") ) ); } --- 1625,1633 ---- , "translation_unit", testNode( "translation_unit", ! testNode( "declarations", ! jokerNode("simple_declaration"), ! testNode("declaration_error", ! id_t("WEIRD_MACRO"), "(",int_t("12"),")", ! "int", spaces_t(1), id_t("x"), ";" ), ! jokerNode("simple_declaration") ) ) ); } |