From bde2429d8dd52b809895894ab65f396bfb5a55c9 Mon Sep 17 00:00:00 2001 From: Minero Aoki Date: Sun, 20 Jan 2008 17:51:06 +0000 Subject: [PATCH] * 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 --- ChangeLog | 6 ++++++ net/loveruby/cflat/parser/Parser.jj | 17 ++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9285778..ffe70ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jan 21 02:51:02 2008 Minero Aoki + + * 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 * net/loveruby/cflat/parser/Parser.jj: refactoring: reorder member diff --git a/net/loveruby/cflat/parser/Parser.jj b/net/loveruby/cflat/parser/Parser.jj index c0a9041..3033fad 100644 --- a/net/loveruby/cflat/parser/Parser.jj +++ b/net/loveruby/cflat/parser/Parser.jj @@ -1,8 +1,10 @@ +// #@@range/options{ options { STATIC = false; DEBUG_PARSER = true; UNICODE_INPUT = true; } +// #@@} PARSER_BEGIN(Parser) package net.loveruby.cflat.parser; @@ -19,7 +21,7 @@ public class Parser { static public AST parseFile(File file, LibraryLoader loader, ErrorHandler errorHandler) throws SyntaxException, FileException { - return newFileParser(file, loader, errorHandler, false).parse(); + return parseFile(file, loader, errorHandler, false); } // #@@range/parseFile{ @@ -35,7 +37,7 @@ public class Parser { ErrorHandler errorHandler) throws SyntaxException, FileException { - return newFileParser(file, loader, errorHandler, false).parseDecls(); + return parseDeclFile(file, loader, errorHandler, false); } static public Declarations parseDeclFile(File file, @@ -61,19 +63,20 @@ public class Parser { catch (FileNotFoundException ex) { throw new FileException(ex.getMessage()); } - catch (UnsupportedEncodingException ex) { - throw new FileException(ex.getMessage()); - } } // #@@} // #@@range/newReader{ static final protected String sourceEncoding = "UTF-8"; - static protected Reader newReader(InputStream s) - throws UnsupportedEncodingException { + static protected Reader newReader(InputStream s) { + try { InputStreamReader r = new InputStreamReader(s, sourceEncoding); return new BufferedReader(r); + } + catch (UnsupportedEncodingException ex) { + throw new Error("must not happen: " + ex.getMessage()); + } } // #@@}