private Definition CreateExtraNodes(MibModule module, string longParent) { string[] content = longParent.Split('.'); Definition node = Find(ExtractName(content[0])); uint[] rootId = node.GetNumericalForm(); var all = new uint[content.Length + rootId.Length - 1]; for (int j = rootId.Length - 1; j >= 0; j--) { all[j] = rootId[j]; } // change all to numerical for (int i = 1; i < content.Length; i++) { uint value; bool numberFound = uint.TryParse(content[i], out value); int currentCursor = rootId.Length + i - 1; if (numberFound) { all[currentCursor] = value; node = Find(ExtractParent(all, currentCursor + 1)); if (node != null) { continue; } IDefinition subroot = Find(ExtractParent(all, currentCursor)); // if not, create Prefix node. var prefix = new ObjectIdentifierType(module.Name, subroot.Name + "_" + value.ToString(CultureInfo.InvariantCulture), subroot.Name, value); #if !MA && !MT Logger.Info(module.ReportImplicitObjectIdentifier(prefix)); #endif node = CreateSelf(prefix); AddToTable(node); } else { string self = content[i]; string parent = content[i - 1]; var extra = new ObjectIdentifierType(module.Name, ExtractName(self), ExtractName(parent), ExtractValue(self)); node = CreateSelf(extra); if (node != null) { #if !MA && !MT Logger.Info(module.ReportImplicitObjectIdentifier(extra)); #endif AddToTable(node); all[currentCursor] = node.Value; } else { #if !MA && !MT Logger.Info(module.ReportIgnoredImplicitEntity(longParent)); #endif } } } return(node); }
private Definition CreateExtraNodes(MibModule module, string longParent) { string[] content = longParent.Split('.'); Definition node = Find(ExtractName(content[0])); uint[] rootId = node.GetNumericalForm(); var all = new uint[content.Length + rootId.Length - 1]; for (int j = rootId.Length - 1; j >= 0; j--) { all[j] = rootId[j]; } // change all to numerical for (int i = 1; i < content.Length; i++) { uint value; bool numberFound = UInt32.TryParse(content[i], out value); int currentCursor = rootId.Length + i - 1; if (numberFound) { all[currentCursor] = value; node = Find(ExtractParent(all, currentCursor + 1)); if (node != null) { continue; } IDefinition subroot = Find(ExtractParent(all, currentCursor)); // if not, create Prefix node. var prefix = new ObjectIdentifierType(module.Name, subroot.Name + "_" + value.ToString(CultureInfo.InvariantCulture), subroot.Name, value); #if !MA Logger.Info(module.ReportImplicitObjectIdentifier(prefix)); #endif node = CreateSelf(prefix); AddToTable(node); } else { string self = content[i]; string parent = content[i - 1]; var extra = new ObjectIdentifierType(module.Name, ExtractName(self), ExtractName(parent), ExtractValue(self)); node = CreateSelf(extra); if (node != null) { #if !MA Logger.Info(module.ReportImplicitObjectIdentifier(extra)); #endif AddToTable(node); all[currentCursor] = node.Value; } else { #if !MA Logger.Info(module.ReportIgnoredImplicitEntity(longParent)); #endif } } } return node; }
public string ReportImplicitObjectIdentifier(ObjectIdentifierType extra) { return string.IsNullOrEmpty(FileName) ? string.Format("warning N0003 : implicit object identifier {0} ({1}) created under {2} in module {3}", extra.Name, extra.Value, extra.Parent, Name) : string.Format("{0} : warning N0003 : implicit object identifier {1} ({2}) created under {3} in module {4}", FileName, extra.Name, extra.Value, extra.Parent, Name); }
public string ReportImplicitObjectIdentifier(ObjectIdentifierType extra) { return(string.IsNullOrEmpty(FileName) ? string.Format("warning N0003 : implicit object identifier {0} ({1}) created under {2} in module {3}", extra.Name, extra.Value, extra.Parent, Name) : string.Format("{0} : warning N0003 : implicit object identifier {1} ({2}) created under {3} in module {4}", FileName, extra.Name, extra.Value, extra.Parent, Name)); }
private static ITypeAssignment ParseSyntax(string module, string name, IEnumerator <Symbol> enumerator, ref Symbol temp) { ITypeAssignment syntax; temp.Expect(Symbol.Syntax); temp = enumerator.NextNonEOLSymbol(); if (temp == Symbol.Bits) { syntax = new BitsType(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } else if (temp == Symbol.Integer || temp == Symbol.Integer32) { syntax = new IntegerType(module, name, enumerator, ref temp); } else if (temp == Symbol.Octet) { temp = enumerator.NextNonEOLSymbol(); temp.Expect(Symbol.String); syntax = new OctetStringType(string.Empty, string.Empty, enumerator, ref temp); } else if (temp == Symbol.Opaque) { syntax = new OctetStringType(string.Empty, string.Empty, enumerator, ref temp); } else if (temp == Symbol.IpAddress) { syntax = new IpAddressType(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } else if (temp == Symbol.Counter64) { syntax = new Counter64Type(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } else if (temp == Symbol.Unsigned32 || temp == Symbol.Counter32 || temp == Symbol.Gauge32 || temp == Symbol.TimeTicks) { syntax = new UnsignedType(string.Empty, string.Empty, enumerator, ref temp); } else if (temp == Symbol.Object) { temp = enumerator.NextNonEOLSymbol(); temp.Expect(Symbol.Identifier); syntax = new ObjectIdentifierType(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } else if (temp == Symbol.Sequence) { temp = enumerator.NextNonEOLSymbol(); if (temp == Symbol.Of) { temp = enumerator.NextNonEOLSymbol(); syntax = new TypeAssignment(string.Empty, string.Empty, enumerator, ref temp); } else { syntax = new Sequence(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } } else { syntax = new TypeAssignment(string.Empty, string.Empty, enumerator, ref temp); } return(syntax); }
private static ITypeAssignment ParseSyntax(string module, string name, IEnumerator<Symbol> enumerator, ref Symbol temp) { ITypeAssignment syntax; temp.Expect(Symbol.Syntax); temp = enumerator.NextNonEOLSymbol(); if (temp == Symbol.Bits) { syntax = new BitsType(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } else if (temp == Symbol.Integer || temp == Symbol.Integer32) { syntax = new IntegerType(module, name, enumerator, ref temp); } else if (temp == Symbol.Octet) { temp = enumerator.NextNonEOLSymbol(); temp.Expect(Symbol.String); syntax = new OctetStringType(string.Empty, string.Empty, enumerator, ref temp); } else if (temp == Symbol.Opaque) { syntax = new OctetStringType(string.Empty, string.Empty, enumerator, ref temp); } else if (temp == Symbol.IpAddress) { syntax = new IpAddressType(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } else if (temp == Symbol.Counter64) { syntax = new Counter64Type(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } else if (temp == Symbol.Unsigned32 || temp == Symbol.Counter32 || temp == Symbol.Gauge32 || temp == Symbol.TimeTicks) { syntax = new UnsignedType(string.Empty, string.Empty, enumerator, ref temp); } else if (temp == Symbol.Object) { temp = enumerator.NextNonEOLSymbol(); temp.Expect(Symbol.Identifier); syntax = new ObjectIdentifierType(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } else if (temp == Symbol.Sequence) { temp = enumerator.NextNonEOLSymbol(); if (temp == Symbol.Of) { temp = enumerator.NextNonEOLSymbol(); syntax = new TypeAssignment(string.Empty, string.Empty, enumerator, ref temp); } else { syntax = new Sequence(string.Empty, string.Empty, enumerator); temp = enumerator.NextNonEOLSymbol(); } } else { syntax = new TypeAssignment(string.Empty, string.Empty, enumerator, ref temp); } return syntax; }