Ejemplo n.º 1
0
 public static IPopulateScope <WeakMemberReference, ISetUpMember> PopulateScope(
     IKey item,
     bool v,
     IPopulateScope <IWeakTypeReference, ISetUpTypeReference> typeToken)
 {
     return(new MemberDefinitionPopulateScope(item, v, typeToken));
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public BinaryPopulateScope(IPopulateScope <IFrontendType> left,
                            IPopulateScope <IFrontendType> right,
                            BinaryOperation.MakeBinaryType <IWeakTypeReference> make)
 {
     this.left  = left ?? throw new ArgumentNullException(nameof(left));
     this.right = right ?? throw new ArgumentNullException(nameof(right));
     this.make  = make ?? throw new ArgumentNullException(nameof(make));
 }
Ejemplo n.º 4
0
 public static IPopulateScope <IWeakTypeReference> PopulateScope(IPopulateScope <IConvertableFrontendType <IVerifiableType> > left,
                                                                 IPopulateScope <IConvertableFrontendType <IVerifiableType> > right,
                                                                 BinaryOperation.MakeBinaryType <IWeakTypeReference> make)
 {
     return(new BinaryPopulateScope(left,
                                    right,
                                    make));
 }
Ejemplo n.º 5
0
 public BinaryPopulateScope(IPopulateScope <IFrontendCodeElement, ISetUpValue> left,
                            IPopulateScope <IFrontendCodeElement, ISetUpValue> right,
                            BinaryOperation.Make <TFrontendCodeElement> make)
 {
     this.left  = left ?? throw new ArgumentNullException(nameof(left));
     this.right = right ?? throw new ArgumentNullException(nameof(right));
     this.make  = make ?? throw new ArgumentNullException(nameof(make));
 }
Ejemplo n.º 6
0
 public PopulateScopeImplementationDefinition(
     IPopulateScope <WeakMemberReference, ISetUpMember> contextDefinition,
     IPopulateScope <WeakMemberReference, ISetUpMember> parameterDefinition,
     IPopulateScope <IFrontendCodeElement, ISetUpSideNode>[] elements,
     IPopulateScope <WeakMemberReference, ISetUpMember> output)
 {
     this.contextDefinition   = contextDefinition ?? throw new ArgumentNullException(nameof(contextDefinition));
     this.parameterDefinition = parameterDefinition ?? throw new ArgumentNullException(nameof(parameterDefinition));
     this.elements            = elements ?? throw new ArgumentNullException(nameof(elements));
     this.output = output ?? throw new ArgumentNullException(nameof(output));
 }
Ejemplo n.º 7
0
 public static IPopulateScope <WeakMethodDefinition, ISetUpMethod> PopulateScope(
     IPopulateScope <WeakMemberReference, ISetUpMember> parameterDefinition,
     IPopulateScope <IConvertableFrontendCodeElement <ICodeElement>, ISetUpSideNode>[] elements,
     IPopulateScope <WeakMemberReference, ISetUpMember> output,
     bool isEntryPoint)
 {
     return(new MethodDefinitionPopulateScope(parameterDefinition,
                                              elements,
                                              output,
                                              isEntryPoint));
 }
Ejemplo n.º 8
0
 public static IPopulateScope <WeakImplementationDefinition, ISetUpMethod> PopulateScope(
     IPopulateScope <WeakMemberReference, ISetUpMember> contextDefinition,
     IPopulateScope <WeakMemberReference, ISetUpMember> parameterDefinition,
     IPopulateScope <IConvertableFrontendCodeElement <ICodeElement>, ISetUpSideNode>[] elements,
     IPopulateScope <WeakMemberReference, ISetUpMember> output)
 {
     return(new PopulateScopeImplementationDefinition(
                contextDefinition,
                parameterDefinition,
                elements,
                output));
 }
Ejemplo n.º 9
0
 public MethodDefinitionPopulateScope(
     IPopulateScope <WeakMemberReference, ISetUpMember> parameterDefinition,
     IPopulateScope <IFrontendCodeElement, ISetUpSideNode>[] elements,
     IPopulateScope <WeakMemberReference, ISetUpMember> output,
     bool isEntryPoint
     )
 {
     this.parameterDefinition = parameterDefinition ?? throw new ArgumentNullException(nameof(parameterDefinition));
     this.elements            = elements ?? throw new ArgumentNullException(nameof(elements));
     this.output       = output ?? throw new ArgumentNullException(nameof(output));
     this.isEntryPoint = isEntryPoint;
 }
Ejemplo n.º 10
0
 public WeakAssignOperationPopulateScope(IPopulateScope <IFrontendCodeElement> left,
                                         IPopulateScope <IFrontendCodeElement> right)
 {
     this.left  = left ?? throw new ArgumentNullException(nameof(left));
     this.right = right ?? throw new ArgumentNullException(nameof(right));;
 }
Ejemplo n.º 11
0
 public MemberDefinitionPopulateScope(IKey item, bool v, IPopulateScope <IWeakTypeReference, ISetUpTypeReference> typeToken)
 {
     memberName = item ?? throw new ArgumentNullException(nameof(item));
     isReadonly = v;
     type       = typeToken ?? throw new ArgumentNullException(nameof(typeToken));
 }
Ejemplo n.º 12
0
 public TrailingPopulateScope(IPopulateScope <IFrontendCodeElement> left, TrailingOperation.Make <TFrontendCodeElement> make)
 {
     this.left = left ?? throw new ArgumentNullException(nameof(left));
     this.make = make ?? throw new ArgumentNullException(nameof(make));
 }
Ejemplo n.º 13
0
 public static IPopulateScope <TFrontendCodeElement> PopulateScope(IPopulateScope <IConvertableFrontendCodeElement <ICodeElement> > left,
                                                                   TrailingOperation.Make <TFrontendCodeElement> make)
 {
     return(new TrailingPopulateScope(left, make));
 }
Ejemplo n.º 14
0
 public WeakPathOperationPopulateScope(IPopulateScope <IFrontendCodeElement> left,
                                       string name)
 {
     this.left = left ?? throw new ArgumentNullException(nameof(left));
     this.name = name ?? throw new ArgumentNullException(nameof(name));
 }
Ejemplo n.º 15
0
        public ITokenMatching <IPopulateScope <WeakMethodDefinition, ISetUpMethod> > TryMake(IMatchedTokenMatching tokenMatching)
        {
            {
                IPopulateScope <IWeakTypeReference, ISetUpTypeReference> inputType = null, outputType = null;
                var matching = tokenMatching
                               .Has(new KeyWordMaker("method"), out var _)
                               .HasSquare(x => x
                                          .HasLine(y => y
                                                   .HasElement(z => z.Has(new TypeMaker(), out inputType))
                                                   .Has(new DoneMaker()))
                                          .HasLine(y => y
                                                   .HasElement(z => z.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);

                    var parameterDefinition = MemberDefinitionMaker.PopulateScope(
                        new NameKey(parameterName?.Item ?? "input"),
                        false,
                        inputType
                        );

                    var resultDefinition = MemberDefinitionMaker.PopulateScope(
                        new ImplicitKey(),
                        false,
                        outputType
                        );

                    return(TokenMatching <IPopulateScope <WeakMethodDefinition, ISetUpMethod> > .MakeMatch(
                               matched.Tokens,
                               matched.Context,
                               new MethodDefinitionPopulateScope(
                                   parameterDefinition,
                                   elements,
                                   resultDefinition,
                                   false)
                               ));
                }
            }
            {
                var matching = tokenMatching
                               .Has(new KeyWordMaker("entry-point"), out var _)
                               .Has(new BodyMaker(), out var body);
                if (matching
                    is IMatchedTokenMatching matched)
                {
                    var elements = matching.Context.ParseBlock(body);

                    var parameterDefinition = MemberDefinitionMaker.PopulateScope(
                        new NameKey("input"),
                        false,
                        TypeReferanceMaker.PopulateScope(new NameKey("empty"))
                        );


                    var resultDefinition = MemberDefinitionMaker.PopulateScope(
                        new ImplicitKey(),
                        false,
                        TypeReferanceMaker.PopulateScope(new NameKey("empty"))
                        );

                    return(TokenMatching <IPopulateScope <WeakMethodDefinition, ISetUpMethod> > .MakeMatch(
                               matched.Tokens,
                               matched.Context,
                               new MethodDefinitionPopulateScope(
                                   parameterDefinition,
                                   elements,
                                   resultDefinition,
                                   true)
                               ));
                }

                return(TokenMatching <IPopulateScope <WeakMethodDefinition, ISetUpMethod> > .MakeNotMatch(
                           matching.Context));
            }
        }
Ejemplo n.º 16
0
 public static IPopulateScope <TFrontendCodeElement, ISetUpValue> PopulateScope(IPopulateScope <IFrontendCodeElement> left,
                                                                                IPopulateScope <IFrontendCodeElement> right,
                                                                                BinaryOperation.Make <TFrontendCodeElement> make)
 {
     return(new BinaryPopulateScope(left,
                                    right,
                                    make));
 }