title: NCalc expression evaluation error for custom function
body: <p>I have an expression which has all calls to all custom functions. </p>
  
  <pre><code>IIF(FVAL(DES_CODE)=1039 OR FVAL(DES_CODE)=1040 OR FVAL(DES_CODE)=1034,0,TBLEVA(PTAX, FVAL(HOPO_GRS)))
  </code></pre>
  
  <p>When trying to evaluate this expression the <code>NCalc</code> engine is producing an error. I'm not able to figure out why. All function declared in the expression has been handled in the <code>EvalFunction</code> event of the expression. Then why is this error arising?</p>
  
  <pre><code>mismatched input 'OR' expecting ')' at line 1:24 missing EOF at 'OR' at line 1:47
  </code></pre>
  
  <p><strong>CODE -</strong></p>
  
  <p>This is where I'm initializing the expression engine.</p>
  
  <pre><code>Dim exp As New Expression(vbCode, EvaluateOptions.IgnoreCase)
  AddHandler exp.EvaluateParameter, AddressOf EvalParameters
  AddHandler exp.EvaluateFunction, AddressOf EvalFunction
  xReturn = Convert.ToDecimal(exp.Evaluate())
  </code></pre>
  
  <p>These are the events for the expression.</p>
  
  <pre><code>Public Sub EvalFunction(ByVal name As String, ByVal args As FunctionArgs)
      Select Case name.ToUpper.Trim
          Case "FVAL"
              Dim xobj = args.EvaluateParameters()
              args.Result = fc.Fval(xobj(0))
          Case "ORIGINALVAL"
              Dim xobj = args.EvaluateParameters()
              args.Result = fc.ORIGINALVAL(xobj(0))
          Case "IIF"
              Dim xobj = args.EvaluateParameters()
              args.Result = fc.IIF(xobj(0), xobj(1), xobj(2))
          Case "LOANDEDUCT"
              Dim xobj = args.EvaluateParameters()
              args.Result = fc.LOANDEDUCT(xobj(0))
          Case "TBLEVA"
              Dim xobj = args.EvaluateParameters()
              args.Result = fc.TBLEVA(xobj(0), xobj(1))
          Case "PERIODMONTH"
              args.Result = fc.PERIODMONTH()
          Case "PERIODSTART"
              args.Result = fc.PERIODSTART()
          Case "AGE"
              Dim xobj = args.EvaluateParameters()
              args.Result = fc.Age(xobj(0))
          Case "INT"
              Dim xobj = args.EvaluateParameters()
              args.Result = fc.Age(xobj(0))
      End Select
  End Sub
  Public Sub EvalParameters(ByVal name As String, ByVal args As ParameterArgs)
      args.Result = name
  End Sub
  </code></pre>