private static bool ComprobarLinea(string texto) { if (texto[texto.Length - 1] == '\r') { texto.Substring(0, texto.Length - 1); } while (texto.Contains(" ")) { texto = texto.Replace(" ", " "); } string[] linea = texto.Trim().Split(' '); string instruccion = string.Empty; if (!UtilidadesInstruccion.esInstruccion(linea[0])) { if (Etiqueta(linea[0])) { for (int i = 1; i < linea.Length; i++) { instruccion += linea[i]; } } else { return(false); } } else { instruccion = texto; } return(Instruccion0(instruccion) || Instruccion2(instruccion) || Instruccion1(instruccion)); }
private static void AñadirEtiqueta(string texto) { if (texto[texto.Length - 1] == '\r') { texto.Substring(0, texto.Length - 1); } while (texto.Contains(" ")) { texto = texto.Replace(" ", " "); } string[] linea = texto.Trim().Split(' '); if (!UtilidadesInstruccion.esInstruccion(linea[0]) && Etiqueta(linea[0])) { etiquetas.Add(linea[0]); } }
public void LeerLinea(string linea, ref ushort posicion) { Instruccion instruccion = null; string[] instruccionArgumentos = UtilidadesInstruccion.ExtraerInstruccionArgumentos(linea); if (UtilidadesInstruccion.esInstruccion(instruccionArgumentos[0])) { instruccion = Instruccion.ConvertirEnInstruccion(instruccionArgumentos); lineas.Add(new string[] { string.Empty, linea }); //-- //lineas2.Add(new EtiquetaInstruccion(string.Empty, linea)); } else { Main.ObtenerMemoria.Etiquetas.Add(new Etiqueta(posicion, instruccionArgumentos[0])); if (instruccionArgumentos.Length <= 0) { throw new ArgumentException(); } string[] _instruccionArgumentos = new string[instruccionArgumentos.Length - 1]; for (int i = 0; i < _instruccionArgumentos.Length; i++) { _instruccionArgumentos[i] = instruccionArgumentos[i + 1]; } instruccion = Instruccion.ConvertirEnInstruccion(_instruccionArgumentos); lineas.Add(new string[] { instruccionArgumentos[0], linea.Substring(instruccionArgumentos[0].Length).TrimStart() }); //lineas2.Add(new EtiquetaInstruccion(instruccionArgumentos[0], linea.Substring(instruccionArgumentos[0].Length).TrimStart())); } switch (instruccion.NumArgumentos) { case 0: posicion++; break; case 1: if (instruccion is IInstruccionSalto) { posicion += 3; } else { if (instruccion.ObtenerArgumento(0).TipoArgumento() == Argumento.Tipo.Literal) { posicion += 2; } else { posicion++; } } break; case 2: if (instruccion.ObtenerArgumento(0).TipoArgumento() == Argumento.Tipo.Literal) { posicion += 2; } else { posicion += 3; } break; } }