-
-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Description
When parsing a construct like "1, 2, 3" and group separators are enabled for numbers, the parser treats a comma as a group separator. Then it does return just a number, but the "separator" itself (not a separator at all) is lost. The problem is in this code of ReadDecimal() in Scanner.cs:
// Number can be empty if we have a decimal separator directly, in this case don't expect group separators
if (!number.IsEmpty && allowGroupSeparator && Cursor.Current == groupSeparator)
{
// Group separators can be repeated as many times
while (true)
{
if (Cursor.Current == groupSeparator)
{
Cursor.AdvanceNoNewLines(1);
}
else
if (!ReadInteger())
{
break;
}
}
}
The solution is to restore the cursor to point at the first "group separator" as follows:
// Number can be empty if we have a decimal separator directly, in this case don't expect group separators
if (!number.IsEmpty && allowGroupSeparator && Cursor.Current == groupSeparator)
{
var savedCursor = Cursor.Position;
// Group separators can be repeated as many times
while (true)
{
if (Cursor.Current == groupSeparator)
{
Cursor.AdvanceNoNewLines(1);
}
else
if (!ReadInteger())
{
// it was not a group separator, really, so go back where the symbol was and stop
Cursor.ResetPosition(savedCursor);
break;
}
}
}
I will create a separate pull request for this fix later.
Metadata
Metadata
Assignees
Labels
No labels