当前位置: 首页>>代码示例>>C#>>正文


C# Runtime.ANTLRInputStream类代码示例

本文整理汇总了C#中Antlr.Runtime.ANTLRInputStream的典型用法代码示例。如果您正苦于以下问题:C# ANTLRInputStream类的具体用法?C# ANTLRInputStream怎么用?C# ANTLRInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ANTLRInputStream类属于Antlr.Runtime命名空间,在下文中一共展示了ANTLRInputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

		static void Main(string[] args)
		{
			int port = 49101;
			string sql = "select * from t1 left join t2";
			MemoryStream ms = new MemoryStream(ASCIIEncoding.ASCII.GetBytes(sql.ToUpper()));
			ANTLRInputStream input = new ANTLRInputStream(ms);
			MySQL51Lexer lexer = new MySQL51Lexer(input);
			// I need a Tree adaptor to build a DebugEventSocketProxy, but I need a 
			// DebugEventSocketProxy to build a Tree Adaptor.
			// Solution: Create the DebugEventSocketProxy 
			//ITreeAdaptor adaptor = new DebugTreeAdaptor(/*dbg*/ null, new CommonTreeAdaptor());
			// To create a DebugTokenStream I need a DebugEventSocketProxy and viceversa
			// Solution: Create DebugEventSocketProxy in the DebugTokenStream contructor
			// How do I get a ITokenStream implementation?
			// Another Caveat: The instance of DebugEventProxySocket must be the same for the lexer than for the parser.

			//DebugEventSocketProxy proxy = new DebugEventSocketProxy(this, port, adaptor);
			DebugTokenStream tokens = new DebugTokenStream( new BufferedTokenStream( lexer ), port, null);
			//CommonTokenStream tokens = new CommonTokenStream(lexer);
			MySQL51Parser parser = new MySQL51Parser(tokens, port, null);
			StringBuilder sb = new StringBuilder();
			TextWriter tw = new StringWriter(sb);
			try
			{
				parser.TraceDestination = tw;
				MySQL51Parser.statement_list_return r = parser.statement_list();
			}
			catch (RecognitionException re)
			{
				Console.WriteLine(re.StackTrace);
			}
		}
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:32,代码来源:Program.cs

示例2: Main

 public static void Main(string[] args)
 {
     Stream inputStream = Console.OpenStandardInput();
     ANTLRInputStream input = new ANTLRInputStream(inputStream);
     CalculatorLexer lexer = new CalculatorLexer(input);
     CommonTokenStream tokens = new CommonTokenStream(lexer);
     CalculatorParser parser = new CalculatorParser(tokens);
     parser.stat();
 }
开发者ID:QAMichaelPeng,项目名称:CoolCompiler,代码行数:9,代码来源:CalculatorMain.cs

示例3: Main

        static void Main(string[] args)
        {
            Stream inputStream = new MemoryStream(Encoding.UTF8.GetBytes(args[0]));

            ANTLRInputStream input = new ANTLRInputStream(inputStream);
            PonishNotationLexer lexer = new PonishNotationLexer(input);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            PonishNotationParser parser = new PonishNotationParser(tokens);
            parser.prog();
        }
开发者ID:isaachan,项目名称:on-the-way,代码行数:10,代码来源:Runner.cs

示例4: test

        private static void test()
        {
            string lexstream = "call foo;";

            MemoryStream ms = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(lexstream));
            ANTLRInputStream ais = new ANTLRInputStream(ms);
            vmexxLexer lexer = new vmexxLexer(ais);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            vmexxParser parser = new vmexxParser(tokens);
            //parser.Program();
            parser.Rule();
        }
开发者ID:donreamey,项目名称:vmeex,代码行数:12,代码来源:Nire.cs

示例5: Main

        static void Main(string[] args)
        {
            using (var stardardInput = Console.OpenStandardInput())
            {
                ANTLRInputStream input = new ANTLRInputStream(stardardInput);
                ExprLexer lexer = new ExprLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lexer);
                ExprParser parser = new ExprParser(tokens);
                parser.prog();
            }

            Console.ReadKey();
        }
开发者ID:adbrowne,项目名称:abcm,代码行数:13,代码来源:Program.cs

示例6: TestSYMMIB_MIB_MIB

 public void TestSYMMIB_MIB_MIB()
 {
     var stream = new ANTLRInputStream(new MemoryStream(Resources.SYMMIB_MIB_MIB));
     var lexer = new SmiLexer(stream);
     var tokens = new CommonTokenStream(lexer);
     var parser = new SmiParser(tokens);
     var document = parser.GetDocument();
     Assert.AreEqual(1, document.Modules.Count);
     Assert.AreEqual("SYMMIB_MIB-MIB", document.Modules[0].Name);
     Assert.AreEqual(117, document.Modules[0].Constructs.Count);
     Assert.AreEqual(98, document.Modules[0].Entities.Count);
     var node = document.Modules[0].Entities[97];
     Assert.AreEqual("disableTrapAtt3", node.Name);
     Assert.AreEqual(3, node.Value);
     Assert.AreEqual("iNTELMIFTOMIBEntry", node.Parent);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:16,代码来源:MibDocumentTestFixture.cs

示例7: TestSNMPv2_SMI

 public void TestSNMPv2_SMI()
 {
     var stream = new ANTLRInputStream(new MemoryStream(Resources.SNMPv2_SMI));
     var lexer = new SmiLexer(stream);
     var tokens = new CommonTokenStream(lexer);
     var parser = new SmiParser(tokens);
     var document = parser.GetDocument();
     Assert.AreEqual(1, document.Modules.Count);
     Assert.AreEqual("SNMPv2-SMI", document.Modules[0].Name);
     Assert.AreEqual(34, document.Modules[0].Constructs.Count);
     Assert.AreEqual(16, document.Modules[0].Entities.Count);
     var node = document.Modules[0].Entities[15];
     Assert.AreEqual("zeroDotZero", node.Name);
     Assert.AreEqual(0, node.Value);
     Assert.AreEqual("ccitt", node.Parent);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:16,代码来源:MibDocumentTestFixture.cs

示例8: Interpreter

 public Interpreter(
     Stream stream,
     TemplateCache cache = null)
 {
     Cache = cache ?? new TemplateCache();
     var charStream = new ANTLRInputStream(stream);
     var lexer = TemplateLexer.Create(charStream);
     var tokenStream = new CommonTokenStream(lexer);
     var parser = new TemplateParser(tokenStream)
     {
         TraceDestination = Console.Out,
         Errors = _parserErrors
     };
     var docResult = parser.document();
     _ast = docResult.Tree;
 }
开发者ID:jeffpanici75,项目名称:FastTemplate,代码行数:16,代码来源:Interpreter.cs

示例9: Parse

 public static Regex Parse(string str, bool caseInsensitive=false)
 {
     using (var s = new MemoryStream())
     using (var wr = new StreamWriter(s))
     {
         wr.Write(str);
         wr.Flush();
         s.Position = 0;
         var input = new ANTLRInputStream(s);
         // Create an ExprLexer that feeds from that stream
         var lexer = new SearchExprLexer(input);
         // Create a stream of tokens fed by the lexer
         var tokens = new CommonTokenStream(lexer);
         // Create a parser that feeds off the token stream
         var parser = new SearchExprParser(tokens);
         return parser.Search(caseInsensitive);
     }
 }
开发者ID:wallymathieu,项目名称:nack,代码行数:18,代码来源:SearchExprParserPartial.cs

示例10: _Main

        private static void _Main(string[] args)
        {
            // input "x = 2*(3+3)"

            ICharStream input;
            if (args.Length > 0)
            {
                if (args[0].Equals("-i"))
                {
                    if (args.Length > 1)
                    {
                        input = new ANTLRFileStream(args[1]);
                    }
                    else
                    {
                        throw new Exception("No input file specified.");
                    }
                }
                else
                {
                    input = new ANTLRStringStream(args[0]);
                }
            }
            else
            {
                input = new ANTLRInputStream(Console.OpenStandardInput());
            }

            var lex = new VecMathLexer(input);
            var tokens = new CommonTokenStream(lex);
            var g = new VecMathParser(tokens);
            IAstRuleReturnScope<CommonTree> r = g.prog();
            CommonTree t = r.Tree;
            Console.WriteLine("Original tree:   " + t.ToStringTree());

            var simplify = new Simplify(new CommonTreeNodeStream(t));
            t = (CommonTree)simplify.Downup(t);

            var reduce = new Reduce(new CommonTreeNodeStream(t));
            t = (CommonTree)reduce.Downup(t);

            Console.WriteLine("Simplified tree: " + t.ToStringTree());
            Console.ReadKey();
        }
开发者ID:biddyweb,项目名称:azfone-ios,代码行数:44,代码来源:Program.cs

示例11: Parse

        /// <summary>
        ///   Переводит строковое представление формулы логики LTL в
        ///   эквивалентный экземпляр <see cref = "LTLFormula" />.
        /// </summary>
        /// <param name = "s">Строка.</param>
        /// <exception cref = "ArgumentNullException"><paramref name = "s" /> является <c>null</c>.</exception>
        /// <exception cref = "ArgumentException"><paramref name = "s" /> не содержит формулу.</exception>
        /// <returns>Формула логики LTL.</returns>
        public static LTLFormula Parse(string s)
        {
            if (s == null)
                throw new ArgumentNullException ("s");

            try {
                using (var memoryStream = new MemoryStream (Encoding.Default.GetBytes (s))) {
                    var stream = new ANTLRInputStream (memoryStream);
                    var parser = new LTLParserParser (new CommonTokenStream (new LTLParserLexer (stream)));
                    var result = parser.start ();

                    if (result == null)
                        throw new ArgumentException ();

                    return result;
                }
            }
            catch (Exception e) {
                throw new ArgumentException (e.Message);
            }
        }
开发者ID:victorsamun,项目名称:NSimulator,代码行数:29,代码来源:LTLFormula.cs

示例12: TestUDP_MIB

 public void TestUDP_MIB()
 {
     var m = new MemoryStream(Resources.UDP_MIB);
     var stream = new ANTLRInputStream(m);
     var lexer = new SmiLexer(stream);
     var tokens = new CommonTokenStream(lexer);
     var parser = new SmiParser(tokens);
     var file = parser.GetDocument();Assert.AreEqual(0, parser.Warnings.Count);
     Assert.AreEqual(1, file.Modules.Count);
     Assert.AreEqual("UDP-MIB", file.Modules[0].Name);
     Assert.AreEqual(31, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[30];
     Assert.AreEqual("udpEndpointGroup", node.Name);
     Assert.AreEqual(4, node.Value);
     Assert.AreEqual("udpMIBGroups", node.Parent);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:16,代码来源:MibDocumentTestFixture.cs

示例13: TestUCD_SNMP_MIB_OLD

 public void TestUCD_SNMP_MIB_OLD()
 {
     var m = new MemoryStream(Resources.UCD_SNMP_MIB_OLD);
     var stream = new ANTLRInputStream(m);
     var lexer = new SmiLexer(stream);
     var tokens = new CommonTokenStream(lexer);
     var parser = new SmiParser(tokens);
     var file = parser.GetDocument();Assert.AreEqual(0, parser.Warnings.Count);
     Assert.AreEqual(1, file.Modules.Count);
     Assert.AreEqual("UCD-SNMP-MIB-OLD", file.Modules[0].Name);
     Assert.AreEqual(35, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[34];
     Assert.AreEqual("loadaveErrMessage", node.Name);
     Assert.AreEqual(101, node.Value);
     Assert.AreEqual("loadaves", node.Parent);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:16,代码来源:MibDocumentTestFixture.cs

示例14: TestUCD_SNMP_MIB

 public void TestUCD_SNMP_MIB()
 {
     var m = new MemoryStream(Resources.UCD_SNMP_MIB1);
     var stream = new ANTLRInputStream(m);
     var lexer = new SmiLexer(stream);
     var tokens = new CommonTokenStream(lexer);
     var parser = new SmiParser(tokens);
     var file = parser.GetDocument();Assert.AreEqual(0, parser.Warnings.Count);
     Assert.AreEqual(1, file.Modules.Count);
     Assert.AreEqual("UCD-SNMP-MIB", file.Modules[0].Name);
     Assert.AreEqual(158, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[157];
     Assert.AreEqual("logMatchRegExCompilation", node.Name);
     Assert.AreEqual(101, node.Value);
     Assert.AreEqual("logMatchEntry", node.Parent);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:16,代码来源:MibDocumentTestFixture.cs

示例15: TestUCD_IPFWACC_MIB

 public void TestUCD_IPFWACC_MIB()
 {
     var m = new MemoryStream(Resources.UCD_IPFWACC_MIB1);
     var stream = new ANTLRInputStream(m);
     var lexer = new SmiLexer(stream);
     var tokens = new CommonTokenStream(lexer);
     var parser = new SmiParser(tokens);
     var file = parser.GetDocument();Assert.AreEqual(0, parser.Warnings.Count);
     Assert.AreEqual(1, file.Modules.Count);
     Assert.AreEqual("UCD-IPFWACC-MIB", file.Modules[0].Name);
     Assert.AreEqual(29, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[28];
     Assert.AreEqual("ipFwAccPort10", node.Name);
     Assert.AreEqual(26, node.Value);
     Assert.AreEqual("ipFwAccEntry", node.Parent);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:16,代码来源:MibDocumentTestFixture.cs


注:本文中的Antlr.Runtime.ANTLRInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。