PositiveTechnologies/PT.PM

Fix ambiguity representation of char

Closed this issue · 1 comments

Consider the following lines of code:

obj.f1 = 'c';
obj.f2 = "'c'";

Each of lines gives the same UST:

"Right": {
  "NodeType": "StringLiteral",
  "Text": "'c'"
}

I suggest adding 'IsChar' field to StringLiteral class.
Then resulting UST should include the following nodes:

"Right": {
  "NodeType": "StringLiteral",
  "Text": "c",
  "IsChar": true
}
and
"Right": {
  "NodeType": "StringLiteral",
  "Text": "'c'",
  "IsChar": false
}

I don't like the idea of IsChar field because of the char is a separated type that is not used in PT.PM for now. I suggest the following solutions:

  • Add a new CharLiteral that will contain a single char.
  • Fix converter for returning different UST for the first and second cases (c and 'c' respectively).