2006-10-24 06:06:16 +00:00
|
|
|
/*
|
2006-11-29 14:52:36 +00:00
|
|
|
* $Id: Awk.java,v 1.17 2006-11-29 14:52:36 bacon Exp $
|
2006-10-24 06:06:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package ase.test.awk;
|
|
|
|
|
2006-11-24 13:25:12 +00:00
|
|
|
public class Awk extends ase.awk.StdAwk
|
2006-10-24 06:06:16 +00:00
|
|
|
{
|
|
|
|
public Awk () throws ase.awk.Exception
|
|
|
|
{
|
|
|
|
super ();
|
2006-11-27 04:33:22 +00:00
|
|
|
|
2006-11-29 14:52:36 +00:00
|
|
|
addBuiltinFunction ("sin", 1, 10);
|
|
|
|
addBuiltinFunction ("xxx", 1, 1);
|
|
|
|
//addBuiltinFunction ("xxx", 1, 1);
|
|
|
|
|
|
|
|
//deleteBuiltinFunction ("sin");
|
|
|
|
//deleteBuiltinFunction ("sin");
|
2006-11-27 04:33:22 +00:00
|
|
|
}
|
|
|
|
|
2006-11-28 15:09:53 +00:00
|
|
|
public Object xxx (Object[] args)
|
2006-11-27 04:33:22 +00:00
|
|
|
{
|
2006-11-28 15:09:53 +00:00
|
|
|
System.out.println ("BFN_XXX");
|
|
|
|
return null;
|
|
|
|
}
|
2006-11-29 14:52:36 +00:00
|
|
|
|
2006-11-28 15:09:53 +00:00
|
|
|
public Object sin (Object[] args)
|
|
|
|
{
|
2006-11-29 11:41:15 +00:00
|
|
|
System.out.println ("<<BFN_SIN>>");
|
|
|
|
for (int i = 0; i < args.length; i++)
|
|
|
|
{
|
|
|
|
System.out.print ("ARG #" + i);
|
|
|
|
System.out.print (": ");
|
|
|
|
if (args[i] == null) System.out.println ("nil");
|
|
|
|
else System.out.println (args[i].toString());
|
|
|
|
}
|
|
|
|
return null;
|
2006-11-29 14:52:36 +00:00
|
|
|
//return new String ("return value");
|
|
|
|
//return new Double (1.234);
|
|
|
|
//return new Float (1.234);
|
|
|
|
//return new Integer (1001);
|
|
|
|
//return new Long (1001);
|
|
|
|
//return new Short ((short)1001);
|
2006-11-24 13:25:12 +00:00
|
|
|
}
|
2006-11-22 15:12:04 +00:00
|
|
|
|
2006-11-24 13:25:12 +00:00
|
|
|
protected String[] getInputConsoleNames ()
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2006-11-24 13:25:12 +00:00
|
|
|
protected String[] getOutputConsoleNames ()
|
|
|
|
{
|
|
|
|
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;
|
2006-10-24 06:06:16 +00:00
|
|
|
}
|
|
|
|
|
2006-11-24 15:37:29 +00:00
|
|
|
protected String[] getSourceNames ()
|
2006-10-24 06:06:16 +00:00
|
|
|
{
|
2006-11-24 15:37:29 +00:00
|
|
|
String[] cout = new String[1];
|
|
|
|
cout[0] = "t.awk";
|
|
|
|
return cout;
|
2006-10-24 06:06:16 +00:00
|
|
|
}
|
|
|
|
|
2006-11-25 15:51:57 +00:00
|
|
|
/*
|
|
|
|
protected String getDeparsedSourceName ()
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
*/
|
2006-11-26 16:17:51 +00:00
|
|
|
protected int getMaxParseDepth ()
|
|
|
|
{
|
|
|
|
return 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int getMaxRunDepth ()
|
|
|
|
{
|
|
|
|
return 50;
|
|
|
|
}
|
2006-11-25 15:51:57 +00:00
|
|
|
|
2006-10-24 06:06:16 +00:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|