Skip to content

Conversation

@DavidMoraisFerreira
Copy link
Contributor

Ported @bramp's java implementation (#2048 and #2046) for case insensitive grammars to the CSharp runtime.


if (c <= 0) return c;

var o = Convert.ToChar(c);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use casing instead of Convert methods. It's faster.

char o = (char)c;


var o = Convert.ToChar(c);

if (upper) return Convert.ToInt32(char.ToUpper(o));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an invariant method here: char.ToUpperInvariant(o). Lexer should not depend on users culture.


if (upper) return Convert.ToInt32(char.ToUpper(o));

return Convert.ToInt32(char.ToLower(o));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting: return (int)char.ToLower(o).

{
int c = stream.LA(i);

if (c <= 0) return c;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one-line statement is not used in C# runtime. Please use the following style:

if (c <= 0)
{
    return c;
}

@DavidMoraisFerreira
Copy link
Contributor Author

Thanks for the review @KvanTTT.

@KvanTTT
Copy link
Member

KvanTTT commented Dec 2, 2017

Could you also add runtime tests with chars case changing? See related PR as a sample.

Also, include a test with another culture (Turkish), see this code fragment for example

@DavidMoraisFerreira
Copy link
Contributor Author

@KvanTTT I am not sure about which csproj the tests should be added to, as there don't seem to be any CSharp tests. I'd greatly appreciate some pointers :)

@ericvergnaud
Copy link
Contributor

ericvergnaud commented Dec 3, 2017 via email

@DavidMoraisFerreira
Copy link
Contributor Author

I agree @ericvergnaud. I noticed that this PR didn't make it into #2146. Do I need to make further changes?

@parrt
Copy link
Member

parrt commented Dec 6, 2017

Hi @DavidMoraisFerreira Just added it now so I am closing this one.

@parrt parrt closed this Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants