コード例 #1
0
ファイル: Program.cs プロジェクト: kpaskal/cassandra-sharp
        private static bool ExecuteCommand(string cmd)
        {
            try
            {
                Scanner scanner = new Scanner();
                Parser.Parser parser = new Parser.Parser(scanner);
                ParseTree parseTree = parser.Parse(cmd);
                if (0 < parseTree.Errors.Count)
                {
                    Console.WriteLine(parseTree.Errors[0].Message);
                    return false;
                }

                object result = parseTree.Eval(null);
                ICommand command = (ICommand) result;

                CommandContext.ResultWriter = GetResultWriter();
                command.Execute();
                return true;
            }
            catch (Exception ex)
            {
                if (CommandContext.DebugLog)
                {
                    Console.WriteLine("Command execution failed with error:\n{0}", ex);
                }
                else
                {
                    while (null != ex.InnerException)
                    {
                        ex = ex.InnerException;
                    }

                    Console.WriteLine("Command execution failed with error '{0}'", ex.Message);
                }

                return false;
            }
            finally
            {
                Console.WriteLine();
            }
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: kpaskal/cassandra-sharp
 public Parser(Scanner scanner)
 {
     this.scanner = scanner;
 }