public static CompositeExpression Translate(GMacSymbolTranslatorContext context, ParseTreeNode node)
        {
            context.PushState(node);

            var translator = new GMacExpressionCompositeGenerator();//new GMacExpressionCompositeGenerator(context);

            translator.SetContext(context);
            translator.Translate();

            context.PopState();

            var result = translator._generatedExpression;

            //MasterPool.Release(translator);

            return(result);
        }
Пример #2
0
        //private ILanguageExpression translate_Expression_Cast(ParseTreeNode node)
        //{
        //    var langType = GMacValueAccessGenerator.Translate_Direct_LanguageType(this.Context, node.ChildNodes[0]);

        //    var expr = GMacExpressionGenerator.Translate(this.BasicExpressionGenerator, node.ChildNodes[0]);

        //    return this.BasicExpressionGenerator.Generate_TypeCast(langType, expr);
        //}

        protected override void Translate()
        {
            var subNode = RootParseNode.ChildNodes[0];

            switch (subNode.Term.Name)
            {
            case GMacParseNodeNames.ConstantNumber:
                _generatedExpression = translate_Constant_Number(subNode);
                break;

            case GMacParseNodeNames.ExpressionScoped:
                _generatedExpression = translate_Expression_Scoped(subNode);
                break;

            case GMacParseNodeNames.QualifiedItem:
                _generatedExpression = GMacValueAccessGenerator.Translate(Context, subNode.ChildNodes[0], false);
                break;

            case GMacParseNodeNames.ExpressionBracketed:
                _generatedExpression = GMacExpressionGenerator.Translate(BasicExpressionGenerator, subNode.ChildNodes[0]);
                break;

            case GMacParseNodeNames.StringLiteral:
                _generatedExpression = GMacExpressionAtomicSymbolicGenerator.Translate(Context, subNode);
                break;

            case GMacParseNodeNames.ExpressionComposite:
                _generatedExpression = GMacExpressionCompositeGenerator.Translate(Context, subNode);
                break;

            case GMacParseNodeNames.ExpressionFunction:
                _generatedExpression = GMacExpressionAtomicFunctionGenerator.Translate(BasicExpressionGenerator, subNode);
                break;

            default:
                CompilationLog.RaiseGeneratorError <ILanguageExpression>("Expression not recognized", RootParseNode);
                break;
            }
        }