コード例 #1
0
        public void Visit(FuncCall node)
        {
            var funcName = node.AnchorToken.Lexeme;

            if (FunTable.ContainsKey(funcName))
            {
                var props = FunTable[funcName];
                if (node[0].Size() == props.arity)
                {
                    Visit((dynamic)node[0]);
                }
                else
                {
                    throw new SemanticError(
                              "Function call has incorrect number of arguments: " + funcName,
                              node.AnchorToken);
                }
            }
            else
            {
                throw new SemanticError(
                          "Undefined function: " + funcName,
                          node.AnchorToken);
            }
        }
コード例 #2
0
 public static void Table(FunTable F, double a, double x, double b)
 {
     Console.WriteLine("----- X ----- Y -----");
     while (x <= b)
     {
         Console.WriteLine("| {0,8:0.000} | {1,8:0.000} |", x, F(a, x));
         x += 1;
     }
     Console.WriteLine("---------------------");
 }