diff --git a/test/translator03.dat b/test/translator03.dat index 3321403..f53a63f 100644 --- a/test/translator03.dat +++ b/test/translator03.dat @@ -33,3 +33,5 @@ A%,B$,C% = 1 A$,B$,C% = 1 A$,B$,C$ = 1 Z = A$ + B * C +A = TAB(4) +A = B + SPC(4) diff --git a/test/translator03.txt b/test/translator03.txt index deb4a87..0bc70fc 100644 --- a/test/translator03.txt +++ b/test/translator03.txt @@ -86,3 +86,9 @@ Input: A$,B$,C$ = 1 Input: Z = A$ + B * C ^^^^^-- expected string expression +Input: A = TAB(4) + ^^^^^^-- expected numeric expression + +Input: A = B + SPC(4) + ^^^^^^-- expected numeric expression + diff --git a/translator.cpp b/translator.cpp index 31516bf..634a1bf 100644 --- a/translator.cpp +++ b/translator.cpp @@ -39,7 +39,7 @@ enum { // array of conversion codes [have data type] [need data type] -static Code cvtCodeHaveNeed[numberof_DataType][numberof_DataType] = { +static Code cvtCodeHaveNeed[sizeof_DataType][numberof_DataType] = { { // have Double, need: Null_Code, // Double CvtInt_Code, // Integer @@ -58,11 +58,35 @@ static Code cvtCodeHaveNeed[numberof_DataType][numberof_DataType] = { Null_Code, // String Null_Code // SubStr }, - { // have SubStr, need: + { // have SubStr, need: (FIXME this data will be removed) Invalid_Code, // Double Invalid_Code, // Integer Null_Code, // String Null_Code // SubStr + }, + { // have numberof, need: (will not have any of this data type) + Invalid_Code, // Double + Invalid_Code, // Integer + Invalid_Code, // String + Invalid_Code // SubStr + }, + { // have None, need: (print functions have this data type) + Invalid_Code, // Double + Invalid_Code, // Integer + Invalid_Code, // String + Invalid_Code // SubStr + }, + { // have Number, need: (will not have any of this data type) + Invalid_Code, // Double + Invalid_Code, // Integer + Invalid_Code, // String + Invalid_Code // SubStr + }, + { // have Any, need: (will not have any of this data type) + Invalid_Code, // Double + Invalid_Code, // Integer + Invalid_Code, // String + Invalid_Code // SubStr } }; @@ -809,7 +833,9 @@ TokenStatus Translator::processFinalOperand(Token *&token, Token *token2, // process print-only internal functions // (check for function with no return value) - if (token->isDataType(None_DataType)) + // FIXME hack: check if command stack empty (for new translator) + // FIXME this section needs to be removed + if (token->isDataType(None_DataType) && !m_cmdStack.isEmpty()) { if (m_table.flags(token->code()) & Print_Flag) {