CompilerTranslator.cpp
Go to the documentation of this file.
00001 
00002 #include "CompilerTranslator.h"
00003 #include "../../compiler/errors_code.h"
00004 
00005 #include <CompilerTranslator.moc>
00006 
00007 namespace Aseba
00008 {
00009         CompilerTranslator::CompilerTranslator()
00010         {
00011 
00012         }
00013 
00014         const std::wstring CompilerTranslator::translate(ErrorCode error)
00015         {
00016                 QString msg;
00017 
00018                 switch (error)
00019                 {
00020 
00021                         case ERROR_BROKEN_TARGET:
00022                                 msg = tr("Broken target description: not enough room for internal variables");
00023                                 break;
00024 
00025                         case ERROR_STACK_OVERFLOW:
00026                                 msg = tr("Execution stack will overflow, check for any recursive subroutine call and cut long mathematical expressions");
00027                                 break;
00028 
00029                         case ERROR_SCRIPT_TOO_BIG:
00030                                 msg = tr("Script too big for target bytecode size");
00031                                 break;
00032 
00033                         case ERROR_VARIABLE_NOT_DEFINED:
00034                                 msg = tr("%0 is not a defined variable");
00035                                 break;
00036 
00037                         case ERROR_VARIABLE_NOT_DEFINED_GUESS:
00038                                 msg = tr("%0 is not a defined variable, do you mean %1?");
00039                                 break;
00040 
00041                         case ERROR_FUNCTION_NOT_DEFINED:
00042                                 msg = tr("Target does not provide function %0");
00043                                 break;
00044 
00045                         case ERROR_FUNCTION_NOT_DEFINED_GUESS:
00046                                 msg = tr("Target does not provide function %0, do you mean %1?");
00047                                 break;
00048 
00049                         case ERROR_CONSTANT_NOT_DEFINED:
00050                                 msg = tr("Constant %0 not defined");
00051                                 break;
00052 
00053                         case ERROR_CONSTANT_NOT_DEFINED_GUESS:
00054                                 msg = tr("Constant %0 not defined, do you mean %1?");
00055                                 break;
00056 
00057                         case ERROR_EVENT_NOT_DEFINED:
00058                                 msg = tr("%0 is not a known event");
00059                                 break;
00060 
00061                         case ERROR_EVENT_NOT_DEFINED_GUESS:
00062                                 msg = tr("%0 is not a known event, do you mean %1?");
00063                                 break;
00064 
00065                         case ERROR_EMIT_LOCAL_EVENT:
00066                                 msg = tr("%0 is a local event that you cannot emit");
00067                                 break;
00068 
00069                         case ERROR_SUBROUTINE_NOT_DEFINED:
00070                                 msg = tr("Subroutine %0 does not exists");
00071                                 break;
00072 
00073                         case ERROR_SUBROUTINE_NOT_DEFINED_GUESS:
00074                                 msg = tr("Subroutine %0 does not exists, do you mean %1?");
00075                                 break;
00076 
00077                         case ERROR_LINE:
00078                                 msg = tr("Line: ");
00079                                 break;
00080 
00081                         case ERROR_COL:
00082                                 msg = tr(" Col: ");
00083                                 break;
00084 
00085                         case ERROR_UNBALANCED_COMMENT_BLOCK:
00086                                 msg = tr("Unbalanced comment block");
00087                                 break;
00088 
00089                         case ERROR_SYNTAX:
00090                                 msg = tr("Syntax error");
00091                                 break;
00092 
00093                         case ERROR_INVALID_IDENTIFIER:
00094                                 msg = tr("Identifiers must begin with _ or an alphanumeric character, found unicode character 0x%0 instead");
00095                                 break;
00096 
00097                         case ERROR_INVALID_HEXA_NUMBER:
00098                                 msg = tr("Error in hexadecimal number");
00099                                 break;
00100 
00101                         case ERROR_INVALID_BINARY_NUMBER:
00102                                 msg = tr("Error in binary number");
00103                                 break;
00104 
00105                         case ERROR_NUMBER_INVALID_BASE:
00106                                 msg = tr("Error in number, invalid base");
00107                                 break;
00108 
00109                         case ERROR_IN_NUMBER:
00110                                 msg = tr("Error in number");
00111                                 break;
00112 
00113                         case ERROR_INTERNAL:
00114                                 msg = tr("Internal compiler error, please report a bug containing the source which triggered this error");
00115                                 break;
00116 
00117                         case ERROR_EXPECTING:
00118                                 msg = tr("Expecting %0, found %1 instead");
00119                                 break;
00120 
00121                         case ERROR_UINT12_OUT_OF_RANGE:
00122                                 msg = tr("Integer value %0 out of [0;4095] range");
00123                                 break;
00124 
00125                         case ERROR_UINT16_OUT_OF_RANGE:
00126                                 msg = tr("Integer value %0 out of [0;65535] range");
00127                                 break;
00128 
00129                         case ERROR_PINT16_OUT_OF_RANGE:
00130                                 msg = tr("Integer value %0 out of [0;32767] range");
00131                                 break;
00132 
00133                         case ERROR_INT16_OUT_OF_RANGE:
00134                                 msg = tr("Integer value %0 out of [-32768;32767] range");
00135                                 break;
00136 
00137                         case ERROR_PCONSTANT_OUT_OF_RANGE:
00138                                 msg = tr("Constant %0 has value %1, which is out of [0;32767] range");
00139                                 break;
00140 
00141                         case ERROR_CONSTANT_OUT_OF_RANGE:
00142                                 msg = tr("Constant %0 has value %1, which is out of [-32768;32767] range");
00143                                 break;
00144 
00145                         case ERROR_EXPECTING_ONE_OF:
00146                                 msg = tr("Expecting one of %0; but found %1 instead");
00147                                 break;
00148 
00149                         case ERROR_NOT_ENOUGH_TEMP_SPACE:
00150                                 msg = tr("Not enough free space to allocate this tempory variable");
00151                                 break;
00152 
00153                         case ERROR_MISPLACED_VARDEF:
00154                                 msg = tr("Variable definition is allowed only at the beginning of the program before any statement");
00155                                 break;
00156 
00157                         case ERROR_EXPECTING_IDENTIFIER:
00158                                 msg = tr("Expecting identifier, found %0");
00159                                 break;
00160 
00161                         case ERROR_VAR_ALREADY_DEFINED:
00162                                 msg = tr("Variable %0 is already defined");
00163                                 break;
00164 
00165                         case ERROR_VAR_CONST_COLLISION:
00166                                 msg = tr("Variable %0 has the same name as a constant");
00167                                 break;
00168 
00169                         case ERROR_UNDEFINED_SIZE:
00170                                 msg = tr("Array %0 has undefined size");
00171                                 break;
00172 
00173                         case ERROR_NOT_ENOUGH_SPACE:
00174                                 msg = tr("No more free variable space");
00175                                 break;
00176 
00177                         case ERROR_EXPECTING_ASSIGNMENT:
00178                                 msg = tr("Expecting assignment, found %0 instead");
00179                                 break;
00180 
00181                         case ERROR_FOR_NULL_STEPS:
00182                                 msg = tr("Null steps are not allowed in for loops");
00183                                 break;
00184 
00185                         case ERROR_FOR_START_HIGHER_THAN_END:
00186                                 msg = tr("Start index must be lower than end index in increasing loops");
00187                                 break;
00188 
00189                         case ERROR_FOR_START_LOWER_THAN_END:
00190                                 msg = tr("Start index must be higher than end index in decreasing loops");
00191                                 break;
00192 
00193                         case ERROR_EVENT_ALREADY_IMPL:
00194                                 msg = tr("Event %0 is already implemented");
00195                                 break;
00196 
00197                         case ERROR_EVENT_WRONG_ARG_SIZE:
00198                                 msg = tr("Event %0 needs an array of size %1, but one of size %2 is passed");
00199                                 break;
00200 
00201                         case ERROR_SUBROUTINE_ALREADY_DEF:
00202                                 msg = tr("Subroutine %0 is already defined");
00203                                 break;
00204 
00205                         case ERROR_INDEX_EXPECTING_CONSTANT:
00206                                 msg = tr("Expecting a constant expression as a second index");
00207                                 break;
00208 
00209                         case ERROR_INDEX_WRONG_END:
00210                                 msg = tr("End of range index must be lower or equal to start of range index");
00211                                 break;
00212 
00213                         case ERROR_SIZE_IS_NEGATIVE:
00214                                 msg = tr("Array size: result is negative (%0)");
00215                                 break;
00216 
00217                         case ERROR_SIZE_IS_NULL:
00218                                 msg = tr("Array size: result is null");
00219                                 break;
00220 
00221                         case ERROR_NOT_CONST_EXPR:
00222                                 msg = tr("Not a valid constant expression");
00223                                 break;
00224 
00225                         case ERROR_FUNCTION_HAS_NO_ARG:
00226                                 msg = tr("Function %0 requires no argument, some are used");
00227                                 break;
00228 
00229                         case ERROR_FUNCTION_NO_ENOUGH_ARG:
00230                                 msg = tr("Function %0 requires %1 arguments, only %2 are provided");
00231                                 break;
00232 
00233                         case ERROR_FUNCTION_WRONG_ARG_SIZE:
00234                                 msg = tr("Argument %0 (%1) of function %2 is of size %3, function definition demands size %4");
00235                                 break;
00236 
00237                         case ERROR_FUNCTION_WRONG_ARG_SIZE_TEMPLATE:
00238                                 msg = tr("Argument %0 (%1) of function %2 is of size %3, while a previous instance of the template parameter was of size %4");
00239                                 break;
00240 
00241                         case ERROR_FUNCTION_TOO_MANY_ARG:
00242                                 msg = tr("Function %0 requires %1 arguments, more are used");
00243                                 break;
00244 
00245                         case ERROR_UNARY_ARITH_BUILD_UNEXPECTED:
00246                                 msg = tr("Unexpected token when building UnaryArithmeticAssignmentNode");
00247                                 break;
00248 
00249                         case ERROR_INCORRECT_LEFT_VALUE:
00250                                 msg = tr("Expecting an assignment to a variable, found %0 instead");
00251                                 break;
00252 
00253                         case ERROR_ARRAY_OUT_OF_BOUND:
00254                                 msg = tr("Access of array %0 out of bounds: accessing index %1 while array is of size %2");
00255                                 break;
00256 
00257                         case ERROR_ARRAY_SIZE_MISMATCH:
00258                                 msg = tr("Size error! Size of array1 = %0 ; size of array2 = %1");
00259                                 break;
00260 
00261                         case ERROR_IF_VECTOR_CONDITION:
00262                                 msg = tr("Condition of the if cannot be a vector");
00263                                 break;
00264 
00265                         case ERROR_WHILE_VECTOR_CONDITION:
00266                                 msg = tr("Condition of the while cannot be a vector");
00267                                 break;
00268 
00269                         case ERROR_ARRAY_ILLEGAL_ACCESS:
00270                                 msg = tr("MemoryVectorNode::getVectorSize: illegal operation");
00271                                 break;
00272 
00273                         case ERROR_INFINITE_LOOP:
00274                                 msg = tr("Infinite loops not allowed");
00275                                 break;
00276 
00277                         case ERROR_DIVISION_BY_ZERO:
00278                                 msg = tr("Division by zero");
00279                                 break;
00280 
00281                         case ERROR_ABS_NOT_POSSIBLE:
00282                                 msg = tr("-32768 has no positive correspondance in 16 bits integers");
00283                                 break;
00284 
00285                         case ERROR_ARRAY_OUT_OF_BOUND_READ:
00286                                 msg = tr("Out of bound static array access. Trying to read index %0 of array %1 of size %2");
00287                                 break;
00288 
00289                         case ERROR_ARRAY_OUT_OF_BOUND_WRITE:
00290                                 msg = tr("Out of bound static array access. Trying to write index %0 of array %1 of size %2");
00291                                 break;
00292 
00293                         case ERROR_EXPECTING_TYPE:
00294                                 msg = tr("Expecting %0 type, found %1 type instead");
00295                                 break;
00296 
00297                         case ERROR_EXPECTING_CONDITION:
00298                                 msg = tr("Expecting a condition, found a %0 instead");
00299                                 break;
00300 
00301                         case ERROR_TOKEN_END_OF_STREAM:
00302                                 msg = tr("end of stream");
00303                                 break;
00304 
00305                         case ERROR_TOKEN_STR_when:
00306                                 msg = tr("when keyword");
00307                                 break;
00308 
00309                         case ERROR_TOKEN_STR_emit:
00310                                 msg = tr("emit keyword");
00311                                 break;
00312 
00313                         case ERROR_TOKEN_STR_for:
00314                                 msg = tr("for keyword");
00315                                 break;
00316 
00317                         case ERROR_TOKEN_STR_in:
00318                                 msg = tr("in keyword");
00319                                 break;
00320 
00321                         case ERROR_TOKEN_STR_step:
00322                                 msg = tr("step keyword");
00323                                 break;
00324 
00325                         case ERROR_TOKEN_STR_while:
00326                                 msg = tr("while keyword");
00327                                 break;
00328 
00329                         case ERROR_TOKEN_STR_do:
00330                                 msg = tr("do keyword");
00331                                 break;
00332 
00333                         case ERROR_TOKEN_STR_if:
00334                                 msg = tr("if keyword");
00335                                 break;
00336 
00337                         case ERROR_TOKEN_STR_then:
00338                                 msg = tr("then keyword");
00339                                 break;
00340 
00341                         case ERROR_TOKEN_STR_else:
00342                                 msg = tr("else keyword");
00343                                 break;
00344 
00345                         case ERROR_TOKEN_STR_elseif:
00346                                 msg = tr("elseif keyword");
00347                                 break;
00348 
00349                         case ERROR_TOKEN_STR_end:
00350                                 msg = tr("end keyword");
00351                                 break;
00352 
00353                         case ERROR_TOKEN_STR_var:
00354                                 msg = tr("var keyword");
00355                                 break;
00356 
00357                         case ERROR_TOKEN_STR_call:
00358                                 msg = tr("call keyword");
00359                                 break;
00360 
00361                         case ERROR_TOKEN_STR_sub:
00362                                 msg = tr("sub keyword");
00363                                 break;
00364 
00365                         case ERROR_TOKEN_STR_callsub:
00366                                 msg = tr("callsub keyword");
00367                                 break;
00368 
00369                         case ERROR_TOKEN_STR_onevent:
00370                                 msg = tr("onevent keyword");
00371                                 break;
00372 
00373                         case ERROR_TOKEN_STR_abs:
00374                                 msg = tr("abs keyword");
00375                                 break;
00376 
00377                         case ERROR_TOKEN_STR_return:
00378                                 msg = tr("return keyword");
00379                                 break;
00380 
00381                         case ERROR_TOKEN_STRING_LITERAL:
00382                                 msg = tr("string");
00383                                 break;
00384 
00385                         case ERROR_TOKEN_INT_LITERAL:
00386                                 msg = tr("integer");
00387                                 break;
00388 
00389                         case ERROR_TOKEN_PAR_OPEN:
00390                                 msg = tr("( (open parenthesis)");
00391                                 break;
00392 
00393                         case ERROR_TOKEN_PAR_CLOSE:
00394                                 msg = tr(") (close parenthesis)");
00395                                 break;
00396 
00397                         case ERROR_TOKEN_BRACKET_OPEN:
00398                                 msg = tr("[ (open bracket)");
00399                                 break;
00400 
00401                         case ERROR_TOKEN_BRACKET_CLOSE:
00402                                 msg = tr("] (close bracket)");
00403                                 break;
00404 
00405                         case ERROR_TOKEN_COLON:
00406                                 msg = tr(": (colon)");
00407                                 break;
00408 
00409                         case ERROR_TOKEN_COMMA:
00410                                 msg = tr(", (comma)");
00411                                 break;
00412 
00413                         case ERROR_TOKEN_ASSIGN:
00414                                 msg = tr("= (assignation)");
00415                                 break;
00416 
00417                         case ERROR_TOKEN_OP_OR:
00418                                 msg = tr("or");
00419                                 break;
00420 
00421                         case ERROR_TOKEN_OP_AND:
00422                                 msg = tr("and");
00423                                 break;
00424 
00425                         case ERROR_TOKEN_OP_NOT:
00426                                 msg = tr("not");
00427                                 break;
00428 
00429                         case ERROR_TOKEN_OP_BIT_OR:
00430                                 msg = tr("binary or");
00431                                 break;
00432 
00433                         case ERROR_TOKEN_OP_BIT_XOR:
00434                                 msg = tr("binary xor");
00435                                 break;
00436 
00437                         case ERROR_TOKEN_OP_BIT_AND:
00438                                 msg = tr("binary and");
00439                                 break;
00440 
00441                         case ERROR_TOKEN_OP_BIT_NOT:
00442                                 msg = tr("binary not");
00443                                 break;
00444 
00445                         case ERROR_TOKEN_OP_BIT_OR_EQUAL:
00446                                 msg = tr("binary or equal");
00447                                 break;
00448 
00449                         case ERROR_TOKEN_OP_BIT_XOR_EQUAL:
00450                                 msg = tr("binary xor equal");
00451                                 break;
00452 
00453                         case ERROR_TOKEN_OP_BIT_AND_EQUAL:
00454                                 msg = tr("binary and equal");
00455                                 break;
00456 
00457                         case ERROR_TOKEN_OP_EQUAL:
00458                                 msg = tr("== (equal to)");
00459                                 break;
00460 
00461                         case ERROR_TOKEN_OP_NOT_EQUAL:
00462                                 msg = tr("!= (not equal to)");
00463                                 break;
00464 
00465                         case ERROR_TOKEN_OP_BIGGER:
00466                                 msg = tr("> (bigger than)");
00467                                 break;
00468 
00469                         case ERROR_TOKEN_OP_BIGGER_EQUAL:
00470                                 msg = tr(">= (bigger or equal than)");
00471                                 break;
00472 
00473                         case ERROR_TOKEN_OP_SMALLER:
00474                                 msg = tr("< (smaller than)");
00475                                 break;
00476 
00477                         case ERROR_TOKEN_OP_SMALLER_EQUAL:
00478                                 msg = tr("<= (smaller or equal than)");
00479                                 break;
00480 
00481                         case ERROR_TOKEN_OP_SHIFT_LEFT:
00482                                 msg = tr("<< (shift left)");
00483                                 break;
00484 
00485                         case ERROR_TOKEN_OP_SHIFT_RIGHT:
00486                                 msg = tr(">> (shift right)");
00487                                 break;
00488 
00489                         case ERROR_TOKEN_OP_SHIFT_LEFT_EQUAL:
00490                                 msg = tr("<<= (shift left equal)");
00491                                 break;
00492 
00493                         case ERROR_TOKEN_OP_SHIFT_RIGHT_EQUAL:
00494                                 msg = tr(">>= (shift right equal)");
00495                                 break;
00496 
00497                         case ERROR_TOKEN_OP_ADD:
00498                                 msg = tr("+ (plus)");
00499                                 break;
00500 
00501                         case ERROR_TOKEN_OP_NEG:
00502                                 msg = tr("- (minus)");
00503                                 break;
00504 
00505                         case ERROR_TOKEN_OP_ADD_EQUAL:
00506                                 msg = tr("+= (plus equal)");
00507                                 break;
00508 
00509                         case ERROR_TOKEN_OP_NEG_EQUAL:
00510                                 msg = tr("-= (minus equal)");
00511                                 break;
00512 
00513                         case ERROR_TOKEN_OP_PLUS_PLUS:
00514                                 msg = tr("++ (plus plus)");
00515                                 break;
00516 
00517                         case ERROR_TOKEN_OP_MINUS_MINUS:
00518                                 msg = tr("-- (minus minus)");
00519                                 break;
00520 
00521                         case ERROR_TOKEN_OP_MULT:
00522                                 msg = tr("* (time)");
00523                                 break;
00524 
00525                         case ERROR_TOKEN_OP_DIV:
00526                                 msg = tr("/ (divide)");
00527                                 break;
00528 
00529                         case ERROR_TOKEN_OP_MOD:
00530                                 msg = tr("modulo");
00531                                 break;
00532 
00533                         case ERROR_TOKEN_OP_MULT_EQUAL:
00534                                 msg = tr("*= (time equal)");
00535                                 break;
00536 
00537                         case ERROR_TOKEN_OP_DIV_EQUAL:
00538                                 msg = tr("/= (divide equal)");
00539                                 break;
00540 
00541                         case ERROR_TOKEN_OP_MOD_EQUAL:
00542                                 msg = tr("modulo equal");
00543                                 break;
00544 
00545                         case ERROR_TOKEN_UNKNOWN:
00546                                 msg = tr("unknown");
00547                                 break;
00548 
00549                         case ERROR_UNKNOWN_ERROR:
00550                                 msg = tr("Unknown error");
00551                                 break;
00552 
00553                         default:
00554                                 msg = tr("Unknown error");
00555                 }
00556 
00557                 return msg.toStdWString();
00558         }
00559 };


aseba
Author(s): Stéphane Magnenat
autogenerated on Thu Jan 2 2014 11:17:16