I'm trying to write an antlr3 grammar for a small DSL with unicode support (needed for german umlauts, äöüÄÖÜß), but I can't seem to get it to work.
I've written a minimal test grammar that is supposed to match on any sequence of unicode characters, like "xay" (which works just fine) or "xäy" (which doesn't.)
Here's the grammar:
grammar X;
@lexer::header {
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
}
@lexer::members {
public static void main(String[] args) throws Exception {
ANTLRInputStream stream = new ANTLRInputStream( new ByteArrayInputStream("x\u00C4y".getBytes()), "utf-8");
XLexer lex = new XLexer(stream);
CommonTokenStream c = new CommonTokenStream(lex);
XParser p = new XParser(c);
p.x();
}
}
x : UTF8+;
UTF8 : ('\u0000'..'\uF8FF');
For "xäx" I'm getting the following error:
line 1:1 mismatched character '?' expecting set null
What am I missing?
Thanks!