From 71e97bffa276bb70649024bba3a186b1d39f8eb4 Mon Sep 17 00:00:00 2001 From: Thunder422 Date: Sat, 24 Aug 2013 09:36:57 -0400 Subject: [PATCH] removal of old translator - sub-string data type the sub-string data type was only used in the old translator and is no longer needed (the new translator uses the sub-string table entry flag); the AssignSubStr and AssignListMix codes were also removed; the maximum number of associated codes was reduced from 4 to 3; the entries for the sub-string data type was removed from the convert have need table and the expected error status table; various checks for the sub-string data type was removed from the translator support functions --- ibcp.h | 1 - table.cpp | 49 +++++++++--------------------------------------- test/parser2.txt | 2 +- test/parser4.txt | 2 +- test/parser5.txt | 4 ++-- translator.cpp | 27 ++------------------------ 6 files changed, 15 insertions(+), 70 deletions(-) diff --git a/ibcp.h b/ibcp.h index b4f3134..2933702 100644 --- a/ibcp.h +++ b/ibcp.h @@ -55,7 +55,6 @@ enum DataType Double_DataType, Integer_DataType, String_DataType, - SubStr_DataType, // end of the actual execution data types // the following data types are used internally for other uses None_DataType, // indicates none of the above data types diff --git a/table.cpp b/table.cpp index 6572469..3e1669b 100644 --- a/table.cpp +++ b/table.cpp @@ -34,7 +34,7 @@ const int MaxOperands = 3; // (arguments) for any operator or internal function (there are currently // no internal function with more than 3 arguments) -const int MaxAssocCodes = 4; +const int MaxAssocCodes = 3; // this value contains the maximum number of associated codes, // codes in additional to the main code for different possible data types // for the code (no code currently has more the 3 total codes) @@ -46,7 +46,6 @@ static Code cvtCodeHaveNeed[sizeof_DataType][sizeof_DataType] = { Null_Code, // Double CvtInt_Code, // Integer Invalid_Code, // String - Invalid_Code, // SubStr (FIXME this data will be removed) Null_Code, // None Null_Code, // Number Null_Code // Any @@ -55,7 +54,6 @@ static Code cvtCodeHaveNeed[sizeof_DataType][sizeof_DataType] = { CvtDbl_Code, // Double Null_Code, // Integer Invalid_Code, // String - Invalid_Code, // SubStr (FIXME this data will be removed) Null_Code, // None Null_Code, // Number Null_Code // Any @@ -64,16 +62,6 @@ static Code cvtCodeHaveNeed[sizeof_DataType][sizeof_DataType] = { Invalid_Code, // Double Invalid_Code, // Integer Null_Code, // String - Null_Code, // SubStr (FIXME this data will be removed) - Null_Code, // None - Invalid_Code, // Number - Null_Code // Any - }, - { // have SubStr, need: (FIXME this data will be removed) - Invalid_Code, // Double - Invalid_Code, // Integer - Null_Code, // String - Null_Code, // SubStr Null_Code, // None Invalid_Code, // Number Null_Code // Any @@ -82,7 +70,6 @@ static Code cvtCodeHaveNeed[sizeof_DataType][sizeof_DataType] = { Invalid_Code, // Double Invalid_Code, // Integer Invalid_Code, // String - Invalid_Code, // SubStr (FIXME this data will be removed) Null_Code, // None (print function allowed if needed None) Invalid_Code, // Number Invalid_Code // Any @@ -91,7 +78,6 @@ static Code cvtCodeHaveNeed[sizeof_DataType][sizeof_DataType] = { Invalid_Code, // Double Invalid_Code, // Integer Invalid_Code, // String - Invalid_Code, // SubStr (FIXME this data will be removed) Invalid_Code, // None Invalid_Code, // Number Invalid_Code // Any @@ -100,7 +86,6 @@ static Code cvtCodeHaveNeed[sizeof_DataType][sizeof_DataType] = { Invalid_Code, // Double Invalid_Code, // Integer Invalid_Code, // String - Invalid_Code, // SubStr (FIXME this data will be removed) Invalid_Code, // None Invalid_Code, // Number Invalid_Code // Any @@ -201,12 +186,6 @@ static DataType StrStr_OperandArray[] = { static DataType StrStrInt_OperandArray[] = { String_DataType, String_DataType, Integer_DataType }; -static DataType Sub_OperandArray[] = { - SubStr_DataType -}; -static DataType SubStr_OperandArray[] = { - SubStr_DataType, String_DataType -}; // associated code data type arrays @@ -216,11 +195,11 @@ static Code Add_AssocCode[] = { }; static Code AddI1_AssocCode[] = {AddInt_Code}; static Code Assign_AssocCode[] = { - AssignInt_Code, AssignStr_Code, AssignSubStr_Code, AssignList_Code + AssignInt_Code, AssignStr_Code, AssignList_Code }; static Code AssignLeft_AssocCode[] = {AssignKeepLeft_Code}; static Code AssignList_AssocCode[] = { - AssignListInt_Code, AssignListStr_Code, AssignListMix_Code + AssignListInt_Code, AssignListStr_Code }; static Code AssignInt_AssocCode[] = {AssignListInt_Code}; static Code AssignMid2_AssocCode[] = {AssignKeepMid2_Code}; @@ -566,7 +545,7 @@ static TableEntry tableEntries[] = }, { // Left_Code IntFuncP_TokenType, OneWord_Multiple, - "LEFT$(", NULL, SubStr_Flag, 2, SubStr_DataType, + "LEFT$(", NULL, SubStr_Flag, 2, String_DataType, new ExprInfo(Null_Code, Operands(StrInt), AssocCode2(Left, -1)) }, { // Len_Code @@ -576,12 +555,12 @@ static TableEntry tableEntries[] = }, { // Mid2_Code IntFuncP_TokenType, OneWord_Multiple, - "MID$(", "MID2$(", Multiple_Flag | SubStr_Flag, 2, SubStr_DataType, + "MID$(", "MID2$(", Multiple_Flag | SubStr_Flag, 2, String_DataType, new ExprInfo(Null_Code, Operands(StrInt), AssocCode2(Mid2, -1)) }, { // Mid3_Code IntFuncP_TokenType, OneWord_Multiple, - "MID$(", "MID3$(", SubStr_Flag, 2, SubStr_DataType, + "MID$(", "MID3$(", SubStr_Flag, 2, String_DataType, new ExprInfo(Null_Code, Operands(StrIntInt), AssocCode2(Mid3, -1)) }, { // Repeat_Code @@ -591,7 +570,7 @@ static TableEntry tableEntries[] = }, { // Right_Code IntFuncP_TokenType, OneWord_Multiple, - "RIGHT$(", NULL, SubStr_Flag, 2, SubStr_DataType, + "RIGHT$(", NULL, SubStr_Flag, 2, String_DataType, new ExprInfo(Null_Code, Operands(StrInt), AssocCode2(Right, -1)) }, { // Space_Code @@ -737,7 +716,7 @@ static TableEntry tableEntries[] = { // Assign_Code Operator_TokenType, OneWord_Multiple, "=", "Assign", Reference_Flag, 4, Double_DataType, - new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Assign, 3)) + new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Assign, 2)) }, { // AssignInt_Code Operator_TokenType, OneWord_Multiple, @@ -749,11 +728,6 @@ static TableEntry tableEntries[] = "=", "Assign$", Reference_Flag, 4, String_DataType, new ExprInfo(Null_Code, Operands(StrStr), AssocCode2(AssignStr, 1)) }, - { // AssignSubStr_Code - Operator_TokenType, OneWord_Multiple, - "=", "AssignSub$", Reference_Flag, 4, String_DataType, - new ExprInfo(Null_Code, Operands(SubStr)) - }, { // AssignLeft_Code Operator_TokenType, OneWord_Multiple, "LEFT$(", "AssignLeft", Reference_Flag, 4, String_DataType, @@ -777,7 +751,7 @@ static TableEntry tableEntries[] = { // AssignList_Code Operator_TokenType, OneWord_Multiple, "=", "AssignList", Reference_Flag, 4, Double_DataType, - new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(AssignList, 3)) + new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(AssignList, 2)) }, { // AssignListInt_Code Operator_TokenType, OneWord_Multiple, @@ -789,11 +763,6 @@ static TableEntry tableEntries[] = "=", "AssignList$", Reference_Flag, 4, String_DataType, &StrStr_ExprInfo }, - { // AssignListMix_Code - Operator_TokenType, OneWord_Multiple, - "=", "AssignListMix$", Reference_Flag, 4, String_DataType, - new ExprInfo(Null_Code, Operands(SubStr)) - }, { // AssignKeepStr_Code Operator_TokenType, OneWord_Multiple, "=", "AssignKeep$", Reference_Flag, 4, String_DataType, &StrStr_ExprInfo diff --git a/test/parser2.txt b/test/parser2.txt index b8ccca5..cd5f7df 100644 --- a/test/parser2.txt +++ b/test/parser2.txt @@ -48,7 +48,7 @@ Input: LET PRINT end then xor Abs(CHR$(val( end if left$ left$( 32: IntFuncP () Double Val 37: Command Op EndIf 44: NoParen String |left$| - 50: IntFuncP () SubStr Left + 50: IntFuncP () String Left 56: Operator Op None EOL Input: rem this should be a comment diff --git a/test/parser4.txt b/test/parser4.txt index 87d8e15..a57da5d 100644 --- a/test/parser4.txt +++ b/test/parser4.txt @@ -62,7 +62,7 @@ Input: A$ = """ Input: A$ = LEFT$("TEST", 1) 0: NoParen String |A$| 3: Operator Op Integer Eq - 5: IntFuncP () SubStr Left + 5: IntFuncP () String Left 11: Constant String |TEST| 17: Operator Op None Comma 19: Constant Integer 1 |1| diff --git a/test/parser5.txt b/test/parser5.txt index 3e9000d..be0edf9 100644 --- a/test/parser5.txt +++ b/test/parser5.txt @@ -2,7 +2,7 @@ Input: A$ = mid$("b",A+B*2,index)+LEFT$("TEST", 1) 0: NoParen String |A$| 3: Operator Op Integer Eq - 5: IntFuncP () SubStr Mid2 + 5: IntFuncP () String Mid2 10: Constant String |b| 13: Operator Op None Comma 14: NoParen None |A| @@ -14,7 +14,7 @@ Input: A$ = mid$("b",A+B*2,index)+LEFT$("TEST", 1) 20: NoParen None |index| 25: Operator Op None CloseParen 26: Operator Op Double Add - 27: IntFuncP () SubStr Left + 27: IntFuncP () String Left 33: Constant String |TEST| 39: Operator Op None Comma 41: Constant Integer 1 |1| diff --git a/translator.cpp b/translator.cpp index 232add8..3c3913d 100644 --- a/translator.cpp +++ b/translator.cpp @@ -154,12 +154,7 @@ TokenStatus Translator::processFinalOperand(Token *&token, Token *token2, DoneItem::deleteCloseParen(last); last = token2; // last operand is CloseParen token } - // FIXME remove check when sub-string data type removed - if (token->isDataType(SubStr_DataType) && !token->reference()) - { - // change non-reference sub-string function data type to string - token->setDataType(String_DataType); - } + if (token->reference()) { doneAppend = false; // don't append sub-string assignment @@ -317,10 +312,6 @@ TokenStatus Translator::processDoneStackTop(Token *&token, int operandIndex, status = expectedErrStatus(dataType); // sub-string no longer needed with first/last operands } - else if (token->isDataType(SubStr_DataType)) - { - status = ExpStrVar_TokenStatus; - } else { status = variableErrStatus(dataType); @@ -384,8 +375,7 @@ DataType Translator::equivalentDataType(DataType dataType) static DataType equivalent[numberof_DataType] = { Double_DataType, // Double Integer_DataType, // Integer - String_DataType, // String - String_DataType // SubStr + String_DataType // String }; return equivalent[dataType]; @@ -415,12 +405,6 @@ TokenStatus Translator::expectedErrStatus(DataType dataType, ExpStrVar_TokenStatus, // VarDefFn ExpStrItem_TokenStatus // All }, - { // SubStr - ExpStrExpr_TokenStatus, // None - BUG_InvalidDataType, // Variable - BUG_InvalidDataType, // VarDefFn - BUG_InvalidDataType // All - }, { // None ExpExpr_TokenStatus, // None ExpAssignItem_TokenStatus, // Variable @@ -1089,13 +1073,6 @@ TokenStatus Translator::getInternalFunction(Token *&token) break; } - // FIXME this is temporary until old translator removed - // FIXME (SubStr_DataType will be removed) - if (topToken->isDataType(SubStr_DataType)) - { - topToken->setDataType(String_DataType); - } - m_doneStack.drop(); // remove from done stack (remove paren tokens) // add token to output list if not sub-string assignment