Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv9381/src/rfta
Modified Files:
ParserTools.cpp
Log Message:
-- added identifier reader
Index: ParserTools.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/ParserTools.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ParserTools.cpp 22 Dec 2002 16:03:52 -0000 1.3
--- ParserTools.cpp 28 Apr 2003 11:03:57 -0000 1.4
***************
*** 55,58 ****
--- 55,104 ----
}
+ bool RFTAPARSER_API
+ tryReadIdentifier( Xtl::CStringEnumerator &enumerator, Xtl::CStringView& identifier )
+ {
+ if ( !enumerator.hasNext() )
+ return false;
+
+ Xtl::CStringEnumerator identifierStart = enumerator;
+ identifier = enumerator.getString();
+ if ( isValidIdentifierFirstLetter( *enumerator ) )
+ {
+ enumerator++;
+ while ( enumerator.hasNext() && isIdentifierLetter( *enumerator ) )
+ enumerator++;
+ }
+
+ identifier.setEnd(enumerator.getCurrentPos());
+
+ return identifier.getLength() != 0;
+ }
+
+ std::string RFTAPARSER_API
+ tryReadKeyword( Xtl::CStringEnumerator &enumerator,
+ std::set< std::string > keywords )
+ {
+ Xtl::CStringEnumerator rollback ( enumerator );
+
+ std::set< std::string >::iterator result;
+ Xtl::CStringView identifier;
+ if (!tryReadIdentifier(enumerator,identifier))
+ {
+ enumerator = rollback;
+ return std::string();
+ }
+
+ std::string idstr = identifier.str();
+
+ std::set< std::string >::iterator it;
+ it = keywords.find(idstr);
+ if (it == keywords.end())
+ {
+ enumerator = rollback;
+ return std::string();
+ }
+ return idstr;
+ }
+
} // namespace ParserTools
|