public Instruction(String Code, VariablesManager Variables) { this.Code = Code; this.Variables = Variables; //special treatment for if statements if (Code.Substring(0,2) == "if") { Type = "if"; Length = 0; Dynamic = true; IfConition = Code.Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries)[1]; IfInstruction = new Instruction(Code.Split(new char[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries)[1], Variables); if (Code.Contains("else")) ElseInstruction = new Instruction(Code.Split(new char[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries)[3], Variables); return; } Dynamic = false; Type = Code.Split(new string[] { "->" }, StringSplitOptions.None)[0]; Destinationformula = Code.Split(new string[] { "fill." }, StringSplitOptions.None)[1]; Destination = Destinationformula; foreach (Char c in Arethmitic) Destination = Destination.Split(c)[0]; if (Destinationformula.Contains("(") && Destinationformula.Contains(")")) DestinationConstant = Destinationformula.Split('(')[1].Split(')')[0]; Length = Array.IndexOf(Types, Type); Length = Length < 0 ? Length : Lengths[Length]; if (Type.Contains("@")) { TypeVariable = Type.Split('@')[1]; Type = Type.Split('@')[0]; if (new Regex(@"^\d+$").IsMatch(TypeVariable)) Length = Convert.ToInt32(TypeVariable); else Dynamic = true; } if(Length < 0 && !Dynamic) { //treat as variable TypeVariable = Type; Type = "variable"; Length = 0; } }
public InstructionsManager(String[] Instructions) { this.Instructions = Instructions; Variables = new VariablesManager(this); Header = fetch_section("header").Split(','); Copyright = fetch_section("copyright"); FileName = fetch_section("filename"); ReadData = fetch_sections("-"); WriteData = fetch_sections("$"); InitData = fetch_sections("!"); update_instructions(); }
public Instruction(String Code, VariablesManager Variables) { this.Code = Code; this.Variables = Variables; //special treatment for if statements if (Code.Substring(0, 2) == "if") { Type = "if"; Length = 0; Dynamic = true; IfConition = Code.Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries)[1]; IfInstruction = new Instruction(Code.Split(new char[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries)[1], Variables); if (Code.Contains("else")) { ElseInstruction = new Instruction(Code.Split(new char[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries)[3], Variables); } return; } Dynamic = false; Type = Code.Split(new string[] { "->" }, StringSplitOptions.None)[0]; Destinationformula = Code.Split(new string[] { "fill." }, StringSplitOptions.None)[1]; Destination = Destinationformula; foreach (Char c in Arethmitic) { Destination = Destination.Split(c)[0]; } if (Destinationformula.Contains("(") && Destinationformula.Contains(")")) { DestinationConstant = Destinationformula.Split('(')[1].Split(')')[0]; } Length = Array.IndexOf(Types, Type); Length = Length < 0 ? Length : Lengths[Length]; if (Type.Contains("@")) { TypeVariable = Type.Split('@')[1]; Type = Type.Split('@')[0]; if (new Regex(@"^\d+$").IsMatch(TypeVariable)) { Length = Convert.ToInt32(TypeVariable); } else { Dynamic = true; } } if (Length < 0 && !Dynamic) { //treat as variable TypeVariable = Type; Type = "variable"; Length = 0; } }