Esempio n. 1
0
        public override double VisitCompileUnit(ExcelApplicationParser.CompileUnitContext context)
        {
            string expression = context.GetText();
            var    indexOf    = expression.IndexOf('<');

            if (indexOf > 0)
            {
                expression = expression.Substring(0, indexOf);
            }
            var lParen = expression.Count(x => x == '(');
            var rParen = expression.Count(x => x == ')');

            if (lParen != rParen)
            {
                throw new Exception("Invalid expression");
            }
            return(Visit(context.expression()));
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="ExcelApplicationParser.compileUnit"/>.
 /// <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 VisitCompileUnit([NotNull] ExcelApplicationParser.CompileUnitContext context)
 {
     return(VisitChildren(context));
 }
Esempio n. 3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="ExcelApplicationParser.compileUnit"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCompileUnit([NotNull] ExcelApplicationParser.CompileUnitContext context)
 {
 }
Esempio n. 4
0
 public override double VisitCompileUnit(ExcelApplicationParser.CompileUnitContext context)
 {
     return(Visit(context.expression()));
 }