Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ANTLR failing parsing of java file on accented character

 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using ANTLR parser 2.7.5 and it fails when I have accented characters in the file.

e.g.


The error I get is,
parser exception: Test1.java:17:33: unexpected char: '''

If I remove the accented characters from the file then it works fine so I believe its these characters causing the problem.

Does anybody have any idea about how to resolve this issue?

I tried google but not much of help so far..

Regards
Maulin
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "native2ascii" program in the JDK will translate 8-bit Java to 7-bit ASCII Java by turning those accented characters into \uxxxx escapes. You could run the code through that first.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest

Thanks a lot, I will try and let you know the outcome..

Regards
Maulin
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,

It works! Thanks.

Does this mean that developers should use this unicode things while writing the code to avoid this possible issue (so somebody else who wants to parse these files, doesn't have to use native2ascii)?

Also this solution is not really very feasible to me as I process too many files programatically and if I have to use native2ascii for each file before processing (though I would use cache once I convert but still..) it would be too much long processing. I will need to see if I can do something in ANTLR generated code for this if I can..

Regards,
Maulin
[ July 05, 2005: Message edited by: Maulin Vasavada ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic