public static string GetName(VBAConditionalCompilationParser.NameContext context)
        {
            string name;
            var    value = context.nameValue();

            if (value.foreignName() != null)
            {
                if (value.foreignName().foreignIdentifier() != null)
                {
                    // Foreign identifiers can be nested, since the meaning of the content can differ depending on the host application,
                    // we simply everything that's inside the brackets as the identifier.
                    name = string.Join("", value.foreignName().foreignIdentifier().Select(id => id.GetText()));
                }
                else
                {
                    // Foreign identifiers can be empty, e.g. "[]".
                    name = string.Empty;
                }
            }
            else
            {
                name = value.GetText();
            }
            return(name);
        }
Exemple #2
0
 private IExpression Visit(VBAConditionalCompilationParser.NameContext context)
 {
     return(new NameExpression(
                new ConstantExpression(new StringValue(Identifier.GetName(context))),
                _symbolTable));
 }
 /// <summary>
 /// Exit a parse tree produced by <see cref="VBAConditionalCompilationParser.name"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitName([NotNull] VBAConditionalCompilationParser.NameContext context)
 {
 }
Exemple #4
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="VBAConditionalCompilationParser.name"/>.
 /// <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 VisitName([NotNull] VBAConditionalCompilationParser.NameContext context)
 {
     return(VisitChildren(context));
 }
Exemple #5
0
 private IExpression Visit(VBAConditionalCompilationParser.NameContext context)
 {
     return(new NameExpression(
                new ConstantExpression(new StringValue(context.IDENTIFIER().GetText())),
                _symbolTable));
 }