CharLiteral with unicode value

Mar 6, 2014 at 7:54 PM
Edited Mar 6, 2014 at 7:54 PM
I am trying to update the C# grammar to the 4.0 syntax, and I am getting an error when Irony parses the C# grammar file when it is hitting line:
case '\u2085':
in the SkipWhitespace override method. I see when the code creating the char literal, is going through some 'TerminalFactory'.

How can I add support to the CharLiteral object for unicode characters?

Mar 7, 2014 at 6:00 AM
can you pls provide more details? inside this 'case' is just 'source.PreviewPosition++' - how this can fail? can you share your grammar?
Mar 7, 2014 at 12:15 PM
Edited Mar 7, 2014 at 12:16 PM
Sorry, I suppose I do know a bit more about the problem then I was giving you.
The problem was not with parsing the code after the case, it was with parsing the char '\u2085'. When the parser got to that position it was throwing an error about an invalid char, only expecting it to be one character.
I fixed the problem though, instead of creating the CharLiteral object from:
TerminalFactory.CreateCSharpChar ("CharLiteral")
I used the following code, and it seems to work fine:
new StringLiteral ("CharLiteral", "'", StringOptions.AllowsUEscapes);
Thanks for the quick reply though.
Mar 8, 2014 at 4:40 AM
one more question, please. It appears that 'standard' c# char literal from TerminalFactory did not work for you. This might be some bug. Can you please share some details (what was input that failed), so I can spot the problem and fix it?
Mar 10, 2014 at 12:58 PM

I have updated the CSharpGrammar to what you will find at the link below:

This updated version has the changes I mentioned above, but in order to catch the error you will need to revert lines 47 and 48 back to using the 'TerminalFactory'.
I then feed that exact file to the parser that has the same grammar above loaded. You will then see the error about the invalid char representation.

I hope this helps!