Example #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.");
			}
		}
Example #2
0
		public Gen(string filename, string outfile, int version)
		{
			this.init_flag = false;
			this.inputFilePath = Path.GetFullPath(filename);
			this.instream = File.OpenText(this.inputFilePath);
			this.outstream = new IndentedTextWriter(File.CreateText(outfile), "\t");
			this.outstream.Indent = 2;
			this.ibuf = new Input(this.instream);
			this.spec = new Spec();
			this.spec.Version = version;
			this.nfa2dfa = new Nfa2Dfa();
			this.minimize = new Minimize();
			this.makeNfa = new MakeNfa();
			this.emit = new Emit();
			this.init_flag = true;
		}