[antlr-interest] invalid char literal: 65535?

Carleton Coffrin Carleton at Coffrin.com
Wed Sep 12 11:34:54 PDT 2007


Thanks for your input Randall.  In ANTLR 2.7 I was using '\uFFFF' to
represent the EOF character.  After doing some more research I found that I
could use the EOF token instead.

Side Note: It would be helpful if this was noted in the "Migrating from
ANTLR 2 to ANTLR 3" wiki.

I did find another interesting point relating to this.  My ANTLR 2.7 rule
was as follows,

CMT: '%' (~( '\n' | '\r' | '\uFFFF' ))* ('\r\n' | '\r' | '\n' | '\uFFFF')

As a terminator the EOF token can be used in place of '\uFFFF' as follows,

('\r\n' |'\r'| '\n'|'\uFFFF') --> ('\r\n' | '\r' | '\n' | EOF)

But in a complement set EOF cannot be used to replace '\uFFFF'.  For example

CMT: '%' (~( '\n' | '\r' | EOF ))*

Yields the following error in ANTLR 3,

Cannot complement rule EOF; not a simple set or element

-Carleton

On 9/11/07, Randall R Schulz <rschulz at sonic.net> wrote:
>
> On Tuesday 11 September 2007 14:17, Carleton Coffrin wrote:
> > In ANTLR 3, when I add the character '\uFFFF' to my lexer I receive
> > the following error message,
> >
> > error(10):  internal error:
> > org.antlr.tool.Grammar.getCharValueFromGrammarCharLiteral(Grammar.jav
> >a:1514): invalid char literal: 65535
> >
> > Any ideas on how I might fix this?
>
> What do you want to fix? That is not a valid Unicode code point.
> According to the tome I have ("The Unicode Standard, version 3.0" by
> the Unicode Consortium):
>
> (page 23)
>
> "* Two codes are not used to encode characters :U+FFFF is for reserved
> internal user (as a sentinel) and should not be transmitted or stored
> as part of plain text. U+FFFE is also reserved; its presence indicates
> byte-swapped Unicode data."
>
>
> > -Carleton
> >
> > Note: '\uFFFF' worked in ANTLR 2.7
>
> Standards conformance improves?
>
>
> Randall Schulz
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070912/1add9104/attachment.html 


More information about the antlr-interest mailing list