本文整理汇总了C#中Lextm.SharpSnmpLib.Mib.Lexer.GetNextSymbol方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.GetNextSymbol方法的具体用法?C# Lexer.GetNextSymbol怎么用?C# Lexer.GetNextSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lextm.SharpSnmpLib.Mib.Lexer
的用法示例。
在下文中一共展示了Lexer.GetNextSymbol方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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));
}
示例3: 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)
{
}
}
示例4: TestEnumerable
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);
}
示例5: TestNegative
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); });
}
示例6: Test
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]);
}
示例7: TestEnumerable
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]);
}
示例8: 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);
}
示例9: TrapType
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");
}
示例10: ImportsFrom
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
}
示例11: Imports
/// <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);
}
}
示例12: TestRanges
public void TestRanges()
{
const string test = "SomeEnum ::= INTEGER (8 |10 ..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.Integer);
IntegerType i = new IntegerType("module", "name", lexer);
Assert.IsFalse(i.IsEnumeration);
Assert.IsTrue(i.Contains(8));
Assert.IsTrue(i.Contains(10));
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));
}
示例13: OctetStringType
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);
}
}
示例14: TestRanges
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));
}
示例15: Exports
public Exports(Lexer lexer)
{
Symbol previous = null;
Symbol temp;
while ((temp = lexer.GetNextSymbol()) != Symbol.Semicolon)
{
if (temp == Symbol.EOL)
{
continue;
}
if (temp == Symbol.Comma && previous != null)
{
previous.ValidateIdentifier();
_types.Add(previous.ToString());
}
previous = temp;
}
}