Commits

Cyrille Berger  committed 0e59790

fix parsing of numbers returning empty

  • Participants
  • Parent commits de41248

Comments (0)

Files changed (2)

File Cauchy/Lexer.cpp

   }
   if(complex)
   {
-    return Token( Token::COMPLEX_CONSTANT, identifierStr.toFloat(), line(), initial_col );
+    return Token( Token::COMPLEX_CONSTANT, identifierStr, line(), initial_col );
   } else if(integer)
   {
     unget();
-    return Token( Token::INTEGER_CONSTANT, identifierStr.toInt(), line(), initial_col );
+    return Token( Token::INTEGER_CONSTANT, identifierStr, line(), initial_col );
   } else {
     unget();
-    return Token( Token::FLOAT_CONSTANT, identifierStr.toFloat(), line(), initial_col );
+    return Token( Token::FLOAT_CONSTANT, identifierStr, line(), initial_col );
   }
 }
 

File Cauchy/Parser.cpp

   {
     case Token::INTEGER_CONSTANT:
     {
+      String n = d->currentToken.string;
       getNextToken();
-      return new AST::NumberExpression( d->currentToken.string, Type::INTEGER );
+      return new AST::NumberExpression( n, Type::INTEGER );
     }
     case Token::FLOAT_CONSTANT:
     {
+      String n = d->currentToken.string;
       getNextToken();
-      return new AST::NumberExpression( d->currentToken.string, Type::DOUBLE );
+      return new AST::NumberExpression( n, Type::DOUBLE );
     }
     case Token::COMPLEX_CONSTANT:
     {
+      String n = d->currentToken.string;
       getNextToken();
-      return new AST::ComplexNumberExpression( "0", d->currentToken.string, Cauchy::Type::DOUBLE );
+      return new AST::ComplexNumberExpression( "0", n, Cauchy::Type::DOUBLE );
     }
     case Token::STRING_CONSTANT:
     {