private static (DeserializableMember?Member, ImmutableArray <Diagnostic> Diagnostics) MakeMember( Location?location, DeserializerTypes types, string name, Setter setter, Parser?parser, Reset?reset, bool isRequired, int?order, ImmutableArray <Diagnostic> diags ) { if (diags.IsEmpty) { if (parser == null && !Parser.TryGetDefault(types, setter.ValueType, out parser)) { var diag = Diagnostics.NoBuiltInParser(location, setter.ValueType); diags = diags.Add(diag); return(null, diags); } parser = Utils.NonNull(parser); return(new DeserializableMember(name, setter, parser, reset, isRequired, order), ImmutableArray <Diagnostic> .Empty); } return(null, diags); }
public AstBinary(Parser?parser, Position startLoc, Position endLoc, AstNode left, AstNode right, Operator op) : base(parser, startLoc, endLoc) { Left = left; Right = right; Operator = op; }
public override Program Load(Address?addrLoad) { this.program = new Program(); parser = CreateParser(); var(hdr, specific) = parser.ParseHeader(addrLoad); this.program = parser.ParseLoadCommands(hdr, specific.Architecture, addrLoad); return(this.program); }
private BindingRestrictions MakeRestrictions(Parser?expected, TypeInfo returnType) { var expectedConst = Expression.Constant(expected); var get = GetParser(returnType); var eq = Expression.Equal(expectedConst, get); var sameParserRestriction = BindingRestrictions.GetExpressionRestriction(eq); var expressionIsCellRestriction = BindingRestrictions.GetTypeRestriction(Expression, Types.DynamicCell); return(expressionIsCellRestriction.Merge(sameParserRestriction)); }
public void ConstructorTest() { try { parser = new Parser(bytes); } catch (Exception ex) { Assert.Fail(ex.Message); } Assert.Pass(); }
private void ValidateElement() { elementName.Init(reader.LocalName, XmlSchemaDatatype.XdrCanonizeUri(reader.NamespaceURI, NameTable, SchemaNames)); ValidateChildElement(); if (SchemaNames.IsXDRRoot(elementName.Name, elementName.Namespace) && reader.Depth > 0) { _inlineSchemaParser = new Parser(SchemaType.XDR, NameTable, SchemaNames, EventHandler); _inlineSchemaParser.StartParsing(reader, null); _inlineSchemaParser.ParseReaderNode(); } else { ProcessElement(); } }
public bool?Process(char c) { _chars.Add(c); if (_parser == null) { switch (c) { case '[': _parser = new CsiParser(); return(null); default: return(false); } } return(_parser.Process(c)); }
private void ProcessInlineSchema() { if (!_inlineSchemaParser !.ParseReaderNode()) { // Done _inlineSchemaParser.FinishParsing(); SchemaInfo?xdrSchema = _inlineSchemaParser.XdrSchema; if (xdrSchema != null && xdrSchema.ErrorCount == 0) { foreach (string inlineNS in xdrSchema.TargetNamespaces.Keys) { if (!this.schemaInfo !.HasSchema(inlineNS)) { schemaInfo.Add(xdrSchema, EventHandler); SchemaCollection !.Add(inlineNS, xdrSchema, null, false); break; } } } _inlineSchemaParser = null; } }
private static Parser[] GetParserInstances(Assembly asm) { var parsers = new List <Parser>(); var customParsers = asm.GetTypes().Where(t => t.IsSubclassOf(typeof(Parser))).ToList(); foreach (var parser in customParsers) { Log.Message($"Found custom parser: {parser}"); Parser?parserInst = null; try { parserInst = Activator.CreateInstance(parser) as Parser; } catch (Exception ex) { Log.Error($"Can't instantiate type: {parser}. {ex}"); } if (parserInst != null) { parsers.Add(parserInst); } } return(parsers.ToArray()); }
public override Program LoadProgram(Address?addrLoad) { addrLoad ??= PreferredBaseAddress; this.program = new Program(); parser = CreateParser(); var(hdr, specific) = parser.ParseHeader(addrLoad); this.program = parser.ParseLoadCommands(hdr, specific.Architecture, addrLoad); CollectSymbolStubs(parser, machoSymbols, imageSymbols); var imgSymbols = new SortedList <Address, ImageSymbol>(); foreach (var de in imageSymbols) { if (program.SegmentMap.IsValidAddress(de.Key)) { program.ImageSymbols.Add(de.Key, de.Value); } } foreach (var ep in entryPoints) { program.EntryPoints[ep.Address] = ep; } return(this.program); }
internal ExpressionEval(ILanguageDefinition languageDefinition, Lexer?lexer = null, Parser?parser = null) { LanguageDefinition = languageDefinition; Lexer = lexer ?? new Lexer(LanguageDefinition); Parser = parser ?? new Parser(LanguageDefinition); }
public AstUndefined(Parser?parser, Position startLoc, Position endLoc) : base(parser, startLoc, endLoc) { }
public AstFalse(Parser?parser, Position startLoc, Position endLoc) : base(parser, startLoc, endLoc) { }
public AstAssign(Parser?parser, Position startLoc, Position endLoc, AstNode left, AstNode right, Operator op) : base(parser, startLoc, endLoc, left, right, op) { }
// returns true if we can static bool CanConvert <T>(Parser?p, ReadOnlySpan <char> data, in ReadContext ctx)
public AstStatement(Parser?parser, Position startPos, Position endPos) : base(parser, startPos, endPos) { }
public AstBoolean(Parser?parser, Position startLoc, Position endLoc) : base(parser, startLoc, endLoc) { }
internal static DeserializableMember CreateInner( TypeInfo?beingDeserializedType, string?name, Setter?setter, Parser?parser, MemberRequired isRequired, Reset?reset, TypeInfo?aheadOfTimeGeneratedType ) { if (beingDeserializedType == null) { Throw.ArgumentNullException(nameof(beingDeserializedType)); } if (name == null) { Throw.ArgumentNullException(nameof(name)); } if (setter == null) { Throw.ArgumentNullException(nameof(setter)); } if (parser == null) { Throw.ArgumentNullException(nameof(parser)); } if (name.Length == 0) { Throw.ArgumentException($"{nameof(name)} must be at least 1 character long", nameof(name)); } bool isRequiredBool; switch (isRequired) { case MemberRequired.Yes: isRequiredBool = true; break; case MemberRequired.No: isRequiredBool = false; break; default: Throw.ArgumentException($"Unexpected {nameof(MemberRequired)}: {isRequired}", nameof(isRequired)); return(default); } var valueType = setter.Takes; if (!valueType.IsAssignableFrom(parser.Creates)) { Throw.ArgumentException($"Provided {nameof(Parser)} creates a {parser.Creates}, which cannot be passed to {setter} which expects a {valueType}", nameof(setter)); } if (reset != null && reset.RowType.HasValue) { if (!reset.RowType.Value.IsAssignableFrom(beingDeserializedType)) { Throw.ArgumentException($"{nameof(reset)} must be callable on {beingDeserializedType}", nameof(reset)); } } if (setter.Mode == BackingMode.ConstructorParameter && !isRequiredBool) { Throw.InvalidOperationException($"{nameof(Setter)} that is backed by a constructor parameter can only be used with {nameof(MemberRequired)}.{nameof(MemberRequired.Yes)}; {nameof(setter)} was {setter}"); } return(new DeserializableMember(name, setter, parser, isRequiredBool, reset, aheadOfTimeGeneratedType)); }
private ManualTypeDescriberBuilder WithDeserializeMember(TypeInfo?forType, Setter?setter, string?name, Parser?parser, MemberRequired required, Reset?reset) { if (forType == null) { Throw.ArgumentNullException(nameof(forType)); } if (setter == null) { Throw.ArgumentNullException(nameof(setter)); } if (name == null) { Throw.ArgumentNullException(nameof(name)); } if (parser == null) { Throw.ArgumentNullException(nameof(parser)); } var toAdd = DeserializableMember.Create(forType, name, setter, parser, required, reset); if (!Deserializers.TryGetValue(forType, out var d)) { Deserializers[forType] = d = ImmutableArray.CreateBuilder <DeserializableMember>(); } d.Add(toAdd); return(this); }
protected AstNode(Parser?parser, Position startLoc, Position endLoc) { Source = parser?.SourceFile; Start = startLoc; End = endLoc; }
public AstInfinity(Parser?parser, Position startLoc, Position endLoc) : base(parser, startLoc, endLoc) { }
public AstSequence(Parser?parser, Position startLoc, Position endLoc, ref StructList <AstNode> expressions) : base(parser, startLoc, endLoc) { Expressions.TransferFrom(ref expressions); }
protected AstConstant(Parser?parser, Position startLoc, Position endLoc) : base(parser, startLoc, endLoc) { }