Simple assignment expression with integer gets converted to double type
In https://github.com/BlueBrain/nmodl/pull/531 we want to create simple expression like below for the for loop initialisation:
id = 0
Here we expect 0 to be an integer. But currently we get:
{
"BinaryExpression": [
{
"VarName": [
{
"Name": [
{
"String": [
{
"name": "id"
}
]
}
]
}
]
},
{
"BinaryOperator": [
{
"name": "="
}
]
},
{
"Double": [
{
"name": "0"
}
]
}
]
}
Lexer is correctly parsing 0 as integer but parser converts all integer to Double type in:
https://github.com/BlueBrain/nmodl/blob/6e81fe57f6e8008140352921268d3c883541b3f5/src/parser/nmodl.yy#L744
The reason for this is that 1) in nmodl everything is double by default 2) when we have expressions like 1/3, we want to have division with double types
It would be nice if there would be easy to avoid this. (either change in parser logic or some helper to convert type from double to int ?)
https://github.com/BlueBrain/nmodl/pull/778 Fix some of them. Do you think to other cases?