2006-10-24 06:06:16 +00:00
|
|
|
/*
|
2007-04-12 10:08:08 +00:00
|
|
|
* $Id: AseAwk.java,v 1.4 2007-04-12 10:08:07 bacon Exp $
|
2006-10-24 06:06:16 +00:00
|
|
|
*/
|
|
|
|
|
2007-04-12 10:08:08 +00:00
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.event.*;
|
2007-01-31 09:31:29 +00:00
|
|
|
|
2007-04-02 11:14:01 +00:00
|
|
|
public class AseAwk extends ase.awk.StdAwk
|
2006-10-24 06:06:16 +00:00
|
|
|
{
|
2007-04-02 11:14:01 +00:00
|
|
|
public AseAwk () throws ase.awk.Exception
|
2006-10-24 06:06:16 +00:00
|
|
|
{
|
|
|
|
super ();
|
2006-11-24 13:25:12 +00:00
|
|
|
}
|
2006-11-22 15:12:04 +00:00
|
|
|
|
2007-01-23 14:23:18 +00:00
|
|
|
protected String[] consoleInputNames ()
|
2006-11-24 13:25:12 +00:00
|
|
|
{
|
|
|
|
String[] cin = new String[3];
|
2006-11-22 15:12:04 +00:00
|
|
|
cin[0] = "c1.txt";
|
|
|
|
cin[1] = "c2.txt";
|
|
|
|
cin[2] = "c3.txt";
|
2006-11-24 13:25:12 +00:00
|
|
|
return cin;
|
|
|
|
}
|
2006-11-22 15:12:04 +00:00
|
|
|
|
2007-01-23 14:23:18 +00:00
|
|
|
protected String[] consoleOutputNames ()
|
2006-11-24 13:25:12 +00:00
|
|
|
{
|
2007-01-21 13:21:14 +00:00
|
|
|
String[] cout = new String[1];
|
|
|
|
cout[0] = "";
|
|
|
|
return cout;
|
|
|
|
/*
|
2006-11-24 13:25:12 +00:00
|
|
|
String[] cout = new String[3];
|
2006-11-23 03:31:58 +00:00
|
|
|
cout[0] = "c4.txt";
|
|
|
|
cout[1] = "c5.txt";
|
|
|
|
cout[2] = "";
|
2006-11-24 13:25:12 +00:00
|
|
|
return cout;
|
2007-01-21 13:21:14 +00:00
|
|
|
*/
|
2006-10-24 06:06:16 +00:00
|
|
|
}
|
|
|
|
|
2007-01-23 14:23:18 +00:00
|
|
|
protected String[] sourceInputNames ()
|
2006-10-24 06:06:16 +00:00
|
|
|
{
|
2007-01-23 14:23:18 +00:00
|
|
|
String[] sin = new String[1];
|
2007-04-06 15:29:45 +00:00
|
|
|
sin[0] = "t.awk";
|
2007-01-23 14:23:18 +00:00
|
|
|
return sin;
|
2006-10-24 06:06:16 +00:00
|
|
|
}
|
|
|
|
|
2006-11-25 15:51:57 +00:00
|
|
|
/*
|
2007-01-23 14:23:18 +00:00
|
|
|
protected String sourceOutputName ()
|
2006-11-25 15:51:57 +00:00
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2006-10-24 06:06:16 +00:00
|
|
|
public static void main (String[] args)
|
|
|
|
{
|
2007-04-12 10:08:08 +00:00
|
|
|
// AWT mode
|
|
|
|
if (args.length == 0)
|
|
|
|
{
|
|
|
|
final Frame frame = new Frame ();
|
|
|
|
|
|
|
|
frame.setLayout (new BorderLayout());
|
|
|
|
frame.setTitle (AseAwk.class.getName());
|
|
|
|
frame.setSize (640, 480);
|
|
|
|
frame.addWindowListener (new WindowListener ()
|
|
|
|
{
|
|
|
|
public void windowActivated (WindowEvent e) {}
|
|
|
|
public void windowClosed (WindowEvent e) {}
|
|
|
|
public void windowClosing (WindowEvent e) { frame.dispose (); }
|
|
|
|
public void windowDeactivated (WindowEvent e) {}
|
|
|
|
public void windowDeiconified (WindowEvent e) {}
|
|
|
|
public void windowIconified (WindowEvent e) {}
|
|
|
|
public void windowOpened (WindowEvent e) {}
|
|
|
|
});
|
2006-10-24 06:06:16 +00:00
|
|
|
|
2007-04-12 10:08:08 +00:00
|
|
|
frame.add (new AseAwkPanel(), BorderLayout.CENTER);
|
|
|
|
frame.setVisible (true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// console mode
|
|
|
|
AseAwk awk = null;
|
2007-04-02 11:14:01 +00:00
|
|
|
|
|
|
|
if (args.length != 1)
|
|
|
|
{
|
2007-04-12 10:08:08 +00:00
|
|
|
|
2007-04-02 11:14:01 +00:00
|
|
|
System.err.println ("Usage: " + AseAwk.class.getName() + " jni");
|
|
|
|
System.err.println ("Where jni := the full path to the jni library");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
System.load (args[0]);
|
|
|
|
}
|
|
|
|
catch (java.lang.UnsatisfiedLinkError e)
|
|
|
|
{
|
|
|
|
System.err.println ("Error: cannot load the library - " + args[0]);
|
|
|
|
return;
|
|
|
|
}
|
2007-01-31 09:31:29 +00:00
|
|
|
|
2006-10-24 06:06:16 +00:00
|
|
|
try
|
|
|
|
{
|
2007-04-02 11:14:01 +00:00
|
|
|
awk = new AseAwk ();
|
|
|
|
awk.setMaxDepth (AseAwk.DEPTH_BLOCK_PARSE, 30);
|
2007-01-25 14:14:56 +00:00
|
|
|
awk.setDebug (true);
|
|
|
|
//awk.setDebug (false);
|
|
|
|
|
|
|
|
//awk.setOption (awk.getOption() | OPTION_STRBASEONE);
|
2007-01-29 04:39:23 +00:00
|
|
|
System.out.println ("Option: [" + awk.getOption() + "]");
|
2007-01-23 14:23:18 +00:00
|
|
|
|
2006-10-24 06:06:16 +00:00
|
|
|
awk.parse ();
|
2007-02-01 07:24:00 +00:00
|
|
|
|
2007-02-23 08:54:03 +00:00
|
|
|
System.out.println ("about to run");
|
2007-02-01 07:24:00 +00:00
|
|
|
String[] aaa = new String[3];
|
|
|
|
aaa[0] = "abcdefg";
|
|
|
|
aaa[1] = "qwerty";
|
|
|
|
aaa[2] = "awk is bad";
|
|
|
|
awk.run ("main", aaa);
|
2006-10-24 06:06:16 +00:00
|
|
|
}
|
|
|
|
catch (ase.awk.Exception e)
|
|
|
|
{
|
2007-01-23 14:23:18 +00:00
|
|
|
if (e.getLine() == 0)
|
|
|
|
{
|
|
|
|
System.out.println ("ase.awk.Exception - " + e.getMessage());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
System.out.println (
|
|
|
|
"ase.awk.Exception at line " +
|
|
|
|
e.getLine() + " - " + e.getMessage());
|
|
|
|
}
|
2006-10-24 06:06:16 +00:00
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
2007-01-23 14:23:18 +00:00
|
|
|
if (awk != null)
|
|
|
|
{
|
|
|
|
awk.close ();
|
|
|
|
awk = null;
|
|
|
|
}
|
2006-10-24 06:06:16 +00:00
|
|
|
}
|
2007-01-23 14:23:18 +00:00
|
|
|
System.out.println ("==== end of awk ====");
|
2006-10-24 06:06:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|