/// <summary> /// Ejecuta las sentencias IfDefined /// </summary> private string CallCheckDefined(InstructionIfDefined instruction, string tagParent) { string result = ""; // Comprueba si está definida la variable if (instruction != null) { string value = Program.SymbolsTable.Variables.Search(instruction.Identifier).Value.Content; if (!value.IsEmpty() && !value.EqualsIgnoreCase("null") && value != "") { // Obtiene el contenido de las líneas hija foreach (InstructionBase objLine in instruction.SentencesIf) { if (objLine is InstructionLineCss) { result += GetTagsCss(Program, objLine as InstructionLineCss) + ";"; } else { result += GetCss(Program, objLine, tagParent); } } } } // Devuelve el resultado return(result); }
/// <summary> /// Crea una instrucción IfDefined /// </summary> private InstructionBase CreateInstructionIfDefined() { InstructionIfDefined instruction = new InstructionIfDefined(GetToken()); TokenSmallCss token = GetToken(); // Obtiene la variable if (token.Row == instruction.Token.Row && (token.TypeCss == TokenSmallCss.TokenCssType.Literal || token.TypeCss == TokenSmallCss.TokenCssType.Variable)) { // Asigna el nombre de la variable instruction.Identifier = token.Value; // Obtiene las instrucciones if (CheckIsBlock(instruction.Token)) { instruction.SentencesIf.AddRange(GetBlock(instruction.Token.Indent)); } else { instruction.Error = ParseError("No se han definido las instrucciones de la función"); } } else { instruction.Error = ParseError("No se encuentra la definición de variable"); } // Devuelve la instrucción return(instruction); }