Changeset 609

Show
Ignore:
Timestamp:
07/22/08 16:13:24 (4 months ago)
Author:
moenicke
Message:

* using std::stringstream for error output

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/rphp/compiler/parser/php.g

    r607 r609  
    2626#include <string> 
    2727#include <iostream> 
     28#include <sstream> 
     29 
     30// I hope this makes life easier 
     31#define str(stdstring) std::string(stdstring) 
    2832 
    2933namespace rphp 
     
    781785void parser::yy_expected_symbol(int kind, const char* name) 
    782786{ 
    783 #ifdef PEDNING_THOMAS 
    784 // TODO pending 
    785  
    786787    rint64 line; 
    787788    rint64 col; 
    788789    rint64 index = token_stream->index()-1; 
    789790    token_type &token = token_stream->token(index); 
    790     kDebug() << "token starts at:" << token.begin; 
    791     kDebug() << "index is:" << index; 
    792     token_stream->startPosition(index, &line, &col); 
     791    std::cout << "token starts at:" << token.begin; 
     792    std::cout << "index is:" << index; 
     793//    token_stream->start_position(index, &line, &col); 
    793794    UnicodeString tokenValue = tokenText(token.begin, token.end); 
     795 
     796    std::stringstream msg; 
     797    msg << "Expected symbol "  
     798        << name  
     799        << " (current token: \""  
     800//        + ( token.kind != 0 ? tokenValue : \"EOF\" ) 
     801        + token.kind  
     802        << " at line: " 
     803        << line 
     804        << " col: " 
     805        << col; 
     806 
     807//        reportProblem( parser::Error, msg.str() ); 
     808 
     809#ifdef PENDING_THOMAS // can be removed 
    794810    reportProblem( parser::Error, 
    795 // TODO port me 
    796 //                   QString("Expected symbol \"%1\" (current token: \"%2\" [%3] at line: %4 col: %5)") 
     811                   QString("Expected symbol \"%1\" (current token: \"%2\" [%3] at line: %4 col: %5)") 
    797812                  .arg(name) 
    798813                  .arg(token.kind != 0 ? tokenValue : "EOF") 
  • trunk/rphp/compiler/parser/rphp_ast.h

    r607 r609  
    1212#include <string> 
    1313#include <iostream> 
     14#include <sstream> 
     15 
     16// I hope this makes life easier 
     17#define str(stdstring) std::string(stdstring) 
    1418 
    1519namespace rphp 
  • trunk/rphp/compiler/parser/rphp_parser.cpp

    r607 r609  
    7272  void parser::yy_expected_symbol(int kind,  const char* name) 
    7373  { 
    74 #ifdef PEDNING_THOMAS  
    75     // TODO pending 
    76  
    7774    rint64 line; 
    7875    rint64 col; 
    7976    rint64 index =  token_stream->index() - 1; 
    8077    token_type &token =  token_stream->token(index); 
    81     kDebug() <<  "token starts at:" <<  token.begin; 
    82     kDebug() <<  "index is:" <<  index; 
    83     token_stream->startPosition(index,  &line, &col); 
     78    std::cout <<  "token starts at:" <<  token.begin; 
     79    std::cout <<  "index is:" <<  index; 
     80    //    token_stream->start_position(index, &line, &col); 
    8481    UnicodeString tokenValue =  tokenText(token.begin,  token.end); 
     82 
     83    std::stringstream msg; 
     84    msg <<  "Expected symbol " 
     85    <<  name 
     86    <<  " (current token: \"" 
     87    //        + ( token.kind != 0 ? tokenValue : \"EOF\" ) 
     88    +  token.kind 
     89    <<  " at line: " 
     90    <<  line 
     91    <<  " col: " 
     92    <<  col; 
     93 
     94    //        reportProblem( parser::Error, msg.str() ); 
     95 
     96#ifdef PENDING_THOMAS 
     97 
    8598    reportProblem( parser::Error, 
    8699                   // TODO port me