*** empty log message ***
This commit is contained in:
parent
761968178c
commit
d477a74b7f
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.java,v 1.2 2006-10-24 06:03:14 bacon Exp $
|
||||
* $Id: Awk.java,v 1.3 2006-10-24 06:05:01 bacon Exp $
|
||||
*/
|
||||
|
||||
package ase.awk;
|
||||
@ -19,15 +19,15 @@ public abstract class Awk
|
||||
|
||||
private long __awk;
|
||||
|
||||
public Awk () throws ase.awk.Exception
|
||||
public Awk () throws Exception
|
||||
{
|
||||
open ();
|
||||
}
|
||||
|
||||
public native void close ();
|
||||
public native void parse () throws ase.awk.Exception;
|
||||
public native void run () throws ase.awk.Exception;
|
||||
private native void open () throws ase.awk.Exception;
|
||||
public native void parse () throws Exception;
|
||||
public native void run () throws Exception;
|
||||
private native void open () throws Exception;
|
||||
|
||||
/*
|
||||
protected native void set_extio (long extio, Object obj);
|
||||
|
@ -33,7 +33,7 @@ java:
|
||||
javac -classpath ../.. Awk.java Extio.java Exception.java
|
||||
|
||||
clean:
|
||||
del $(OBJS) $(OUT) *.obj
|
||||
del $(OBJS) $(OUT) *.obj *.class
|
||||
|
||||
.SUFFIXES: .c .obj
|
||||
.c.obj:
|
||||
|
147
ase/test/awk/Awk.java
Normal file
147
ase/test/awk/Awk.java
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* $Id: Awk.java,v 1.1 2006-10-24 06:03:14 bacon Exp $
|
||||
*/
|
||||
|
||||
package ase.test.awk;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class Awk extends ase.awk.Awk
|
||||
{
|
||||
private FileReader insrc;
|
||||
private FileWriter outsrc;
|
||||
|
||||
public Awk () throws ase.awk.Exception
|
||||
{
|
||||
super ();
|
||||
}
|
||||
|
||||
protected int open_source (int mode)
|
||||
{
|
||||
if (mode == SOURCE_READ)
|
||||
{
|
||||
try { insrc = new FileReader ("test.awk"); }
|
||||
catch (IOException e) { return -1; }
|
||||
return 1;
|
||||
}
|
||||
else if (mode == SOURCE_WRITE)
|
||||
{
|
||||
try { outsrc = new FileWriter ("test.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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
protected int open_console ()
|
||||
{
|
||||
System.err.println ("[open_console called....]");
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected int close_console ()
|
||||
{
|
||||
System.err.println ("[close_console called....]");
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected int read_console (char[] buf, int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int write_console (char[] buf, int len)
|
||||
{
|
||||
System.out.print (new String (buf, 0, len));
|
||||
return len;
|
||||
}
|
||||
|
||||
protected int next_console (char[] buf, int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int open_file (ase.awk.Extio extio)
|
||||
{
|
||||
System.out.print ("opening file [");
|
||||
//System.out.print (extio.name());
|
||||
System.out.println ("]");
|
||||
|
||||
/*
|
||||
FileInputStream f = new FileInputStream (extio.name());
|
||||
extio.setHandle (f);
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
public int open_file (String name)
|
||||
{
|
||||
System.out.print ("opening file [");
|
||||
System.out.print (name);
|
||||
System.out.println ("]");
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
public int close_file (String name)
|
||||
{
|
||||
System.out.print ("closing file [");
|
||||
System.out.print (name);
|
||||
System.out.println ("]");
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Awk awk = null;
|
||||
|
||||
try
|
||||
{
|
||||
awk = new Awk ();
|
||||
awk.parse ();
|
||||
awk.run ();
|
||||
}
|
||||
catch (ase.awk.Exception e)
|
||||
{
|
||||
System.out.println ("ase.awk.Exception - " + e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (awk != null) awk.close ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,11 @@ rex2: rex2.obj
|
||||
rex3: rex3.obj
|
||||
link /nologo /out:rex3.exe $(LDFLAGS) $(LIBS) rex3.obj
|
||||
|
||||
java:
|
||||
javac -classpath ../../.. Awk.java
|
||||
|
||||
jrun:
|
||||
java -classpath ../../.. ase.test.awk.Awk
|
||||
|
||||
clean:
|
||||
del $(OBJS) *.obj awk.exe rex.exe
|
||||
|
Loading…
Reference in New Issue
Block a user