[Mono-list] (Janet) - JCommand changes

Andrew Stopford andrew_stopford@yahoo.co.uk
Thu, 30 Jan 2003 17:47:56 +0000 (GMT)


--0-846411884-1043948876=:3743
Content-Type: multipart/alternative; boundary="0-1090808928-1043948876=:3743"

--0-1090808928-1043948876=:3743
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


Hi,

I don't have CVS access and I am having trouble creating a patch so can some one commit this file to CVS for me.

Thanks

Andrew




---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs

--0-1090808928-1043948876=:3743
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<P>Hi,</P>
<P>I don't have CVS access and I am having trouble creating a patch so can some one commit this file to CVS for me.</P>
<P>Thanks</P>
<P>Andrew</P><p><p><br><hr size=1><a href="http://uk.yahoo.com/mail/tagline_xtra/?http://uk.docs.yahoo.com/mail_storage.html"><b><font face="Arial" size="2">With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs</font></b></a><br>
--0-1090808928-1043948876=:3743--
--0-846411884-1043948876=:3743
Content-Type: text/plain; name="JCommand.cs"
Content-Description: JCommand.cs
Content-Disposition: inline; filename="JCommand.cs"

// JCompiler.cs: JANET compiler command-line tool
//
// Author: Steve Newman (steve@snewman.net)
//
// Licensed under the terms of the GNU GPL
//
// (C) 2001 Bitcraft, Inc.


#define TRACE

using System;
using System.IO;
using System.Text;
using System.Diagnostics;

using JANET.Printer;
using JANET.Compiler;


// HACK SN 7/14/01: this is a simple test driver, which needs to be replaced
// by a more robust command-line tool.
class MainApp
	{
	public static int Main(string[] args)
		{
		string progClassName;
		string inputFileLabel;
		
		StreamReader r = null;
		bool weBuiltReader = false;
		
		// MOD A Stopford 6/1/2002: Added some basic header text		
		Console.Error.WriteLine("JCommand 1.0.0, the Mono ECMA Script Compiler");		
		
		// HACK A Stopford 6/1/2002: Added an error catch for no command line args
		// Will need to error check what args have been provided
		if (args.Length <= 0) 
		{
			Console.WriteLine("");
			Console.Error.WriteLine("ERROR You must include an ecmascript file");
			Console.WriteLine("");
			Console.Error.WriteLine("Usage is: Jcommand ecmascriptfile.js > csharpfile.cs");
			Console.WriteLine("");
		}
		else {
		

			if (args.Length >= 1)
		{
			inputFileLabel = "\"" + args[0] + "\"";
			FileStream fs = new FileStream(args[0], FileMode.Open, FileAccess.Read);
			r = new StreamReader(fs);
			weBuiltReader = true;
			
			progClassName = "Program_";
			for (int i=0; i<args[0].Length; i++)
			{
				char c = args[0][i];
				if ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
					(c >= '0' && c <= '9') || c == '_' )
					progClassName += c;
				else
					break;
			}
		}
		else
		{
			inputFileLabel = "<stdin>";
			progClassName = "Program";
		}
		
			if (args.Length >= 2)
				progClassName = args[1];
		
			try
			{
				Compiler.CompileToCSharp( r, Console.Out, progClassName,
					inputFileLabel, false );
			}
			catch (ParseError e)
			{
				Console.Error.WriteLine( "ParseError at line {0}, column {1} (byte position {2})",
					e.loc.lineNum, e.loc.colNum, e.loc.absPosition );
				Console.Error.WriteLine( "Message: {0}", e.Message );
			}
		}
		// while (true)
		// 	{
		// 	Token tok = tokenizer.Match();
		// 	if (tok == null)
		// 		break;
		// 	
		// 	Console.WriteLine(tok.rawText);
		// 	} // while (true)
		
		if (weBuiltReader)
			r.Close();
		
		return 0;
		} // Main
	
	} // MainApp

--0-846411884-1043948876=:3743--