public ITokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > TryMake(IMatchedTokenMatching tokenMatching) { if (tokenMatching.AllTokens[tokenMatching.EndIndex].Is2(out var setUp) && setUp.SafeIs(out ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> alreadyMatched)) { return(TokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > .MakeMatch( tokenMatching, alreadyMatched, tokenMatching.EndIndex + 1)); } if (tokenMatching.AllTokens[tokenMatching.EndIndex].Is1(out var token) && token.SafeIs(out ParenthesisToken parenthesisToken) && parenthesisToken.Tokens.Count() == 1) { var line = parenthesisToken.Tokens.First().SafeCastTo(out LineToken _); var matching = TokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > .MakeStart(line.Tokens.Select(x => OrType.Make <IToken, ISetUp>(x)).ToArray(), tokenMatching.Context, 0); // you can be an or again (z | b) | c is legal var res = new TypeMaker().TryMake(matching); if (res is IMatchedTokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > matched) { return(TokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > .MakeMatch( tokenMatching, matched.Value, tokenMatching.EndIndex + 1)); } else { return(TokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > .MakeNotMatch( tokenMatching.Context)); } } { if (tokenMatching.Has(new TypeDefinitionMaker(), out var type) is IMatchedTokenMatching matched) { return(TokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > .MakeMatch( tokenMatching, type, matched.EndIndex)); } } { if (tokenMatching.Has(new TypeReferanceMaker(), out var type) is IMatchedTokenMatching matched) { return(TokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > .MakeMatch( tokenMatching, type, matched.EndIndex)); } } return(TokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > .MakeNotMatch( tokenMatching.Context)); }
public ITokenMatching <IPopulateScope <IWeakTypeReference, ISetUpTypeReference> > TryMake(IMatchedTokenMatching tokenMatching) { { if (tokenMatching.Has(new TypeDefinitionMaker(), out var type) is IMatchedTokenMatching matched) { return(TokenMatching <IPopulateScope <IWeakTypeReference, ISetUpTypeReference> > .MakeMatch( matched.Tokens, matched.Context, type)); } } { if (tokenMatching.Has(new TypeReferanceMaker(), out var type) is IMatchedTokenMatching matched) { return(TokenMatching <IPopulateScope <IWeakTypeReference, ISetUpTypeReference> > .MakeMatch( matched.Tokens, matched.Context, type)); } } // TODO // I need a more well-rounded approach to parenthesis // I don't think this will work generally at all // gosh, what to do? I don't really want to kick the can down the road, // but I don't feel like I understand it well enough to make changes // I mean for the short term I am just going to jam all the type operators in here // maybe that is ok if (tokenMatching.Tokens.First() is ParenthesisToken parenthesisToken) { if (TokenMatching <IPopulateScope <IWeakTypeReference, ISetUpType> > .MakeStart(parenthesisToken.Tokens.ToArray(), tokenMatching.Context).Has(new TypeOrOperationMaker(), out var type) is IMatchedTokenMatching matched) { return(TokenMatching <IPopulateScope <IWeakTypeReference, ISetUpTypeReference> > .MakeMatch( tokenMatching.Tokens.Skip(1).ToArray(), matched.Context, type)); } } return(TokenMatching <IPopulateScope <IWeakTypeReference, ISetUpTypeReference> > .MakeNotMatch( tokenMatching.Context)); }
public ITokenMatching <ISetUp <IBox <WeakObjectDefinition>, Tpn.IValue> > TryMake(IMatchedTokenMatching tokenMatching) { return(tokenMatching .Has(new KeyWordMaker("object")) .Has(new BodyMaker()) .ConvertIfMatched((_, block) => new ObjectDefinitionPopulateScope(tokenMatching.Context.ParseBlock(block)), tokenMatching)); }
public ITokenMatching <ISetUp <IBox <WeakEmptyInstance>, Tpn.IValue> > TryMake(IMatchedTokenMatching tokenMatching) { // change key word to nothing? return(tokenMatching .Has(new KeyWordMaker("new-empty"), out var _) .ConvertIfMatched(() => new EmptyInstancePopulateScope(), tokenMatching)); }
public ITokenMatching <ISetUp <IBox <WeakPathOperation>, Tpn.TypeProblem2.Member> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new BinaryOperationMatcher(SymbolsRegistry.StaticPathSymbol), out (ISetUp lhs, ISetUp rhs)match); if (matching is IMatchedTokenMatching matched) { var left = OrType.Make <ISetUp <IBox <IFrontendCodeElement>, Tpn.ITypeProblemNode>, IError>(match.lhs.SafeCastTo(out ISetUp <IBox <IFrontendCodeElement>, Tpn.ITypeProblemNode> _)); var right = OrType.Make <MemberPopulateScope, IError>(match.rhs.SafeCastTo(out MemberPopulateScope _)); var res = new WeakPathOperationPopulateScope(left, right.TransformInner(x => x.memberName)); //if (left.Is1(out var leftValue)) //{ // tokenMatching.Context.Map.SetElementParent(leftValue, res); //} //if (right.Is1(out var rightValue)) //{ // tokenMatching.Context.Map.SetElementParent(rightValue, res); //} return(TokenMatching <ISetUp <IBox <WeakPathOperation>, Tpn.TypeProblem2.Member> > .MakeMatch( tokenMatching, res, matched.EndIndex)); } return(TokenMatching <ISetUp <IBox <WeakPathOperation>, Tpn.TypeProblem2.Member> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <IPopulateScope <WeakImplementationDefinition, ISetUpMethod> > TryMake(IMatchedTokenMatching tokenMatching) { IPopulateScope <IWeakTypeReference, ISetUpTypeReference> context = null, input = null, output = null; var match = tokenMatching .Has(new KeyWordMaker("implementation"), out var _) .HasSquare(x => x .HasLine(y => y .HasElement(z => z.Has(new TypeMaker(), out context)) .Has(new DoneMaker())) .HasLine(y => y .HasElement(z => z.Has(new TypeMaker(), out input)) .Has(new DoneMaker())) .HasLine(y => y .HasElement(z => z.Has(new TypeMaker(), out output)) .Has(new DoneMaker())) .Has(new DoneMaker())) .OptionalHas(new NameMaker(), out var contextName) .OptionalHas(new NameMaker(), out var parameterName) .Has(new BodyMaker(), out var body); if (match is IMatchedTokenMatching matched) { var elements = tokenMatching.Context.ParseBlock(body); var contextNameString = contextName?.Item ?? "context"; var contextDefinition = MemberDefinitionMaker.PopulateScope( new NameKey(contextNameString), false, context ); var parameterNameString = parameterName?.Item ?? "input"; var parameterDefinition = MemberDefinitionMaker.PopulateScope( new NameKey(parameterNameString), false, input ); var resultDefinition = MemberDefinitionMaker.PopulateScope( new ImplicitKey(), false, output ); return(TokenMatching <IPopulateScope <WeakImplementationDefinition, ISetUpMethod> > .MakeMatch( matched.Tokens, matched.Context, new PopulateScopeImplementationDefinition( contextDefinition, parameterDefinition, elements, resultDefinition))); } return(TokenMatching <IPopulateScope <WeakImplementationDefinition, ISetUpMethod> > .MakeNotMatch(match.Context)); }
public ITokenMatching <ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> > TryMake(IMatchedTokenMatching tokenMatching) { return(tokenMatching .Has(new KeyWordMaker("type"), out var _) .OptionalHas(new NameMaker(), out var typeName) .Has(new BodyMaker()).ConvertIfMatched(body => new TypeDefinitionPopulateScope( tokenMatching.Context.ParseType(body), typeName != default ? OrType.Make <NameKey, ImplicitKey>(new NameKey(typeName.Item)) : OrType.Make <NameKey, ImplicitKey>(new ImplicitKey(Guid.NewGuid()))), tokenMatching)); }
public ITokenMatching <ISetUp <IBox <WeakConstantNumber>, Tpn.IValue> > TryMake(IMatchedTokenMatching tokenMatching) { var match = tokenMatching .Has(new NumberMaker(), out var dub); if (match is IMatchedTokenMatching matched) { return(TokenMatching <ISetUp <IBox <WeakConstantNumber>, Tpn.IValue> > .MakeMatch(tokenMatching, new ConstantNumberPopulateScope(dub), matched.EndIndex)); } return(TokenMatching <ISetUp <IBox <WeakConstantNumber>, Tpn.IValue> > .MakeNotMatch(tokenMatching.Context)); }
public ITokenMatching <IPopulateScope <WeakConstantString, ISetUpValue> > TryMake(IMatchedTokenMatching tokenMatching) { var match = tokenMatching .Has(new StringMaker(), out var str); if (match is IMatchedTokenMatching matched) { return(TokenMatching <IPopulateScope <WeakConstantString, ISetUpValue> > .MakeMatch(matched.Tokens.Skip(1).ToArray(), matched.Context, new ConstantStringPopulateScope(str))); } return(TokenMatching <IPopulateScope <WeakConstantString, ISetUpValue> > .MakeNotMatch(tokenMatching.Context)); }
public ITokenMatching <IKey[]> TryMake(IMatchedTokenMatching elementToken) { if (elementToken.Has(new GenericNMaker(), out var collection).SafeIs(out IMatchedTokenMatching <IKey[]> matched)) { return(TokenMatching <IKey[]> .MakeMatch( elementToken, collection !, matched.EndIndex)); } return(TokenMatching <IKey[]> .MakeNotMatch(elementToken.Context)); }
public ITokenMatching <IPopulateScope <WeakEmptyInstance, ISetUpValue> > TryMake(IMatchedTokenMatching tokenMatching) { // change key word to nothing? var match = tokenMatching .Has(new KeyWordMaker("new-empty"), out var _); if (match is IMatchedTokenMatching matched) { return(TokenMatching <IPopulateScope <WeakEmptyInstance, ISetUpValue> > .MakeMatch(matched.Tokens.Skip(1).ToArray(), matched.Context, new EmptyInstancePopulateScope())); } return(TokenMatching <IPopulateScope <WeakEmptyInstance, ISetUpValue> > .MakeNotMatch(tokenMatching.Context)); }
public ITokenMatching <ISetUp <IBox <WeakGenericTypeDefinition>, Tpn.IExplicitType> > TryMake(IMatchedTokenMatching tokenMatching) { return(tokenMatching .Has(new KeyWordMaker("type"), out var _) .Has(new DefineGenericNMaker()) .Has(new NameMaker()) .Has(new BodyMaker()) .ConvertIfMatched((_, generics, name, lines) => { return new GenericTypeDefinitionPopulateScope( new NameKey(name.Item), tokenMatching.Context.ParseBlock(lines), generics.Select(x => new NameKey(x)).ToArray()); }, tokenMatching)); }
public ITokenMatching <ISetUp <IBox <TFrontendCodeElement>, Tpn.IValue> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new BinaryOperationMatcher(Symbol), out var _); return(matching.ConvertIfMatched(match => { var left = OrType.Make <ISetUp <IBox <IFrontendCodeElement>, Tpn.ITypeProblemNode>, IError>(match.lhs.SafeCastTo(out ISetUp <IBox <IFrontendCodeElement>, Tpn.ITypeProblemNode> _)); var right = OrType.Make <ISetUp <IBox <IFrontendCodeElement>, Tpn.ITypeProblemNode>, IError>(match.rhs.SafeCastTo(out ISetUp <IBox <IFrontendCodeElement>, Tpn.ITypeProblemNode> _)); var res = new BinaryPopulateScope <TFrontendCodeElement, TCodeElement>(left, right, Make, keyMaker, intoInitScope); return res; }, tokenMatching)); }
public ITokenMatching <IPopulateScope <IWeakTypeReference, ISetUpTypeReference> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new TypeNameMaker(), out var name); if (matching is IMatchedTokenMatching matched) { return(TokenMatching <IPopulateScope <IWeakTypeReference, ISetUpTypeReference> > .MakeMatch( matched.Tokens, matched.Context, new TypeReferancePopulateScope(name))); } return(TokenMatching <IPopulateScope <IWeakTypeReference, ISetUpTypeReference> > .MakeNotMatch(matching.Context)); }
public ITokenMatching <IPopulateScope <WeakMemberReference, ISetUpMember> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new NameMaker(), out var first); if (matching is IMatchedTokenMatching matched) { return(TokenMatching <IPopulateScope <WeakMemberReference, ISetUpMember> > .MakeMatch( matched.Tokens, matched.Context, new MemberPopulateScope(first.Item)));; } return(TokenMatching <IPopulateScope <WeakMemberReference, ISetUpMember> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <IPopulateScope <WeakBlockDefinition, ISetUpScope> > TryMake(IMatchedTokenMatching tokenMatching) { var match = tokenMatching .Has(new BodyMaker(), out var body); if (match is IMatchedTokenMatching matched) { var elements = tokenMatching.Context.ParseBlock(body); return(TokenMatching <IPopulateScope <WeakBlockDefinition, ISetUpScope> > .MakeMatch(matched.Tokens.Skip(1).ToArray(), matched.Context, new BlockDefinitionPopulateScope(elements))); } return(TokenMatching <IPopulateScope <WeakBlockDefinition, ISetUpScope> > .MakeNotMatch(tokenMatching.Context)); }
public ITokenMatching <ISetUp <IBox <WeakBlockDefinition>, Tpn.IScope> > TryMake(IMatchedTokenMatching tokenMatching) { var match = tokenMatching .Has(new BodyMaker(), out var body); if (match is IMatchedTokenMatching matched) { var elements = tokenMatching.Context.ParseBlock(body); return(TokenMatching <ISetUp <IBox <WeakBlockDefinition>, Tpn.IScope> > .MakeMatch(tokenMatching, new BlockDefinitionPopulateScope(elements), matched.EndIndex)); } return(TokenMatching <ISetUp <IBox <WeakBlockDefinition>, Tpn.IScope> > .MakeNotMatch(tokenMatching.Context)); }
public ITokenMatching <IPopulateScope <TFrontendCodeElement> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new TrailingOperationMatcher(Symbol), out (IEnumerable <IToken> perface, AtomicToken _)res); if (matching is IMatchedTokenMatching matched) { var left = matching.Context.ParseLine(res.perface); return(TokenMatching <IPopulateScope <TFrontendCodeElement> > .MakeMatch( matched.Tokens, matched.Context, new TrailingPopulateScope(left, Make))); } return(TokenMatching <IPopulateScope <TFrontendCodeElement> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <IPopulateScope <WeakObjectDefinition, ISetUpObject> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new KeyWordMaker("object"), out var _) .Has(new BodyMaker(), out var block); if (matching is IMatchedTokenMatching matched) { var elements = tokenMatching.Context.ParseBlock(block); return(TokenMatching <IPopulateScope <WeakObjectDefinition, ISetUpObject> > .MakeMatch( matched.Tokens, matched.Context, new ObjectDefinitionPopulateScope(elements))); } return(TokenMatching <IPopulateScope <WeakObjectDefinition, ISetUpObject> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <ISetUp <IBox <TFrontendCodeElement>, Tpn.IValue> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new TrailingOperationMatcher(Symbol), out var _); return(matching.ConvertIfMatched(match => { //var left = tokenMatching.Context.Map.GetGreatestParent(match.perface); var res = new TrailingPopulateScope <TFrontendCodeElement, TCodeElement>(OrType.Make <ISetUp <IBox <IFrontendCodeElement>, Tpn.ITypeProblemNode>, IError>(match.SafeCastTo(out ISetUp <IBox <IFrontendCodeElement>, Tpn.ITypeProblemNode> _)), Make, getReturnedValue, intoInitScope); //if (left.Is1(out var leftValue)) //{ // tokenMatching.Context.Map.SetElementParent(leftValue, res); //} return res; }, tokenMatching)); }
public ITokenMatching <ISetUp <IBox <WeakImplementationDefinition>, Tpn.IValue> > TryMake(IMatchedTokenMatching tokenMatching) { // this is not great // but the typing here is hard to get right #pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> context = null, input = null, output = null; #pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type. var match = tokenMatching .Has(new KeyWordMaker("implementation"), out var _) .HasSquare(x => x .HasLine(y => y .Has(new TypeMaker(), out context) .Has(new DoneMaker())) .HasLine(y => y .Has(new TypeMaker(), out input) .Has(new DoneMaker())) .HasLine(y => y .Has(new TypeMaker(), out output) .Has(new DoneMaker())) .Has(new DoneMaker())) .OptionalHas(new NameMaker(), out var contextName) .OptionalHas(new NameMaker(), out var parameterName) .Has(new BodyMaker(), out var body); if (match is IMatchedTokenMatching matched) { var elements = tokenMatching.Context.ParseBlock(body !); return(TokenMatching <ISetUp <IBox <WeakImplementationDefinition>, IValue> > .MakeMatch( tokenMatching, new PopulateScopeImplementationDefinition( context !, input !, elements, output !, contextName?.Item ?? "context", parameterName?.Item ?? "input"), matched.EndIndex)); } return(TokenMatching <ISetUp <IBox <WeakImplementationDefinition>, IValue> > .MakeNotMatch(match.Context)); }
public ITokenMatching <IPopulateScope <WeakAssignOperation> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new BinaryOperationMatcher(SymbolsRegistry.StaticAssertAssignSymbol), out (IReadOnlyList <IToken> perface, AtomicToken token, IToken rhs)match); if (matching is IMatchedTokenMatching matched) { var left = matching.Context.ParseLine(match.perface); var right = matching.Context.ParseParenthesisOrElement(match.rhs); return(TokenMatching <IPopulateScope <WeakAssignOperation> > .MakeMatch( matched.Tokens, matched.Context, new WeakAssignOperationPopulateScope(left, right))); } return(TokenMatching <IPopulateScope <WeakAssignOperation> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <IKey> TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new NameMaker(), out var typeName); if (matching is IMatchedTokenMatching matched) { var list = new List <IKey>(); var genericMatachig = matching .HasSquare(x => { while (true) { // colin, why! w x y z // you are an adult arn't you? var item = default(IKey); var y = x.HasLine(z => z.Has(new KeyMatcher(), out item)); if (y is IMatchedTokenMatching w) { x = w; list.Add(item !); if (w.AllTokens.Any().Not()) { return(w); } } else { return(y); } } }); if (genericMatachig is IMatchedTokenMatching genericMatched) { return(TokenMatching <IKey> .MakeMatch(tokenMatching, new GenericNameKey(new NameKey(typeName.Item), list.Select(x => OrType.Make <IKey, IError>(x)).ToArray().ToArray()), genericMatched.EndIndex)); } return(TokenMatching <IKey> .MakeMatch(tokenMatching, new NameKey(typeName.Item), matched.EndIndex)); } return(TokenMatching <IKey> .MakeNotMatch(matching.Context)); }
public ITokenMatching <IPopulateScope <IWeakTypeReference> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new BinaryOperationMatcher(Symbol), out (IReadOnlyList <IToken> perface, AtomicToken token, IToken rhs)match); if (matching is IMatchedTokenMatching matched) { var left = matching.Context.ParseTypeLine(match.perface); var right = matching.Context.ParseParenthesisOrElementType(match.rhs); return(TokenMatching <IPopulateScope <IWeakTypeReference> > .MakeMatch( matched.Tokens, matched.Context, new BinaryPopulateScope(left, right, Make))); } return(TokenMatching <IPopulateScope <IWeakTypeReference> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <IPopulateScope <WeakModuleDefinition, ISetUpObject> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new KeyWordMaker("module"), out _) .Has(new NameMaker(), out var name) .Has(new BodyMaker(), out var third); if (matching is IMatchedTokenMatching matched) { var elements = matching.Context.ParseBlock(third); var nameKey = new NameKey(name.Item); return(TokenMatching <IPopulateScope <WeakModuleDefinition, ISetUpObject> > .MakeMatch( matched.Tokens, matched.Context, new ModuleDefinitionPopulateScope(elements, nameKey))); } return(TokenMatching <IPopulateScope <WeakModuleDefinition, ISetUpObject> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <ISetUp <IBox <WeakGenericMethodDefinition>, Tpn.TypeProblem2.Method> > TryMake(IMatchedTokenMatching tokenMatching) { #pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. ISetUp <IBox <IFrontendType <IVerifiableType> >, Tpn.TypeProblem2.TypeReference> inputType = null, outputType = null; #pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type. var matching = tokenMatching .Has(new KeyWordMaker("method"), out var _) .Has(new DefineGenericNMaker(), out var generics) .HasSquare(x => x .HasLine(y => y .Has(new TypeMaker(), out inputType) .Has(new DoneMaker())) .HasLine(y => y .Has(new TypeMaker(), out outputType) .Has(new DoneMaker())) .Has(new DoneMaker())) .OptionalHas(new NameMaker(), out var parameterName) .Has(new BodyMaker(), out var body); if (matching is IMatchedTokenMatching matched) { var elements = matching.Context.ParseBlock(body); return(TokenMatching <ISetUp <IBox <WeakGenericMethodDefinition>, Tpn.TypeProblem2.Method> > .MakeMatch( tokenMatching, new GenericMethodDefinitionPopulateScope( inputType !, elements, outputType !, parameterName !.Item, generics.Select(x => new NameKey(x)).ToArray()), matched.EndIndex )); } return(TokenMatching <ISetUp <IBox <WeakGenericMethodDefinition>, Tpn.TypeProblem2.Method> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <IPopulateScope <WeakTryAssignOperation> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new BinaryOperationMatcher(SymbolsRegistry.TryAssignSymbol), out (IReadOnlyList <IToken> perface, AtomicToken token, IToken rhs)res); if (matching is IMatchedTokenMatching matched) { var left = matching.Context.ParseLine(res.perface); var right = matching.Context.ParseParenthesisOrElement(res.rhs); return(TokenMatching <IPopulateScope <WeakTryAssignOperation> > .MakeMatch( matched.Tokens, matched.Context, BinaryOperationMaker <WeakTryAssignOperation, ITryAssignOperation> .PopulateScope(left, right, (l, r) => Possibly.Is( new WeakTryAssignOperation(l, r))))); } return(TokenMatching <IPopulateScope <WeakTryAssignOperation> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <IPopulateScope <IWeakTypeReference, ISetUpType> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new KeyWordMaker("type"), out var _) .OptionalHas(new NameMaker(), out var typeName) .Has(new BodyMaker(), out var body); if (matching is IMatchedTokenMatching matched) { var elements = tokenMatching.Context.ParseBlock(body); return(TokenMatching <IPopulateScope <IWeakTypeReference, ISetUpType> > .MakeMatch( matched.Tokens, matched.Context, new TypeDefinitionPopulateScope( elements, typeName != default ? new NameKey(typeName.Item).Cast <IKey>(): new ImplicitKey()))); } return(TokenMatching <IPopulateScope <WeakTypeReference, ISetUpType> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <IPopulateScope <WeakGenericTypeDefinition, ISetUpType> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new KeyWordMaker("type"), out var _) .Has(new DefineGenericNMaker(), out var genericTypes) .Has(new NameMaker(), out var typeName) .Has(new BodyMaker(), out var body); if (matching is IMatchedTokenMatching matched) { return(TokenMatching <IPopulateScope <WeakGenericTypeDefinition, ISetUpType> > .MakeMatch( matched.Tokens, matched.Context, new GenericTypeDefinitionPopulateScope( new NameKey(typeName.Item), tokenMatching.Context.ParseBlock(body), genericTypes.Select(x => PrimitiveTypes.CreateGenericTypeParameterPlacholder(new NameKey(x))).ToArray()))); } return(TokenMatching <IPopulateScope <WeakGenericTypeDefinition, ISetUpType> > .MakeNotMatch( matching.Context)); }
public ITokenMatching <IPopulateScope <WeakPathOperation> > TryMake(IMatchedTokenMatching tokenMatching) { var matching = tokenMatching .Has(new BinaryOperationMatcher(SymbolsRegistry.StaticPathSymbol), out (IReadOnlyList <IToken> perface, AtomicToken token, IToken rhs)match); if (matching is IMatchedTokenMatching matched) { var matching2 = matched.Has(new NameMaker(), out var first); if (matching2 is IMatchedTokenMatching matched2) { var left = matching.Context.ParseLine(match.perface); //var right = matching.Context.ExpectPathPart(box).ParseParenthesisOrElement(match.rhs); return(TokenMatching <IPopulateScope <WeakPathOperation> > .MakeMatch( matched2.Tokens, matched2.Context, new WeakPathOperationPopulateScope(left, first.Item))); } } return(TokenMatching <IPopulateScope <WeakPathOperation> > .MakeNotMatch( matching.Context)); }