* net/loveruby/cflat/parser/Parser.jj: produce Error for UnknownEncodingError. Current Java runtime must know UTF-8 encoding.

git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3854 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2008-01-20 17:51:06 +00:00
parent 067629484c
commit bde2429d8d
2 changed files with 16 additions and 7 deletions

View File

@ -1,3 +1,9 @@
Mon Jan 21 02:51:02 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/parser/Parser.jj: produce Error for
UnknownEncodingError. Current Java runtime must know UTF-8
encoding.
Mon Jan 21 01:58:57 2008 Minero Aoki <aamine@loveruby.net> Mon Jan 21 01:58:57 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/parser/Parser.jj: refactoring: reorder member * net/loveruby/cflat/parser/Parser.jj: refactoring: reorder member

View File

@ -1,8 +1,10 @@
// #@@range/options{
options { options {
STATIC = false; STATIC = false;
DEBUG_PARSER = true; DEBUG_PARSER = true;
UNICODE_INPUT = true; UNICODE_INPUT = true;
} }
// #@@}
PARSER_BEGIN(Parser) PARSER_BEGIN(Parser)
package net.loveruby.cflat.parser; package net.loveruby.cflat.parser;
@ -19,7 +21,7 @@ public class Parser {
static public AST parseFile(File file, LibraryLoader loader, static public AST parseFile(File file, LibraryLoader loader,
ErrorHandler errorHandler) ErrorHandler errorHandler)
throws SyntaxException, FileException { throws SyntaxException, FileException {
return newFileParser(file, loader, errorHandler, false).parse(); return parseFile(file, loader, errorHandler, false);
} }
// #@@range/parseFile{ // #@@range/parseFile{
@ -35,7 +37,7 @@ public class Parser {
ErrorHandler errorHandler) ErrorHandler errorHandler)
throws SyntaxException, throws SyntaxException,
FileException { FileException {
return newFileParser(file, loader, errorHandler, false).parseDecls(); return parseDeclFile(file, loader, errorHandler, false);
} }
static public Declarations parseDeclFile(File file, static public Declarations parseDeclFile(File file,
@ -61,19 +63,20 @@ public class Parser {
catch (FileNotFoundException ex) { catch (FileNotFoundException ex) {
throw new FileException(ex.getMessage()); throw new FileException(ex.getMessage());
} }
catch (UnsupportedEncodingException ex) {
throw new FileException(ex.getMessage());
}
} }
// #@@} // #@@}
// #@@range/newReader{ // #@@range/newReader{
static final protected String sourceEncoding = "UTF-8"; static final protected String sourceEncoding = "UTF-8";
static protected Reader newReader(InputStream s) static protected Reader newReader(InputStream s) {
throws UnsupportedEncodingException { try {
InputStreamReader r = new InputStreamReader(s, sourceEncoding); InputStreamReader r = new InputStreamReader(s, sourceEncoding);
return new BufferedReader(r); return new BufferedReader(r);
}
catch (UnsupportedEncodingException ex) {
throw new Error("must not happen: " + ex.getMessage());
}
} }
// #@@} // #@@}