From 1d3b0bbb2490fde364d0608c57c64171c30e5a15 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 24 Nov 2006 15:37:29 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/StdAwk.java | 71 +++++++++++++++++++++++++++++++++++++++++-- ase/test/awk/Awk.java | 39 +++--------------------- 2 files changed, 74 insertions(+), 36 deletions(-) diff --git a/ase/awk/StdAwk.java b/ase/awk/StdAwk.java index 005f1746..972d8ec8 100644 --- a/ase/awk/StdAwk.java +++ b/ase/awk/StdAwk.java @@ -1,5 +1,5 @@ /* - * $Id: StdAwk.java,v 1.2 2006-11-24 15:04:23 bacon Exp $ + * $Id: StdAwk.java,v 1.3 2006-11-24 15:37:05 bacon Exp $ */ package ase.awk; @@ -8,6 +8,8 @@ import java.io.*; public abstract class StdAwk extends Awk { + private FileReader insrc; + private String[] cin; private int cin_no; private String[] cout; @@ -17,16 +19,81 @@ public abstract class StdAwk extends Awk { super (); + insrc = null; + cin = getInputConsoleNames (); cout = getOutputConsoleNames (); cin_no = 0; cout_no = 0; } - /* ===== standard console names ===== */ + /* ===== source code names ===== */ + protected abstract String[] getSourceNames (); + protected String getDeparseName () { return null; } + + /* ===== console names ===== */ protected abstract String[] getInputConsoleNames (); protected abstract String[] getOutputConsoleNames (); + /* ===== source code ===== */ + protected int open_source (int mode) + { + if (mode == SOURCE_READ) + { + try { insrc = new FileReader ("t.awk"); } + catch (IOException e) { return -1; } + return 1; + } + else if (mode == SOURCE_WRITE) + { + /* + try { outsrc = new FileWriter ("t.out"); } + catch (IOException e) { return -1; } + return 1; + */ + return 1; + } + + return -1; + } + + protected int close_source (int mode) + { + if (mode == SOURCE_READ) + { + try { insrc.close (); } + catch (IOException e) { return -1; } + return 0; + } + else if (mode == SOURCE_WRITE) + { + /* + try { outsrc.close (); } + catch (IOException e) { return -1; } + return 0; + */ + return 0; + } + + return -1; + } + + protected int read_source (char[] buf, int len) + { + try { return insrc.read (buf, 0, len); } + catch (IOException e) { return -1; } + } + + protected int write_source (char[] buf, int len) + { + /* + try { outsrc.write (buf, 0, len); } + catch (IOException e) { return -1; } + return len; + */ + return len; + } + /* ===== console ===== */ protected int open_console (Extio extio) { diff --git a/ase/test/awk/Awk.java b/ase/test/awk/Awk.java index 34d3f6a9..f2d1a879 100644 --- a/ase/test/awk/Awk.java +++ b/ase/test/awk/Awk.java @@ -1,5 +1,5 @@ /* - * $Id: Awk.java,v 1.7 2006-11-24 13:25:12 bacon Exp $ + * $Id: Awk.java,v 1.8 2006-11-24 15:37:29 bacon Exp $ */ package ase.test.awk; @@ -40,40 +40,11 @@ public class Awk extends ase.awk.StdAwk return cout; } - protected int open_source (int mode) + protected String[] getSourceNames () { - if (mode == SOURCE_READ) - { - try { insrc = new FileReader ("t.awk"); } - catch (IOException e) { return -1; } - return 1; - } - else if (mode == SOURCE_WRITE) - { - try { outsrc = new FileWriter ("t.out"); } - catch (IOException e) { return -1; } - return 1; - } - - return -1; - } - - protected int close_source (int mode) - { - if (mode == SOURCE_READ) - { - try { insrc.close (); } - catch (IOException e) { return -1; } - return 0; - } - else if (mode == SOURCE_WRITE) - { - try { outsrc.close (); } - catch (IOException e) { return -1; } - return 0; - } - - return -1; + String[] cout = new String[1]; + cout[0] = "t.awk"; + return cout; } protected int read_source (char[] buf, int len)