|
From: <net...@us...> - 2003-04-28 20:38:00
|
Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv25656/src/rftaparser
Modified Files:
UnparsedDeclarationMutator.cpp
Log Message:
-- bug fixes found while class body parsing tests
Index: UnparsedDeclarationMutator.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutator.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** UnparsedDeclarationMutator.cpp 28 Apr 2003 02:45:42 -0000 1.2
--- UnparsedDeclarationMutator.cpp 28 Apr 2003 20:37:54 -0000 1.3
***************
*** 239,243 ****
{
// yes it's - so parse the class specifier
! if (specifierIdent == "class" || specifierIdent == "struct")
{
--- 239,243 ----
{
// yes it's - so parse the class specifier
! if (specifierIdent == "class" || specifierIdent == "struct" || specifierIdent == "union")
{
***************
*** 289,295 ****
{
// the 'typename_' might be a userdefined type or a declarator
! // here we try to find out:
! const char * rollback = current_;
!
if (typename_ == "operator")
return false;
--- 289,293 ----
{
// the 'typename_' might be a userdefined type or a declarator
! // here we try to find out:
if (typename_ == "operator")
return false;
***************
*** 301,310 ****
{
if (!tryNextIs(':'))
! throwFailure("Declaration parser expects '::' in this context.");
typename_.append("::");
! readNestedName(typename_);
skipSpaces();
}
// now check for template declaration:
if (tryNextIs('<')) // the use of a template type
--- 299,314 ----
{
if (!tryNextIs(':'))
! {
! --current_;
! return false; // it's not "::" - might be the bitfield operator (e.g. "int myvar:0")
! }
typename_.append("::");
! readNestedName(typename_);
skipSpaces();
}
+ // do some look ahead for the decision (store rollback position
+ const char * rollback = current_;
+
// now check for template declaration:
if (tryNextIs('<')) // the use of a template type
***************
*** 364,368 ****
{
if (!tryNextIs(':'))
! throwFailure( "Expected a double colon => '::'." );
fullName.append("::");
--- 368,375 ----
{
if (!tryNextIs(':'))
! {
! --current_;
! return; // // it's not a "::" - might be the bitfield operator (e.g. "int myvar::sub :0")
! }
fullName.append("::");
***************
*** 378,393 ****
UnparsedDeclarationMutator::readClassOrEnumSpecifier(ASTNodePtr& specifier, std::string keyword, std::string name)
{
! if (keyword == "class" || keyword == "struct" )
{
// read over possible inheritance information
! readUntilNextOf("{");
current_++;
} else
{
specifier->mutateType( ASTNodeTypes::enumSpecifier );
expect('{');
- }
findNextBalanced('{','}');
}
--- 385,419 ----
UnparsedDeclarationMutator::readClassOrEnumSpecifier(ASTNodePtr& specifier, std::string keyword, std::string name)
{
! ASTNodePtr body;
! int startIndex;
!
! if (keyword == "class" || keyword == "struct" || keyword == "union")
{
// read over possible inheritance information
! readUntilNextOf("{");
current_++;
+
+ body = createASTNode(
+ ASTNodeTypes::unparsedDeclarationList,
+ specifier,
+ startIndex = getCurrentIndex(),
+ getCurrentLength()
+ );
+ specifier->setPropertyNode( ASTNodeProperties::classBodyProperty , body );
} else
{
specifier->mutateType( ASTNodeTypes::enumSpecifier );
expect('{');
+ body = createASTNode(
+ ASTNodeTypes::unparsedDeclarationList,
+ specifier,
+ startIndex = getCurrentIndex(),
+ getCurrentLength()
+ );
+ specifier->setPropertyNode( ASTNodeProperties::enumBodyProperty , body );
+ }
findNextBalanced('{','}');
+ body->setLength(getCurrentLength() - startIndex - 1 ); // do not count the last '}'
}
***************
*** 535,538 ****
--- 561,572 ----
nestedName.append("::");
readNestedName(identifier);
+ }
+
+ // check for bitfield expression
+ if (tryNextIs(':'))
+ {
+ if (!skipOverAssignmentInitializer())
+ throwFailure("Constant expression is not well formed.");
+ // @todo: store bit field expression
}
continue;
|