public override object VisitAttr_assignment([NotNull] xmllangParser.Attr_assignmentContext context)
        {
            TypeMap.TryGetValue(context.ATTR().ToString(), out var type);
            var varName = context.ID().ToString();

            if (CurrentVarScope.GetVarValue(varName) != null)
            {
                throw new Exception(VisitorExceptionMessages.VarAlreadyExists);
            }

            // TODO: split to args var
            var attrName  = context.STRING(0).ToString();
            var attrValue = context.STRING(1).ToString();

            CurrentVarScope.CreateVar(varName, type, new XMLAttribute(attrName, attrValue));

            CurrentFunction.Content.Append($"var {varName} = new {type}({attrName}, {attrValue});\n");

            return(VisitChildren(context));
        }
 /// <summary>
 /// Exit a parse tree produced by the <c>attr_assignment</c>
 /// labeled alternative in <see cref="xmllangParser.statement"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitAttr_assignment([NotNull] xmllangParser.Attr_assignmentContext context)
 {
 }
Exemplo n.º 3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>attr_assignment</c>
 /// labeled alternative in <see cref="xmllangParser.statement"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitAttr_assignment([NotNull] xmllangParser.Attr_assignmentContext context)
 {
     return(VisitChildren(context));
 }