public void TestLexer1() { using (MemoryStream ms = Content.GenerateContent1 ()) { MiniZincLexer scnr = new MiniZincLexer (ms); int index = 0x00; foreach (Token tok in scnr.Tokenize ()) { Assert.AreEqual (Content.Tokens1 [index++], tok); } } }
public void TestLexer1() { using (MemoryStream ms = Content.GenerateContent1()) { MiniZincLexer scnr = new MiniZincLexer(ms); int index = 0x00; foreach (Token tok in scnr.Tokenize()) { Assert.AreEqual(Content.Tokens1 [index++], tok); } } }
/// <summary> /// The entry point of the program, where the program control starts and ends. /// </summary> /// <param name="args">The command-line arguments.</param> /// <returns>The exit code that is given to the operating system after the program ends.</returns> public static int Main (string[] args) { bool show_help = false; ProgramEnvironment env = new ProgramEnvironment (); var p = new OptionSet () { { "t|task=", "The task to be executed (validate-model,validate-data,match,generate-data,generate-heuristics,assume).", env.SetTask }, { "v|verbosity=","The level of verbosity (error,warning,assumption,remark).",env.SetVerbosity }, { "h|help","Show this help message and exit.", x => show_help = x != null } }; List<string> files = new List<string> (); try { files = p.Parse (args); Interaction.VerbosityLevel = env.Verbosity; } catch (OptionException e) { Console.Error.Write ("zincoxide: "); Console.Error.WriteLine (e.Message); Console.Error.WriteLine ("Try 'zincoxide --help' for more information."); return (int)ProgramResult.StaticError; } catch (ZincOxideException e) { Interaction.Error (e.Message); return (int)ProgramResult.StaticError; } if (show_help) { Console.Error.WriteLine ("Usage: zincoxide [Options]+ files"); Console.Error.WriteLine (); Console.Error.WriteLine ("Options: "); p.WriteOptionDescriptions (Console.Error); } else { DirectoryInfo dirInfo = new DirectoryInfo ("."); foreach (string name in files) { FileInfo[] fInfo = dirInfo.GetFiles (name); foreach (FileInfo info in fInfo) { try { using (FileStream file = new FileStream (info.FullName, FileMode.Open)) { MiniZincLexer scnr = new MiniZincLexer (file); MiniZincParser pars = new MiniZincParser (scnr); Interaction.ActiveFile = info.Name; Console.Error.WriteLine ("File: " + info.Name); #if PARSE pars.Parse (); #else foreach (Token tok in scnr.Tokenize()) { Console.Error.Write (tok); Console.Error.Write (' '); } #endif if (pars.Result != null) { Console.Error.WriteLine ("echo: "); pars.Result.Write (Console.Out); } else { Interaction.Warning ("File \"{0}\" is not a valid MiniZinc file."); } } } catch (IOException) { Interaction.Warning ("File \"{0}\" not found.", info.Name); } } } } return (int)ProgramResult.Succes; }
/// <summary> /// The entry point of the program, where the program control starts and ends. /// </summary> /// <param name="args">The command-line arguments.</param> /// <returns>The exit code that is given to the operating system after the program ends.</returns> public static int Main(string[] args) { bool show_help = false; ProgramEnvironment env = new ProgramEnvironment(); var p = new OptionSet() { { "t|task=", "The task to be executed (validate-model,validate-data,match,generate-data,generate-heuristics,assume).", env.SetTask }, { "v|verbosity=", "The level of verbosity (error,warning,assumption,remark).", env.SetVerbosity }, { "h|help", "Show this help message and exit.", x => show_help = x != null } }; List <string> files = new List <string> (); try { files = p.Parse(args); Interaction.VerbosityLevel = env.Verbosity; } catch (OptionException e) { Console.Error.Write("zincoxide: "); Console.Error.WriteLine(e.Message); Console.Error.WriteLine("Try 'zincoxide --help' for more information."); return((int)ProgramResult.StaticError); } catch (ZincOxideException e) { Interaction.Error(e.Message); return((int)ProgramResult.StaticError); } if (show_help) { Console.Error.WriteLine("Usage: zincoxide [Options]+ files"); Console.Error.WriteLine(); Console.Error.WriteLine("Options: "); p.WriteOptionDescriptions(Console.Error); } else { DirectoryInfo dirInfo = new DirectoryInfo("."); foreach (string name in files) { FileInfo[] fInfo = dirInfo.GetFiles(name); foreach (FileInfo info in fInfo) { try { using (FileStream file = new FileStream(info.FullName, FileMode.Open)) { MiniZincLexer scnr = new MiniZincLexer(file); MiniZincParser pars = new MiniZincParser(scnr); Interaction.ActiveFile = info.Name; Console.Error.WriteLine("File: " + info.Name); #if PARSE pars.Parse(); #else foreach (Token tok in scnr.Tokenize()) { Console.Error.Write(tok); Console.Error.Write(' '); } #endif if (pars.Result != null) { Console.Error.WriteLine("echo: "); pars.Result.Write(Console.Out); } else { Interaction.Warning("File \"{0}\" is not a valid MiniZinc file."); } } } catch (IOException) { Interaction.Warning("File \"{0}\" not found.", info.Name); } } } } return((int)ProgramResult.Succes); }