本文整理汇总了C#中Lextm.SharpSnmpLib.Mib.Lexer类的典型用法代码示例。如果您正苦于以下问题:C# Lexer类的具体用法?C# Lexer怎么用?C# Lexer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Lexer类属于Lextm.SharpSnmpLib.Mib命名空间,在下文中一共展示了Lexer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObjectType
public ObjectType(string module, IList<Symbol> header, Lexer lexer)
{
_module = module;
_name = header[0].ToString();
_properties = ParseProperties(header);
lexer.ParseOidValue(out _parent, out _value);
}
示例2: MibModule
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);
}
示例3: TestParse3
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());
}
示例4: MibDocument
/// <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));
}
}
示例5: ObjectIdentity
/// <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";
}
}
示例6: TestMethod
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);
}
示例7: Macro
public Macro(string module, IList<Symbol> header, Lexer lexer)
{
Symbol temp;
while ((temp = lexer.NextSymbol) != Symbol.Begin)
{
}
while ((temp = lexer.NextSymbol) != Symbol.End)
{
}
}
示例8: MibDocument
/// <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));
}
}
示例9: TestParse
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);
}
示例10: TestMethod1
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);
}
示例11: TestException
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);
}
示例12: UnsignedType
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);
}
}
示例13: Macro
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)
{
}
}
示例14: Test
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);
}
示例15: TestOverlappingRanges3
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));
}