Exemple #1
0
		public static void CreateMachine(Gen cmg, Spec cms, Input cmi)
		{
			MakeNfa.spec = cms;
			MakeNfa.gen = cmg;
			MakeNfa.input = cmi;
			MakeNfa.spec.AddInitialState();
			int count = MakeNfa.spec.States.Count;
			MakeNfa.spec.state_rules = new List<Nfa>[count];
			for (int i = 0; i < count; i++)
			{
				MakeNfa.spec.state_rules[i] = new List<Nfa>();
			}
			MakeNfa.spec.nfa_start = MakeNfa.machine();
			count = MakeNfa.spec.nfa_states.Count;
			for (int i = 0; i < count; i++)
			{
				Nfa nfa = MakeNfa.spec.nfa_states[i];
				nfa.Label = i;
			}
			if (MakeNfa.spec.verbose)
			{
				Console.WriteLine("NFA comprised of " + (MakeNfa.spec.nfa_states.Count + 1) + " states.");
			}
		}
Exemple #2
0
		public static void Main(string[] args)
		{
			try
			{
				if (!Lex.ProcessArguments(args))
				{
					return;
				}
			}
			catch (ApplicationException ex)
			{
				if (Lex.currentOption != null)
				{
					Console.WriteLine("Option '{0}', value '{1}'.", Lex.currentOption, Lex.currentValue);
				}
				Console.WriteLine(ex.Message);
				Console.WriteLine();
				Environment.ExitCode = 1;
			}
			try
			{
				Gen gen = new Gen(Lex.inFile, Lex.outFile, Lex.version);
				gen.Generate();
			}
			catch (ApplicationException ex2)
			{
				Console.WriteLine(ex2.Message);
				Console.WriteLine();
				Environment.ExitCode = 1;
			}
			catch (Exception ex3)
			{
				Console.WriteLine(ex3.Message);
				Console.WriteLine(ex3.StackTrace);
				Environment.ExitCode = 1;
			}
		}