Exemple #1
0
        public static GMacConstant Translate(GMacSymbolTranslatorContext context, ParseTreeNode node)
        {
            context.PushState(RoleNames.Constant, node);

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

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

            context.PopState();

            var result = translator._generatedConstant;

            //MasterPool.Release(translator);

            return(result);
        }
Exemple #2
0
        private void translate_GMacDSL_Items_List(ParseTreeNode node)
        {
            if (CompilationLog.HasErrors && CompilationLog.StopOnFirstError)
            {
                return;
            }

            var subnode = node.ChildNodes[0];

            if (_translateNamespaceFirst && subnode.Term.ToString() != GMacParseNodeNames.Namespace)
            {
                CompilationLog.RaiseGeneratorError <int>("DSL definitions must start with a namespace", subnode);
            }

            _translateNamespaceFirst = false;

            switch (subnode.Term.ToString())
            {
            case GMacParseNodeNames.Breakpoint:
                GMacRootAst.EnableBreakpoints = true;
                break;

            case GMacParseNodeNames.Namespace:
                GMacNamespaceGenerator.Translate(Context, subnode);
                break;

            case GMacParseNodeNames.OpenNamespace:
                //Only namespaces and frames can be used in the 'open' statement
                Context.OpenScope(
                    (SymbolWithScope)GMacValueAccessGenerator.Translate_Direct(
                        Context,
                        subnode.ChildNodes[0],
                        new[] { RoleNames.Namespace, RoleNames.Frame }
                        )
                    );

                break;

            case GMacParseNodeNames.Frame:
                GMacFrameGenerator.Translate(Context, subnode);
                break;

            case GMacParseNodeNames.Constant:
                GMacConstantGenerator.Translate(Context, subnode);
                break;

            case GMacParseNodeNames.Structure:
                GMacStructureGenerator.Translate(Context, subnode);
                break;

            case GMacParseNodeNames.Transform:
                GMacTransformGenerator.Translate(Context, subnode);
                break;

            case GMacParseNodeNames.Macro:
                GMacMacroGenerator.Translate(Context, subnode);
                break;

            case GMacParseNodeNames.MacroTemplate:
                GMacMacroTemplateGenerator.Translate(Context, subnode);
                break;

            case GMacParseNodeNames.TemplatesImplementation:
                GMacTemplatesImplementationGenerator.Translate(Context, subnode);
                break;

            default:
                CompilationLog.RaiseGeneratorError <int>("DSL definitions item not recognized", subnode);
                break;
            }
        }