Indexed node with expression contains `Name` and not `VarName`
While looking at IndexedName node, I noticed that the expression that is used as index created differently from a regular expression. Consider the following program:
PROCEDURE foo() {
LOCAL x[4], i, j
i = 0
j = 1 + i
x[2 + i] = 3
}
Comparing the AST generated for j = 1 + i and x[2 + i]:
{
"BinaryExpression": [
{
"VarName": [
{
"Name": [
{
"String": [
{
"name": "j"
}
]
}
]
}
]
},
{
"BinaryOperator": [
{
"name": "="
}
]
},
{
"WrappedExpression": [
{
"BinaryExpression": [
{
"Double": [
{
"name": "1"
}
]
},
{
"BinaryOperator": [
{
"name": "+"
}
]
},
{
"VarName": [
{
"Name": [
{
"String": [
{
"name": "i"
}
]
}
]
}
]
}
]
}
]
}
]
}
and
{
"IndexedName": [
{
"Name": [
{
"String": [
{
"name": "x"
}
]
}
]
},
{
"WrappedExpression": [
{
"BinaryExpression": [
{
"Integer": [
{
"name": "2"
}
]
},
{
"BinaryOperator": [
{
"name": "+"
}
]
},
{
"Name": [
{
"String": [
{
"name": "i"
}
]
}
]
}
]
}
]
}
]
}
Here, in indexed case, the binary operator has a Name and not VarName node. this creates an ambiguity for code generation.
Maybe we should fix that in the parser level? @pramodk what do you think?
I think this may not be only place where Name and VarName are used interchangeably. We can take a look next week.
We should remove VarName at then and use Identifier (base class of all type).
Related to #903