Beispiel #1
0
    public override String VisitLog([NotNull] mathParser.LogContext context)
    {
        //Check if the children are:
        // logw NUM '(' expr ')' this would be logarithm with base
        // logw '(' expr ')' this would be log with base 10
        // logw '(' e ')' this would be log of e

        if (context.ChildCount == 5)
        {
            expression = expression + "System.Math.Log(";
            Visit(context.GetChild(3));
            expression = expression + "," + context.GetChild(1).GetText() + ")";

            return(expression);
        }
        else if (context.GetChild(2).GetText().Equals("e"))
        {
            expression = expression + "System.Math.Log(" + context.GetChild(2).GetText() + ")";

            return(expression);
        }
        else
        {
            expression = expression + "System.Math.Log10(";
            Visit(context.GetChild(2));
            expression = expression + ")";

            return(expression);
        }
    }
 /// <summary>
 /// Visit a parse tree produced by <see cref="mathParser.log"/>.
 /// <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 VisitLog([NotNull] mathParser.LogContext context)
 {
     return(VisitChildren(context));
 }