コード例 #1
0
ファイル: Program.cs プロジェクト: Top-Cat/SteamBot
		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);
			}
		}
コード例 #2
0
 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();
 }
コード例 #3
0
ファイル: Runner.cs プロジェクト: isaachan/on-the-way
        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();
        }
コード例 #4
0
 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);
     var tree = parser.stat().Tree;
     Console.WriteLine(tree.ToStringTree());
     DumpTree(tree, "", "  ");
 }
コード例 #5
0
ファイル: Nire.cs プロジェクト: donreamey/vmeex
        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();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: adbrowne/abcm
        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();
        }
コード例 #7
0
 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);
 }
コード例 #8
0
 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);
 }
コード例 #9
0
 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;
 }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: biddyweb/azfone-ios
        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();
        }
コード例 #12
0
 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);
 }
コード例 #13
0
 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);
 }
コード例 #14
0
 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);
 }
コード例 #15
0
 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);
 }
コード例 #16
0
 public void TestUCD_DLMOD_MIB()
 {
     var m = new MemoryStream(Resources.UCD_DLMOD_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-DLMOD-MIB", file.Modules[0].Name);
     Assert.AreEqual(9, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[8];
     Assert.AreEqual("dlmodStatus", node.Name);
     Assert.AreEqual(5, node.Value);
     Assert.AreEqual("dlmodEntry", node.Parent);
 }
コード例 #17
0
 public void TestUCD_DISKIO_MIB()
 {
     var m = new MemoryStream(Resources.UCD_DISKIO_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-DISKIO-MIB", file.Modules[0].Name);
     Assert.AreEqual(14, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[13];
     Assert.AreEqual("diskIONWrittenX", node.Name);
     Assert.AreEqual(13, node.Value);
     Assert.AreEqual("diskIOEntry", node.Parent);
 }
コード例 #18
0
 public void TestRFC1271_MIB()
 {
     var m = new MemoryStream(Resources.RFC1271_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("RFC1271-MIB", file.Modules[0].Name);
     Assert.AreEqual(213, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[212];
     Assert.AreEqual("logDescription", node.Name);
     Assert.AreEqual(4, node.Value);
     Assert.AreEqual("logEntry", node.Parent);
 }
コード例 #19
0
ファイル: LTLFormula.cs プロジェクト: victorsamun/NSimulator
        /// <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);
            }
        }
コード例 #20
0
 public static JsonObject Parse(Stream stream)
 {
    var inputStream = new ANTLRInputStream(stream);
    return ParseANTLRStream(inputStream);
 }
コード例 #21
0
 public void TestSMUX_MIB()
 {
     var m = new MemoryStream(Resources.SMUX_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("SMUX-MIB", file.Modules[0].Name);
     Assert.AreEqual(14, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[13];
     Assert.AreEqual("smuxTstatus", node.Name);
     Assert.AreEqual(4, node.Value);
     Assert.AreEqual("smuxTreeEntry", node.Parent);
 }
コード例 #22
0
 public void TestRMON_MIB()
 {
     var m = new MemoryStream(Resources.RMON_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("RMON-MIB", file.Modules[0].Name);
     Assert.AreEqual(232, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[231];
     Assert.AreEqual("rmonNotificationGroup", node.Name);
     Assert.AreEqual(11, node.Value);
     Assert.AreEqual("rmonGroups", node.Parent);
 }
コード例 #23
0
 public void TestRFC_1215()
 {
     var m = new MemoryStream(Resources.RFC_1215);
     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("RFC-1215", file.Modules[0].Name);
     Assert.AreEqual(0, file.Modules[0].Entities.Count);
 }
コード例 #24
0
 public void TestRFC1213_MIB2()
 {
     var m = new MemoryStream(Resources.RFC1213_MIB);
     var stream = new ANTLRInputStream(m);
     var lexer = new SmiLexer(stream);
     var tokens = new CommonTokenStream(lexer);
     var parser = new SmiParser(tokens);
     var exception = Assert.Throws<MismatchedTokenException>(() => parser.GetDocument());
     var token = exception.Token;
     Assert.AreEqual(@"DESCRIPTION", token.Text);
     Assert.AreEqual(1, token.Line);
     Assert.AreEqual(1, parser.Errors.Count);
     var error = parser.Errors[0];
     Assert.AreEqual(@"""Test Agent Simulator""", error.Token.Text);
 }
コード例 #25
0
 public void TestRFC1213_MIB()
 {
     var m = new MemoryStream(Resources.RFC1213_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("RFC1213-MIB", file.Modules[0].Name);
     Assert.AreEqual(201, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[200];
     Assert.AreEqual("snmpEnableAuthenTraps", node.Name);
     Assert.AreEqual(30, node.Value);
     Assert.AreEqual("snmp", node.Parent);
 }
コード例 #26
0
ファイル: Program.cs プロジェクト: emperorstarfinder/phlox
        static void Main(string[] args)
        {
            ICharStream input = null;

            if (args.Length > 0)
            {
                if (args[0] == "bytecompiler")
                {
                    input = new ANTLRInputStream(Console.OpenStandardInput());
                    ByteCompilerFrontend fe = new ByteCompilerFrontend();
                    fe.Listener = new DefaultLSLListener();
                    fe.Compile(input);

                    CompiledScript script = fe.Result;
                    if (script != null)
                    {
                        System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                        watch.Start();
                        Interpreter i = new Interpreter(script, null);
                        i.TraceDestination = Console.Out;
                        while (i.ScriptState.RunState == RuntimeState.Status.Running)
                        {
                            i.Tick();
                        }

                        watch.Stop();
                        System.Console.WriteLine(watch.ElapsedMilliseconds/1000.0);
                    }
                }
                else
                {
                    foreach (string arg in args)
                    {
                        Console.WriteLine("Compiling: " + arg);

                        input = new ANTLRFileStream(arg);
                        CompilerFrontend fe = new CompilerFrontend();
                        fe.TraceDestination = Console.Out;
                        fe.Compile(input);
                    }
                }
            }
            else
            {
                ILSLListener listener = new DefaultLSLListener();
                LSLListenerTraceRedirectorMono redirector = new LSLListenerTraceRedirectorMono(listener);

                input = new ANTLRInputStream(Console.OpenStandardInput());
                CompilerFrontend fe = new CompilerFrontend();
                fe.TraceDestination = redirector;
                fe.Listener = listener;

                Console.WriteLine("** compilation output **");
                string byteCode = fe.Compile(input);

                
                if (! listener.HasErrors() && byteCode != null)
                {
                    input = new ANTLRStringStream(byteCode);
                    ByteCompilerFrontend bfe = new ByteCompilerFrontend();
                    bfe.TraceDestination = redirector;
                    bfe.Listener = listener;
                    bfe.Compile(input);

                    CompiledScript script = bfe.Result;
                    Console.WriteLine("** usage info **");
                    if (script != null) Console.WriteLine("Base memory: {0} bytes", script.CalcBaseMemorySize());
                    //SaveScript(script);

                    /*
                    if (script != null)
                    {
                        System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                        watch.Start();
                        Interpreter i = new Interpreter(script, null);
                        i.TraceDestination = Console.Out;
                        while (i.ScriptState.RunState == RuntimeState.Status.Running)
                        {
                            i.Tick();
                        }

                        watch.Stop();
                        System.Console.WriteLine("Execution: {0} seconds", watch.ElapsedMilliseconds / 1000.0);
                        System.Console.WriteLine("Free Memory: {0} bytes", i.ScriptState.MemInfo.MemoryFree);
                    }
                     * */
                }

                
            }
        }
コード例 #27
0
 public void TestTransport_Address_MIB()
 {
     var m = new MemoryStream(Resources.TRANSPORT_ADDRESS_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("TRANSPORT-ADDRESS-MIB", file.Modules[0].Name);
     Assert.AreEqual(18, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[17];
     Assert.AreEqual("transportDomainSctpDns", node.Name);
     Assert.AreEqual(16, node.Value);
     Assert.AreEqual("transportDomains", node.Parent);
 }
コード例 #28
0
 public ANTLRInputStream(Stream input, int size, int readBufferSize, Encoding encoding)
     : base((TextReader)ANTLRInputStream.GetStreamReader(input, encoding), size, readBufferSize)
 {
 }
コード例 #29
0
 public void TestTunnel_MIB()
 {
     var m = new MemoryStream(Resources.TUNNEL_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("TUNNEL-MIB", file.Modules[0].Name);
     Assert.AreEqual(42, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[41];
     Assert.AreEqual("tunnelMIBInetGroup", node.Name);
     Assert.AreEqual(2, node.Value);
     Assert.AreEqual("tunnelMIBGroups", node.Parent);
 }
コード例 #30
0
 public void TestSNMP_VIEW_BASED_ACM_MIB()
 {
     var m = new MemoryStream(Resources.SNMP_VIEW_BASED_ACM_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("SNMP-VIEW-BASED-ACM-MIB", file.Modules[0].Name);
     Assert.AreEqual(38, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[37];
     Assert.AreEqual("vacmBasicGroup", node.Name);
     Assert.AreEqual(1, node.Value);
     Assert.AreEqual("vacmMIBGroups", node.Parent);
 }
コード例 #31
0
 public void TestUCD_DEMO_MIB()
 {
     var m = new MemoryStream(Resources.UCD_DEMO_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-DEMO-MIB", file.Modules[0].Name);
     Assert.AreEqual(7, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[6];
     Assert.AreEqual("ucdDemoPassphrase", node.Name);
     Assert.AreEqual(4, node.Value);
     Assert.AreEqual("ucdDemoPublic", node.Parent);
 }