示例#1
0
        private void BuildGetValidSyntaxCore(ParserCompiler compiler, ParserBuilder parserBuilder, IIntermediateCliManager identityManager)
        {
            var targetClassPartial = parserBuilder.ParserClass.Parts.Add();

            this._getValidSyntaxMethodImpl         = targetClassPartial.Methods.Add(new TypedName("GetValidSyntax", compiler.LexicalSymbolModel.ValidSymbols));
            this._getValidSyntaxMethod             = parserBuilder.ParserInterface.Methods.Add(new TypedName("GetValidSyntax", compiler.LexicalSymbolModel.ValidSymbols));
            this._getValidSyntaxMethodInternalImpl =
                targetClassPartial.Methods.Add(
                    new TypedName("GetValidSyntaxInternal", compiler.LexicalSymbolModel.ValidSymbols),
                    new TypedNameSeries(
                        new TypedName("state", RuntimeCoreType.Int32, identityManager),
                        new TypedName("ruleContext", compiler.RuleSymbolBuilder.ILanguageRuleSymbol),
                        new TypedName("initialPass", RuntimeCoreType.Boolean, identityManager)));
        }
示例#2
0
        private static IIntermediateClassMethodMember BuildMethodOn(IType returnType, IIntermediateInterfaceType visitorInterface, IType voidType, IIntermediateInterfaceMethodMember method, IIntermediateClassType ruleClass, bool skipBody = false)
        {
            var ruleVisit = ruleClass.Methods.Add(
                new TypedName("Accept", returnType),
                new TypedNameSeries(new TypedName("visitor", visitorInterface)));

            if (returnType.IsGenericTypeParameter)
            {
                ruleVisit.TypeParameters.Add(returnType.Name);
            }
            ruleVisit.AccessLevel = AccessLevelModifiers.Public;
            ruleVisit.IsOverride  = true;
            if (!skipBody)
            {
                if (returnType != voidType)
                {
                    ruleVisit.Return(method.GetReference(ruleVisit.Parameters["visitor"].GetReference()).Invoke(new SpecialReferenceExpression(SpecialReferenceKind.This)));
                }
                else
                {
                    ruleVisit.Call(method.GetReference(ruleVisit.Parameters["visitor"].GetReference()).Invoke(new SpecialReferenceExpression(SpecialReferenceKind.This)));
                }
            }
            return(ruleVisit);
        }
示例#3
0
        private static IIntermediateClassMethodMember AddVisitMethodToClass(IType returnType, IType voidType, IIntermediateInterfaceType visitorInterface, IIntermediateClassType visitedClass, bool isAbstract, IIntermediateInterfaceMethodMember memberToVisit)
        {
            var rootVisit = visitedClass.Methods.Add(
                new TypedName("Accept", returnType),
                new TypedNameSeries(new TypedName("visitor", visitorInterface)));

            if (returnType.IsGenericTypeParameter)
            {
                rootVisit.TypeParameters.Add(returnType.Name);
            }
            rootVisit.SummaryText = "Invokes the appropriate overload for the current @p:visitor;.";
            rootVisit.AccessLevel = AccessLevelModifiers.Public;
            var invocation = isAbstract ? null : memberToVisit.GetReference(rootVisit.Parameters["visitor"].GetReference()).Invoke(new SpecialReferenceExpression(SpecialReferenceKind.This));

            if (isAbstract)
            {
                rootVisit.IsAbstract = true;
            }
            else if (returnType != voidType)
            {
                rootVisit.Return(invocation);
            }
            else
            {
                rootVisit.Call(invocation);
            }
            return(rootVisit);
        }