コード例 #1
0
ファイル: Input.cs プロジェクト: yonglehou/Bermuda
        public static void Main(string[] args)
        {
            MemoryStream stream = new MemoryStream();
            String saber = new String('c', 4);
            StreamWriter writer = new StreamWriter(stream);
            writer.Write(@"
GET lol, troll, bla WHERE asdsadas lol test FROM:(bla NOT:lol OR (NOT:lolo OR ""lolol lolol"")) asdasd OR asdasd TO:lala OR (FROM:bla TO:(lol OR (BLA AND NOT:bla)) AND (NOT Lol OR BLA))");
            writer.Flush();

            Scanner scanner = new Scanner(stream);
            Parser parser = new Parser(scanner);
            MemoryStream errorStream = new MemoryStream();
            StreamWriter errorWriter = new StreamWriter(errorStream);

            parser.errors.errorStream = errorWriter;
            parser.Parse();
            errorWriter.Flush();
            errorStream.Seek(0, SeekOrigin.Begin);
            saber = new StreamReader(errorStream).ReadToEnd();
            errorStream.Close();
            stream.Close();
            if (parser.errors.count > 0)
            {
                Console.Out.WriteLine(saber);
            }
            else
            {
                PrintTree(parser.RootTree, 0);
            }
            Console.ReadLine();
        }
コード例 #2
0
ファイル: EvoQLExpression.cs プロジェクト: yonglehou/Bermuda
        public EvoQLExpression(string query)
        {
            MemoryStream stream = new MemoryStream();
            String errorString;
            StreamWriter writer = new StreamWriter(stream);
            writer.Write(query);
            writer.Flush();

            Scanner scanner = new Scanner(stream);
            Parser parser = new Parser(scanner);
            MemoryStream errorStream = new MemoryStream();
            StreamWriter errorWriter = new StreamWriter(errorStream);

            parser.errors.errorStream = errorWriter;
            parser.Parse();
            errorWriter.Flush();
            errorStream.Seek(0, SeekOrigin.Begin);
            errorString = new StreamReader(errorStream).ReadToEnd();
            errorStream.Close();
            stream.Close();

            if (parser.errors.count > 0)
            {
                Errors = errorString.Split('\n');
                HadErrors = true;
            }
            else
            {
                Tree = parser.RootTree;
            }
        }