context: //
  // settings.cs: All compiler settings
  //
  // Author: Miguel de Icaza (miguel@ximian.com)
  //            Ravi Pratap  (ravi@ximian.com)
  //            Marek Safar  (marek.safar@gmail.com)
  //
  //
  // Dual licensed under the terms of the MIT X11 or GNU GPL
  //
  // Copyright 2001 Ximian, Inc (http://www.ximian.com)
  // Copyright 2004-2008 Novell, Inc
  // Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
  //
  
  using System.Collections.Generic;
  using System.IO;
  using System.Text;
  using System.Globalization;
  using System;
  
  namespace Mono.CSharp {
  
  	public enum LanguageVersion
  	{
  		ISO_1 = 1,
  		ISO_2 = 2,
  		V_3 = 3,
  		V_4 = 4,
  		V_5 = 5,
  		V_6 = 6,
  		Experimental = 100,
  
  		Default = LanguageVersion.V_6,
  	}
  
  	public enum RuntimeVersion
  	{
  		v1,
  		v2,
  		v4
  	}
  
  	public enum Target
  	{
  		Library, Exe, Module, WinExe
  	}
  
  	public enum Platform
  	{
  		AnyCPU,
  		AnyCPU32Preferred,
  		Arm,
  		X86,
  		X64,
  		IA64
  	}
  
  	public class CompilerSettings
  	{
  		public Target Target;
  		public Platform Platform;
  		public string TargetExt;
  		public bool VerifyClsCompliance;
  		public bool Optimize;
  		public LanguageVersion Version;
  		public bool EnhancedWarnings;
  		public bool LoadDefaultReferences;
  		public string SdkVersion;
  
  		public string StrongNameKeyFile;
  		public string StrongNameKeyContainer;
  		public bool StrongNameDelaySign;
  
  		public int TabSize;
  
  		public bool WarningsAreErrors;
  		public int WarningLevel;
  
  		//
  		// Assemblies references to be loaded
  		//
  		public List<string> AssemblyReferences;
  
  		// 
  		// External aliases for assemblies
  		//
  		public List<Tuple<string, string>> AssemblyReferencesAliases;
  
  		//
  		// Modules to be embedded
  		//
  		public List<string> Modules;
  
  		//
  		// Lookup paths for referenced assemblies
  		//
  		public List<string> ReferencesLookupPaths;
  
  		//
  		// Encoding.
  		//
  		public Encoding Encoding;
  
  		//
  		// If set, enable XML documentation generation
  		//
  		public string DocumentationFile;
  
  		public string MainClass;
  
  		//
  		// Output file
  		//
  		public string OutputFile;
  
  		// 
  		// The default compiler checked state
  		//
  		public bool Checked;
  
  		//
  		// If true, the compiler is operating in statement mode,
  		// this currently turns local variable declaration into
  		// static variables of a class
  		//
  		public bool StatementMode;	// TODO: SUPER UGLY
  		
  		//
  		// Whether to allow Unsafe code
  		//
  		public bool Unsafe;
  
  		public string Win32ResourceFile;
  		public string Win32IconFile;
  
  		//
  		// A list of resource files for embedding
  		//
  		public List<AssemblyResource> Resources;
  
  		public bool GenerateDebugInfo;
  
  		#region Compiler debug flags only
  		public bool ParseOnly, TokenizeOnly, Timestamps;
  		public int DebugFlags;
  		public int VerboseParserFlag;
  		public int FatalCounter;
  		public bool Stacktrace;
  		public bool BreakOnInternalError;
  		#endregion
  
  		public List<string> GetResourceStrings;
  
  		public bool ShowFullPaths;
  
  		//
  		// Whether we are being linked against the standard libraries.
  		// This is only used to tell whether `System.Object' should
  		// have a base class or not.
  		//
  		public bool StdLib;
  
  		public RuntimeVersion StdLibRuntimeVersion;
  
  		public string RuntimeMetadataVersion;
  
  		public bool WriteMetadataOnly;
  
  		readonly List<string> conditional_symbols;
  
  		readonly List<SourceFile> source_files;
  
  		List<int> warnings_as_error;
  		List<int> warnings_only;
  		HashSet<int> warning_ignore_table;
  
  		public CompilerSettings ()
  		{
  			StdLib = true;
  			Target = Target.Exe;
  			TargetExt = ".exe";
  			Platform = Platform.AnyCPU;
  			Version = LanguageVersion.Default;
  			VerifyClsCompliance = true;
  			Encoding = Encoding.UTF8;
  			LoadDefaultReferences = true;
  			StdLibRuntimeVersion = RuntimeVersion.v4;
  			WarningLevel = 4;
  
  			// Default to 1 or mdb files would be platform speficic
  			TabSize = 1;
  
  			AssemblyReferences = new List<string> ();
  			AssemblyReferencesAliases = new List<Tuple<string, string>> ();
  			Modules = new List<string> ();
  			ReferencesLookupPaths = new List<string> ();
  
  			conditional_symbols = new List<string> ();
  			//
  			// Add default mcs define
  			//
  			conditional_symbols.Add ("__MonoCS__");
  
  			source_files = new List<SourceFile> ();
  		}
  
  		#region Properties
  
  		public SourceFile FirstSourceFile {
  			get {
  				return source_files.Count > 0 ? source_files [0] : null;
  			}
  		}
  
  		public bool HasKeyFileOrContainer {
  			get {
  				return StrongNameKeyFile != null || StrongNameKeyContainer != null;
  			}
  		}
  
  		public bool NeedsEntryPoint {
  			get {
  				return Target == Target.Exe || Target == Target.WinExe;
  			}
  		}
  
  		public List<SourceFile> SourceFiles {
  			get {
  				return source_files;
  			}
  		}
  
  		#endregion
  
  		public void AddConditionalSymbol (string symbol)
  		{
  			if (!conditional_symbols.Contains (symbol))
  				conditional_symbols.Add (symbol);
  		}
  
  		public void AddWarningAsError (int id)
  		{
  			if (warnings_as_error == null)
  				warnings_as_error = new List<int> ();
  
  			warnings_as_error.Add (id);
  		}
  
  		public void AddWarningOnly (int id)
  		{
  			if (warnings_only == null)
  				warnings_only = new List<int> ();
  
  			warnings_only.Add (id);
  		}
  
  		public bool IsConditionalSymbolDefined (string symbol)
  		{
  			return conditional_symbols.Contains (symbol);
  		}
  
  		public bool IsWarningAsError (int code)
  		{
  			bool is_error = WarningsAreErrors;
  
  			// Check specific list
  			if (warnings_as_error != null)
  				is_error |= warnings_as_error.Contains (code);
  
  			// Ignore excluded warnings
  			if (warnings_only != null && warnings_only.Contains (code))
  				is_error = false;
  
  			return is_error;
  		}
  
  		public bool IsWarningEnabled (int code, int level)
  		{
  			if (WarningLevel < level)
  				return false;
  
  			return !IsWarningDisabledGlobally (code);
  		}
  
  		public bool IsWarningDisabledGlobally (int code)
  		{
  			return warning_ignore_table != null && warning_ignore_table.Contains (code);
  		}
  
  		public void SetIgnoreWarning (int code)
  		{
  			if (warning_ignore_table == null)
  				warning_ignore_table = new HashSet<int> ();
  
  			warning_ignore_table.Add (code);
  		}
  	}
  
  	public class CommandLineParser
  	{
  		enum ParseResult
  		{
  			Success,
  			Error,
  			Stop,
  			UnknownOption
  		}
  
  		static readonly char[] argument_value_separator = { ';', ',' };
  		static readonly char[] numeric_value_separator = { ';', ',', ' ' };
  
  		readonly TextWriter output;
  		readonly Report report;
  		bool stop_argument;
  
  		Dictionary<string, int> source_file_index;
  
  		public event Func<string[], int, int> UnknownOptionHandler;
  
  		CompilerSettings parser_settings;
  
  		public CommandLineParser (TextWriter errorOutput)
  			: this (errorOutput, Console.Out)
  		{
  		}
  
  		public CommandLineParser (TextWriter errorOutput, TextWriter messagesOutput)
  		{
  			var rp = new StreamReportPrinter (errorOutput);
  
  
gt: 			parser_settings = new CompilerSettings ();