Skip to content

Commit

Permalink
added new variable or defined function reference type
Browse files Browse the repository at this point in the history
this is needed to distinguish between when only a variable is allowed
(INPUT and READ), or when a variable or a defined function is allowed
(a sub-string assignment) or when all including a sub-string assignment
is allowed (an assignment)

getOperand() modified to look for this new type for DefFuncN and
DefFuncP token types; getInternalFunction() modified to use the new
reference type; and added appropriate errors for new reference type in
expectedErrStatus()
  • Loading branch information
thunder422 committed Aug 17, 2013
1 parent b670ab3 commit a79f117
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 18 additions & 3 deletions translator.cpp
Expand Up @@ -1490,36 +1490,43 @@ TokenStatus Translator::expectedErrStatus(DataType dataType,
{ // Double
ExpNumExpr_TokenStatus, // None
ExpDblVar_TokenStatus, // Variable
ExpDblVar_TokenStatus, // VarDefFn
ExpDblVar_TokenStatus // All
},
{ // Integer
ExpNumExpr_TokenStatus, // None
ExpIntVar_TokenStatus, // Variable
ExpIntVar_TokenStatus, // VarDefFn
ExpIntVar_TokenStatus // All
},
{ // String
ExpStrExpr_TokenStatus, // None
ExpStrVar_TokenStatus, // Variable
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
ExpAssignItem_TokenStatus, // VarDefFn
ExpAssignItem_TokenStatus // All
},
{ // Number
ExpNumExpr_TokenStatus, // None
BUG_InvalidDataType, // Variable
BUG_InvalidDataType, // VarDefFn
BUG_InvalidDataType // All
},
{ // Any
ExpExpr_TokenStatus, // None
ExpAssignItem_TokenStatus, // Variable
ExpVar_TokenStatus, // Variable
ExpAssignItem_TokenStatus, // VarDefFn
ExpAssignItem_TokenStatus // All
}
};
Expand Down Expand Up @@ -2085,6 +2092,10 @@ TokenStatus Translator::getOperand(Token *&token, DataType dataType,
return expectedErrStatus(dataType, reference);
}
case DefFuncN_TokenType:
if (reference == Variable_Reference)
{
return expectedErrStatus(dataType, reference);
}
// fall thru
case NoParen_TokenType:
if (reference != None_Reference)
Expand Down Expand Up @@ -2121,7 +2132,11 @@ TokenStatus Translator::getOperand(Token *&token, DataType dataType,
break;

case DefFuncP_TokenType:
if (reference != None_Reference)
if (reference == Variable_Reference)
{
return expectedErrStatus(dataType, reference);
}
else if (reference != None_Reference)
{
// NOTE these are allowed in the DEF command
// just point to the open parentheses of the token
Expand Down Expand Up @@ -2189,7 +2204,7 @@ TokenStatus Translator::getInternalFunction(Token *&token)
{
// sub-string assignment, look for reference operand
expectedDataType = String_DataType;
status = getOperand(token, expectedDataType, Variable_Reference);
status = getOperand(token, expectedDataType, VarDefFn_Reference);
if (status == Good_TokenStatus)
{
if ((status = getToken(token)) == Good_TokenStatus)
Expand Down
1 change: 1 addition & 0 deletions translator.h
Expand Up @@ -127,6 +127,7 @@ class Translator
enum Reference {
None_Reference,
Variable_Reference,
VarDefFn_Reference,
All_Reference,
sizeof_Reference
};
Expand Down

0 comments on commit a79f117

Please sign in to comment.