Esempio n. 1
0
        public MibModule(string name, Lexer lexer)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            
            if (lexer == null)
            {
                throw new ArgumentNullException("lexer");
            }
            
            _name = name.ToUpperInvariant(); // all module name are uppercase.
            Symbol temp = lexer.GetNextNonEOLSymbol();
            temp.Expect(Symbol.Definitions);
            temp = lexer.GetNextNonEOLSymbol();
            temp.Expect(Symbol.Assign);
            temp = lexer.GetNextSymbol();
            temp.Expect(Symbol.Begin);
            temp = lexer.GetNextNonEOLSymbol();
            if (temp == Symbol.Imports)
            {
                _imports = ParseDependents(lexer);
            }
            else if (temp == Symbol.Exports)
            {
                _exports = ParseExports(lexer);
            }
            else if (temp == Symbol.End)
            {
                return;
            }

            ParseEntities(_tokens, temp, _name, lexer);
        }
Esempio n. 2
0
 public ObjectType(string module, IList<Symbol> header, Lexer lexer)
 {
     _module = module;
     _name = header[0].ToString();
     _properties = ParseProperties(header);
     lexer.ParseOidValue(out _parent, out _value);
 }
Esempio n. 3
0
 public void TestParse3()
 {
     const string test = "::=BEGIN";
     Lexer lexer = new Lexer();
     StringReader reader = new StringReader(test);
     lexer.Parse(reader);
     Assert.AreEqual("::=", lexer.NextSymbol.ToString());
     Assert.AreEqual("BEGIN", lexer.NextSymbol.ToString());
 }       
Esempio n. 4
0
 /// <summary>
 /// Creates a <see cref="MibDocument"/> instance.
 /// </summary>
 /// <param name="lexer"></param>
 public MibDocument(Lexer lexer)
 {
     Symbol temp;
     while ((temp = lexer.GetNextNonEOLSymbol()) != null)
     {
         temp.ValidateIdentifier();
         _modules.Add(new MibModule(temp.ToString(), lexer));                
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Creates a <see cref="ObjectIdentity"/>.
 /// </summary>
 /// <param name="module">Module name</param>
 /// <param name="header">Header</param>
 /// <param name="lexer">Lexer</param>
 public ObjectIdentity(string module, IList<Symbol> header, Lexer lexer)
 {
     _module = module;
     _name = header[0].ToString();
     lexer.ParseOidValue(out _parent, out _value);
     if (_parent == "0")
     {
         _parent = "ccitt";
     }
 }
 public void TestMethod()
 {
     Lexer lexer = new Lexer();
     lexer.Parse(new StringReader("{ iso org(3) dod(6) 1 }"));
     string parent;
     uint value;
     lexer.ParseOidValue(out parent, out value);
     Assert.AreEqual("iso.org(3).dod(6)", parent);
     Assert.AreEqual(1, value);
 }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MibDocument"/> class.
        /// </summary>
        /// <param name="lexer">The lexer.</param>
        public MibDocument(Lexer lexer)
        {
            ISymbolEnumerator symbols = lexer.GetEnumerator();

            Symbol current;
            while ((current = symbols.NextNonEOLSymbol()) != null)
            {
                symbols.PutBack(current);
                _modules.Add(new MibModule(symbols));                
            }
        }
Esempio n. 8
0
 public Macro(string module, IList<Symbol> header, Lexer lexer)
 {
     Symbol temp;
     while ((temp = lexer.NextSymbol) != Symbol.Begin)
     {                
     }
     
     while ((temp = lexer.NextSymbol) != Symbol.End)
     {
     }
 }
        public void TestMethod1()
        {
            Lexer lexer = new Lexer();
            lexer.Parse(new StringReader("{ iso(1) std(0) iso8802(8802) ieee802dot1(1)" + Environment.NewLine +
"     ieee802dot1mibs(1) 1 }"));
            string parent;
            uint value;
            lexer.ParseOidValue(out parent, out value);
            Assert.AreEqual("iso(1).std(0).iso8802(8802).ieee802dot1(1).ieee802dot1mibs(1)", parent);
            Assert.AreEqual(1, value);
        }
Esempio n. 10
0
 public void TestParse()
 {
     Lexer lexer = new Lexer();
     MemoryStream m = new MemoryStream(Resources.SNMPv2_SMI);
     using (StreamReader reader = new StreamReader(m))
     {
         lexer.Parse(reader);
         reader.Close();
     }
     Assert.AreEqual(909, lexer.SymbolCount);
 }
        public void TestException()
        {
            Lexer lexer = new Lexer();
            MemoryStream m = new MemoryStream(Resources.fivevarbinds);
            using (StreamReader reader = new StreamReader(m))
            {
                lexer.Parse("temp.txt", reader);
                reader.Close();
            }

            new MibDocument(lexer);
        }
Esempio n. 12
0
 public Macro(string module, IList<Symbol> header, Lexer lexer)
 {
     _name = header[0].ToString();
     Symbol temp;
     while ((temp = lexer.GetNextSymbol()) != Symbol.Begin)
     {                
     }
     
     while ((temp = lexer.GetNextSymbol()) != Symbol.End)
     {
     }
 }
Esempio n. 13
0
        public void TestOverlappingRanges3()
        {
            const string test = "SomeEnum ::= INTEGER (8 | 8 | 31 .. 60 )";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Integer);

            Assert.Throws<MibException>(() => new IntegerType("module", "name", lexer));
        }
Esempio n. 14
0
 public TrapType(string module, IList<Symbol> header, Lexer lexer)
 {
     _module = module;
     _name = header[0].ToString();
     Symbol temp;
     while ((temp = lexer.GetNextSymbol()) == Symbol.EOL)
     {
     }
     
     bool succeeded = int.TryParse(temp.ToString(), out _value);
     temp.Assert(succeeded, "not a decimal");
 }
Esempio n. 15
0
        public void TestEnumerable()
        {
            const string test = "SomeEnum ::= Counter64";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Counter64);

            Counter64Type i = new Counter64Type("module", "name", lexer);
        }
Esempio n. 16
0
        public UnsignedType(string module, string name, Lexer lexer)
        {
            _module = module;
            _name = name;

            Symbol temp = lexer.CheckNextNonEOLSymbol();
            if (temp == Symbol.OpenParentheses)
            {
                lexer.GetNextNonEOLSymbol();
                _ranges = DecodeRanges(lexer);
            }
        }
Esempio n. 17
0
        public void Test()
        {
            const string test = "SomeIp ::= IpAddress";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.IpAddress);

            IpAddressType i = new IpAddressType("module", "name", lexer);
        }
Esempio n. 18
0
        public OctetStringType(string module, string name, Lexer lexer)
        {
            _module = module;
            _name = name;
            _size = new List<ValueRange>();

            Symbol temp = lexer.GetNextSymbol();
            if (temp == Symbol.OpenParentheses)
            {
                _size = DecodeRanges(lexer);
            }

        }
Esempio n. 19
0
        public void Test()
        {
            const string test = "SomeEnum ::= BITS {first(1), second(2)}";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Bits);

            BitsType i = new BitsType("module", "name", lexer);
            Assert.AreEqual("first(1)", i[1]);
        }
Esempio n. 20
0
 /// <summary>
 /// Creates an <see cref="Imports"/> instance.
 /// </summary>
 /// <param name="lexer"></param>
 public Imports(Lexer lexer)
 {
     Symbol temp;
     while ((temp = lexer.GetNextSymbol()) != Symbol.Semicolon)
     {
         if (temp == Symbol.EOL)
         {
             continue;
         }
         
         _dependents.Add(new ImportsFrom(temp, lexer).Module);
     }
 }
Esempio n. 21
0
        public void TestNegative()
        {
            const string test = "SomeEnum ::= OCTET STRING ( SIZE (8 | -5 .. 20 | 31 .. 60 ))";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Octet);
            lexer.GetNextSymbol().Expect(Symbol.String);

            Assert.Throws<MibException>(delegate { new OctetStringType("module", "name", lexer); });
        }
Esempio n. 22
0
        public void TestEnumerable()
        {
            const string test = "SomeEnum ::= INTEGER {first(1), second(2)}";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Integer);

            IntegerType i = new IntegerType("module", "name", lexer);
            Assert.IsTrue(i.IsEnumeration);
            Assert.AreEqual("first(1)", i[1]);
        }
 public void TestEmpty()
 {
     // issue 4978
     Lexer lexer = new Lexer();
     MemoryStream m = new MemoryStream(Resources.empty);
     using (StreamReader reader = new StreamReader(m))
     {
         lexer.Parse(reader);
         reader.Close();
     }
     MibDocument file = new MibDocument(lexer);
     Assert.AreEqual("SNMPV2-CONF", file.Modules[0].Name);
     Assert.AreEqual(0, file.Modules[0].Dependents.Count);
     Assert.AreEqual(0, file.Modules[0].Entities.Count);
 }
        public void TestHttpMib()
        {
            // issue 4978
            Lexer lexer = new Lexer();
            MemoryStream m = new MemoryStream(Resources.httpmib);
            using (StreamReader reader = new StreamReader(m))
            {
                lexer.Parse(reader);
                reader.Close();
            }

            MibDocument file = new MibDocument(lexer);
            Assert.AreEqual("HTTPSERVER-MIB", file.Modules[0].Name);
            Assert.AreEqual(0, file.Modules[0].Dependents.Count);
            Assert.AreEqual(0, file.Modules[0].Entities.Count);
        }        
 // TODO: [Test]
 public void TestSNMPv2_PDU()
 {
     Lexer lexer = new Lexer();
     MemoryStream m = new MemoryStream(Resources.SNMPV2_PDU);
     using (StreamReader reader = new StreamReader(m))
     {
         lexer.Parse(reader);
         reader.Close();
     }
     MibDocument file = new MibDocument(lexer);
     Assert.AreEqual("SNMPv2-PDU", file.Modules[0].Name);
     Assert.AreEqual(5, file.Modules[0].Dependents.Count);
     Assert.AreEqual(55, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[54];
     Assert.AreEqual("casConfigGroup", node.Name);
     Assert.AreEqual(2, node.Value);
     Assert.AreEqual("casMIBGroups", node.Parent);
 }
Esempio n. 26
0
        public IntegerType(string module, string name, Lexer lexer)
        {
            _name = name;

            Symbol temp = lexer.CheckNextNonEOLSymbol();
            if (temp == Symbol.OpenBracket)
            {
                lexer.GetNextNonEOLSymbol();
                _isEnumeration = true;
                _map = DecodeEnumerations(lexer);
            }
            else if (temp == Symbol.OpenParentheses)
            {
                lexer.GetNextNonEOLSymbol();
                _isEnumeration = false;
                _ranges = DecodeRanges(lexer);
            }
        }
Esempio n. 27
0
 public Exports(Lexer lexer)
 {
     Symbol previous = null;
     Symbol temp;
     while ((temp = lexer.NextSymbol) != Symbol.Semicolon) 
     {
         if (temp == Symbol.EOL) 
         {
             continue;
         }
         
         if (temp == Symbol.Comma && previous != null) 
         {
             previous.ValidateIdentifier();
             _types.Add(previous.ToString());
         }
         
         previous = temp;
     }
 }
Esempio n. 28
0
 public Sequence(string module, string name, Lexer lexer)
 {
     _name = name;
     // parse between ( )
     Symbol temp = lexer.GetNextNonEOLSymbol(); 
     int bracketSection = 0;
     temp.Expect(Symbol.OpenBracket);
     bracketSection++;
     while (bracketSection > 0)
     {
         temp = lexer.GetNextNonEOLSymbol();
         if (temp == Symbol.OpenBracket)
         {
             bracketSection++;
         }
         else if (temp == Symbol.CloseBracket)
         {
             bracketSection--;
         }
     }
 }
Esempio n. 29
0
        public void TestRanges()
        {
            const string test = "SomeEnum ::= OCTET STRING ( SIZE (5 | 8 .. 20 | 31 .. 60 ))";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Octet);
            lexer.GetNextSymbol().Expect(Symbol.String);

            OctetStringType i = new OctetStringType("module", "name", lexer);
            Assert.IsTrue(i.Contains(8));
            Assert.IsTrue(i.Contains(5));
            Assert.IsTrue(i.Contains(15));
            Assert.IsTrue(i.Contains(20));
            Assert.IsTrue(i.Contains(35));
            Assert.IsFalse(i.Contains(4));
            Assert.IsFalse(i.Contains(-9));
            Assert.IsFalse(i.Contains(25));
            Assert.IsFalse(i.Contains(61));
        }
Esempio n. 30
0
 public ImportsFrom(Symbol last, Lexer lexer)
 {
     Symbol previous = last;
     Symbol temp;
     while ((temp = lexer.GetNextSymbol()) != Symbol.From)
     {
         if (temp == Symbol.EOL) 
         {
             continue;
         }
         
         if (temp == Symbol.Comma)
         {
             previous.ValidateIdentifier();
             _types.Add(previous.ToString());
         }
         
         previous = temp;
     }
     
     _module = lexer.GetNextSymbol().ToString().ToUpperInvariant(); // module names are uppercase
 }
Esempio n. 31
0
 private static Exports ParseExports(Lexer lexer)
 {
     return(new Exports(lexer));
 }
Esempio n. 32
0
 public Counter64Type(string module, string name, Lexer lexer)
 {
     _module = module;
     _name   = name;
 }
        public TextualConvention(string module, string name, Lexer lexer)
        {
            _name = name;

            Symbol temp = lexer.GetNextNonEOLSymbol();

            if (temp == Symbol.DisplayHint)
            {
                // TODO: this needs decoding to a useful format.
                _displayHint = new DisplayHint(lexer.GetNextNonEOLSymbol().ToString().Trim(new[] { '"' }));
                temp = lexer.GetNextNonEOLSymbol();
            }

            temp.Expect(Symbol.Status);
            try
            {
                _status = StatusHelper.CreateStatus(lexer.GetNextNonEOLSymbol().ToString());
                temp = lexer.GetNextNonEOLSymbol();
            }
            catch (ArgumentException)
            {
                temp.Throw("Invalid status");
            }

            temp.Expect(Symbol.Description);
            _description = lexer.GetNextNonEOLSymbol().ToString().Trim(new[] { '"' });
            temp = lexer.GetNextNonEOLSymbol();

            if (temp == Symbol.Reference)
            {
                _reference = lexer.GetNextNonEOLSymbol().ToString();
                temp = lexer.GetNextNonEOLSymbol();
            }

            temp.Expect(Symbol.Syntax);

            /* 
             * RFC2579 definition:
             *       Syntax ::=   -- Must be one of the following:
             *                    -- a base type (or its refinement), or
             *                    -- a BITS pseudo-type
             *               type
             *             | "BITS" "{" NamedBits "}"
             *
             * From section 3.5:
             *      The data structure must be one of the alternatives defined
             *      in the ObjectSyntax CHOICE or the BITS construct.  Note
             *      that this means that the SYNTAX clause of a Textual
             *      Convention can not refer to a previously defined Textual
             *      Convention.
             *      
             *      The SYNTAX clause of a TEXTUAL CONVENTION macro may be
             *      sub-typed in the same way as the SYNTAX clause of an
             *      OBJECT-TYPE macro.
             * 
             * Therefore the possible values are (grouped by underlying type):
             *      INTEGER, Integer32
             *      OCTET STRING, Opaque
             *      OBJECT IDENTIFIER
             *      IpAddress
             *      Counter64
             *      Unsigned32, Counter32, Gauge32, TimeTicks
             *      BITS
             * With appropriate sub-typing.
             */

            temp = lexer.GetNextNonEOLSymbol();
            if (temp == Symbol.Bits)
            {
                _syntax = new BitsType(module, string.Empty, lexer);
            }
            else if (temp == Symbol.Integer || temp == Symbol.Integer32)
            {
                _syntax = new IntegerType(module, string.Empty, lexer);
            }
            else if (temp == Symbol.Octet)
            {
                temp = lexer.GetNextSymbol();
                temp.Expect(Symbol.String);
                _syntax = new OctetStringType(module, string.Empty, lexer);
            }
            else if (temp == Symbol.Opaque)
            {
                _syntax = new OctetStringType(module, string.Empty, lexer);
            }
            else if (temp == Symbol.IpAddress)
            {
                _syntax = new IpAddressType(module, string.Empty, lexer);
            }
            else if (temp == Symbol.Counter64)
            {
                _syntax = new Counter64Type(module, string.Empty, lexer);
            }
            else if (temp == Symbol.Unsigned32 || temp == Symbol.Counter32 || temp == Symbol.Gauge32 || temp == Symbol.TimeTicks)
            {
                _syntax = new UnsignedType(module, string.Empty, lexer);
            }
            else if (temp == Symbol.Object)
            {
                temp = lexer.GetNextSymbol();
                temp.Expect(Symbol.Identifier);
                _syntax = new ObjectIdentifierType(module, string.Empty, lexer);
            }
            else
            {
                //temp.Throw("illegal syntax for textual convention");
                _syntax = new CustomType(module, string.Empty, lexer);
            }
        }
Esempio n. 34
0
 private static void ParseEntity(ICollection <IConstruct> tokens, string module, IList <Symbol> buffer, Lexer lexer)
 {
     buffer[0].Assert(buffer.Count > 1, "unexpected symbol");
     buffer[0].ValidateIdentifier();
     if (buffer.Count == 2)
     {
         // others
         tokens.Add(ParseOthers(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.Object)
     {
         // object identifier
         tokens.Add(ParseObjectIdentifier(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.ModuleIdentity)
     {
         // module identity
         tokens.Add(new ModuleIdentity(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.ObjectType)
     {
         tokens.Add(new ObjectType(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.ObjectGroup)
     {
         tokens.Add(new ObjectGroup(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.NotificationGroup)
     {
         tokens.Add(new NotificationGroup(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.ModuleCompliance)
     {
         tokens.Add(new ModuleCompliance(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.NotificationType)
     {
         tokens.Add(new NotificationType(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.ObjectIdentity)
     {
         tokens.Add(new ObjectIdentity(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.Macro)
     {
         tokens.Add(new Macro(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.TrapType)
     {
         tokens.Add(new TrapType(module, buffer, lexer));
     }
     else if (buffer[1] == Symbol.AgentCapabilities)
     {
         tokens.Add(new AgentCapabilities(module, buffer, lexer));
     }
 }
 public IpAddressType(string module, string name, Lexer lexer)
 {
     _module = module;
     _name   = name;
 }
Esempio n. 36
0
        private static void ParseEntities(ICollection <IConstruct> tokens, Symbol last, string module, Lexer lexer)
        {
            Symbol temp = last;

            if (temp == Symbol.End)
            {
                return;
            }

            IList <Symbol> buffer = new List <Symbol>();
            IList <Symbol> next   = new List <Symbol>(); // symbol that belongs to next token.

            do
            {
                if (temp == Symbol.Imports || temp == Symbol.Exports || temp == Symbol.EOL)
                {
                    continue;
                }

                buffer.Add(temp);
                if (temp != Symbol.Assign)
                {
                    continue;
                }

                ParseEntity(tokens, module, buffer, lexer, ref next);
                buffer.Clear();
                foreach (Symbol s in next)
                {
                    if (s == Symbol.End)
                    {
                        return;
                    }

                    buffer.Add(s);
                }

                next.Clear();
            }while ((temp = lexer.NextSymbol) != Symbol.End);
        }
Esempio n. 37
0
 /// <summary>
 /// Creates an <see cref="AgentCapabilities"/> instance.
 /// </summary>
 /// <param name="module"></param>
 /// <param name="header"></param>
 /// <param name="lexer"></param>
 public AgentCapabilities(string module, IList <Symbol> header, Lexer lexer)
 {
     _module = module;
     _name   = header[0].ToString();
     lexer.ParseOidValue(out _parent, out _value);
 }
Esempio n. 38
0
        private static void ParseEntities(ICollection <IConstruct> tokens, Symbol last, string module, Lexer lexer)
        {
            Symbol         temp   = last;
            IList <Symbol> buffer = new List <Symbol>();

            do
            {
                if (temp == Symbol.Imports || temp == Symbol.Exports || temp == Symbol.EOL)
                {
                    continue;
                }

                buffer.Add(temp);
                if (temp != Symbol.Assign)
                {
                    continue;
                }

                ParseEntity(tokens, module, buffer, lexer);
                buffer.Clear();
            }while ((temp = lexer.GetNextSymbol()) != Symbol.End);
        }
Esempio n. 39
0
 private static IEntity ParseObjectIdentifier(string module, IList <Symbol> header, Lexer lexer)
 {
     header[0].Assert(header.Count == 4, "invalid OID value assignment");
     header[2].Expect(Symbol.Identifier);
     return(new OidValueAssignment(module, header[0].ToString(), lexer));
 }
Esempio n. 40
0
 public ObjectIdentifierType(string module, string name, Lexer lexer)
 {
     _module = module;
     _name   = name;
 }
 public ModuleIdentity(string module, IList <Symbol> header, Lexer lexer)
 {
     _module = module;
     _name   = header[0].ToString();
     lexer.ParseOidValue(out _parent, out _value);
 }
Esempio n. 42
0
        private void ParseEntity(SymbolList preAssignSymbols, ISymbolEnumerator symbols)
        {
            if ((preAssignSymbols == null) || (preAssignSymbols.Count == 0))
            {
                Symbol s = symbols.NextSymbol();
                if (s != null)
                {
                    s.Assert(false, "Invalid Entitiy declaration");
                }
                else
                {
                    throw new MibException("Invalid Entitiy declaration");
                }
            }

            // check for a valid identifier
            preAssignSymbols[0].AssertIsValidIdentifier();

            if (preAssignSymbols.Count == 1)
            {
                // its a typedef
                _tokens.Add(Lexer.ParseBasicTypeDef(this, preAssignSymbols[0].ToString(), symbols, isMacroSyntax: false));
                return;
            }

            ISymbolEnumerator preAssignSymbolsEnumerator = preAssignSymbols.GetSymbolEnumerator();

            preAssignSymbolsEnumerator.NextNonEOLSymbol(); // returns identifier
            Symbol type = preAssignSymbolsEnumerator.NextNonEOLSymbol();

            // parse declarations
            if (type == Symbol.Object)
            {
                Symbol next = preAssignSymbolsEnumerator.NextNonEOLSymbol();

                if (next == Symbol.Identifier)
                {
                    _tokens.Add(new OidValueAssignment(this, preAssignSymbols, symbols));
                    return;
                }
                else if (next != null)
                {
                    preAssignSymbolsEnumerator.PutBack(next);
                }
            }
            if (type == Symbol.ModuleIdentity)
            {
                _tokens.Add(new ModuleIdentity(this, preAssignSymbols, symbols));
                return;
            }
            if (type == Symbol.ObjectType)
            {
                _tokens.Add(new ObjectType(this, preAssignSymbols, symbols));
                return;
            }
            if (type == Symbol.ObjectGroup)
            {
                _tokens.Add(new ObjectGroup(this, preAssignSymbols, symbols));
                return;
            }
            if (type == Symbol.NotificationGroup)
            {
                _tokens.Add(new NotificationGroup(this, preAssignSymbols, symbols));
                return;
            }
            if (type == Symbol.ModuleCompliance)
            {
                _tokens.Add(new ModuleCompliance(this, preAssignSymbols, symbols));
                return;
            }
            if (type == Symbol.NotificationType)
            {
                _tokens.Add(new NotificationType(this, preAssignSymbols, symbols));
                return;
            }
            if (type == Symbol.ObjectIdentity)
            {
                _tokens.Add(new ObjectIdentity(this, preAssignSymbols, symbols));
                return;
            }
            if (type == Symbol.Macro)
            {
                _tokens.Add(new Macro(this, preAssignSymbols, symbols));
                return;
            }
            if (type == Symbol.TrapType)
            {
                _tokens.Add(new TrapType(this, preAssignSymbols, symbols));
                return;
            }
            if (type == Symbol.AgentCapabilities)
            {
                _tokens.Add(new AgentCapabilities(this, preAssignSymbols, symbols));
                return;
            }

            preAssignSymbols[1].Assert(false, "Unknown/Invalid declaration");
        }
Esempio n. 43
0
 private static Imports ParseDependents(Lexer lexer)
 {
     return(new Imports(lexer));
 }