|
From: <net...@us...> - 2002-12-28 10:39:02
|
Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv20463/src/rftaparser
Modified Files:
ExpressionMutator.cpp
Log Message:
-- added new tokens for tokenizer
Index: ExpressionMutator.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ExpressionMutator.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ExpressionMutator.cpp 20 Dec 2002 08:30:50 -0000 1.8
--- ExpressionMutator.cpp 28 Dec 2002 10:38:59 -0000 1.9
***************
*** 50,80 ****
const char *tokenStart = current_;
const char *tokenEnd = 0;
! TokenType tokenType = none;
! char c = *current_++;
! if ( c == '.' )
! {
! tokenType = dot;
! }
! else if ( c == '-' && current_ != end_ && *current_ == '>' )
! {
! ++current_;
! tokenType = arrow;
! }
! else if ( c == ':' && current_ != end_ && *current_ == ':' )
! {
! ++current_;
! tokenType = scopeOperator;
! }
! else if ( ParserTools::isValidIdentifierFirstLetter( c ) )
{
while ( current_ != end_ && ParserTools::isIdentifierLetter(*current_) )
++current_;
tokenType = identifier;
! }
! else if ( c == ' ' )
continue;
- else
- tokenType = other;
addToken( tokenStart, current_, tokenType, tokens );
}
--- 50,208 ----
const char *tokenStart = current_;
const char *tokenEnd = 0;
! TokenType tokenType = other;
! char c = *current_++;
!
! if ( ParserTools::isValidIdentifierFirstLetter( c ) )
{
while ( current_ != end_ && ParserTools::isIdentifierLetter(*current_) )
++current_;
tokenType = identifier;
! } else
! switch (c)
! {
! case ' ':
continue;
+ case '.':
+ tokenType = dot;
+ break;
+
+ case '?':
+ tokenType = questMark;
+ break;
+
+ case '-':
+ if (current_ != end_ && *current_ == '>' )
+ {
+ ++current_;
+ tokenType = arrow;
+ } else
+ if (current_ != end_ && *current_ == '=')
+ {
+ ++current_;
+ tokenType = minusAssign;
+ } else
+ tokenType = minus;
+
+
+ break;
+
+ case ',':
+ tokenType = comma;
+ break;
+
+ case '=':
+ if (current_ == end_ || *current_ != '=')
+ tokenType = assign;
+ else
+ if (*current_ == '=')
+ {
+ ++current_;
+ tokenType = equal;
+ }
+ break;
+
+ case '+':
+ if (current_ != end_ && *current_ == '=')
+ {
+ ++current_;
+ tokenType = plusAssign;
+ }
+ break;
+
+ case '%':
+ if (current_ != end_ && *current_ == '=')
+ {
+ ++current_;
+ tokenType = modAssign;
+ }
+ break;
+
+ case '/':
+ if (current_ != end_ && *current_ == '=')
+ {
+ ++current_;
+ tokenType = divAssign;
+ }
+ break;
+
+ case '*':
+ if (current_ != end_ && *current_ == '=')
+ {
+ ++current_;
+ tokenType = mulAssign;
+ }
+ break;
+
+ case '&':
+ if (current_ != end_ && *current_ == '=')
+ {
+ ++current_;
+ tokenType = andAssign;
+ }
+ break;
+
+ case '|':
+ if (current_ != end_ && *current_ == '=')
+ {
+ ++current_;
+ tokenType = orAssign;
+ }
+ break;
+
+ case '^':
+ if (current_ != end_ && *current_ == '=')
+ {
+ ++current_;
+ tokenType = xorAssign;
+ }
+ break;
+
+ case '<':
+ if (current_ != end_ && *current_ == '<')
+ {
+ ++current_;
+ if (current_ == end_ || *current_ != '=')
+ tokenType = leftShift;
+ else
+ {
+ ++current_;
+ tokenType = lshiftAssign;
+ }
+ }
+ break;
+
+ case '>':
+ if (current_ != end_ && *current_ == '>')
+ {
+ ++current_;
+ if (current_ == end_ || *current_ != '=')
+ tokenType = rightShift;
+ else
+ {
+ ++current_;
+ tokenType = rshiftAssign;
+ }
+ }
+ break;
+
+ case '(':
+ tokenType = openBrace;
+ break;
+
+ case ')':
+ tokenType = closeBrace;
+ break;
+
+ case ':':
+ if ( current_ != end_ && *current_ == ':' )
+ {
+ ++current_;
+ tokenType = scopeOperator;
+ }
+ else
+ tokenType = colon;
+ break;
+ }
addToken( tokenStart, current_, tokenType, tokens );
}
***************
*** 127,132 ****
TokenType nextToken )
{
! return token == identifier &&
! ( previousToken == none || previousToken == other ) &&
nextToken != scopeOperator &&
nextToken != identifier;
--- 255,265 ----
TokenType nextToken )
{
! return token == identifier &&
!
! previousToken != arrow &&
! previousToken != colon &&
! previousToken != dot &&
! previousToken != scopeOperator &&
!
nextToken != scopeOperator &&
nextToken != identifier;
***************
*** 151,155 ****
ASTNodePtr variable =
createASTNode( ASTNodeTypes::localScopeIdentifier,
! getParentNode(),
(token.start_ - start_) + getStartIndex(),
token.end_ - token.start_ );
--- 284,288 ----
ASTNodePtr variable =
createASTNode( ASTNodeTypes::localScopeIdentifier,
! node_,
(token.start_ - start_) + getStartIndex(),
token.end_ - token.start_ );
|