/// <summary> /// Interpret an Markup /// </summary> /// <param name="markup">Markup to interpret</param> public override void Visit(Markup markup) { if (IsCall(markup)) { //We are calling a function FunctionDefinition functionDefinition = SymbolTable.GetFunctionDefinition(markup.GetDesignator().GetIdentifier()); //Create SymbolTable for specific function SymbolTable tempSymbolTable = SymbolTable; SymbolTable = new SymbolTable(GetSymbolTableOfFunction(functionDefinition)); //Store arguments in SymbolTable as variables int index = 0; NodeList arguments = markup.GetArguments(); foreach (Formal formal in functionDefinition.GetFormals()) { Expression expr = null; if (arguments.Count > index) { Argument arg = (Argument)arguments.Get(index); expr = arg.GetExpression(); } SymbolTable.AddVariableDefinition(formal.GetIdentifier(), expr); index++; } //Visit functiondefinition functionDefinition.AcceptVisitor(this); //Go back to parent SymbolTable SymbolTable = tempSymbolTable; } else { //Dealing with an Tag String tag = markup.GetDesignator().GetIdentifier(); //Write tag with retrieved attributes AddElement(new XHTMLElement(tag, Current)); //Visit the attributes foreach (Parser.Ast.Markup.Attribute attribute in markup.GetDesignator().GetAttributes()) { attribute.AcceptVisitor(this); } //Interpret arguments also as attributes String attributeValue = ""; foreach (Argument argument in markup.GetArguments()) { if (argument is AttrArgument) { //Interpret expression to retrieve value ((AttrArgument)argument).GetExpression().AcceptVisitor(this); //Store attribute String attr = ((AttrArgument)argument).GetIdentifier(); Current.AddAttribute(attr, TextValue); } else if (argument is ExpressionArgument) { //Interpret expression ((ExpressionArgument)argument).GetExpression().AcceptVisitor(this); if (TextValue == "undef") { TextValue = "UNDEFINED"; } //Store value if (!(attributeValue == "") && !(TextValue != "")) { attributeValue += " "; } attributeValue += TextValue; } } if (attributeValue != "") { //Add value attribute Current.AddAttribute("value", attributeValue); } } }