Example #1
0
        public static CommandBlock Translate(GMacSymbolTranslatorContext context, ParseTreeNode node)
        {
            context.PushState(node);

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

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

            context.PopState();

            var result = translator._generatedBlock;

            //MasterPool.Release(translator);

            return(result);
        }
Example #2
0
        private void translate_Macro_Body_CommandBlock(ParseTreeNode node)
        {
            try
            {
                Context.MarkCheckPointState();

                _generatedMacro.SymbolBody = GMacCommandBlockGenerator.Translate(Context, node);

                Context.UnmarkCheckPointState();
                Context.CompilationLog.ReportNormal("Translated Macro Body: " + _generatedMacro.SymbolAccessName, ProgressEventArgsResult.Success);
            }
            catch (CompilerException)
            {
                Context.RestoreToCheckPointState();
                Context.CompilationLog.ReportNormal("Translate Macro Body: " + _generatedMacro.SymbolAccessName, ProgressEventArgsResult.Failure);
            }
            catch (Exception e)
            {
                Context.RestoreToCheckPointState();
                Context.CompilationLog.ReportError("Translate Macro Body Failed With Error: " + _generatedMacro.SymbolAccessName, e);
            }
        }
Example #3
0
        protected override void Translate()
        {
            RootParseNode.Assert(GMacParseNodeNames.Command);

            var oldCommandsCount = Context.ActiveParentCommandBlock.CommandsCount;

            var subNode = RootParseNode.ChildNodes[0];

            switch (subNode.ToString())
            {
            case GMacParseNodeNames.CommandDeclare:
                translate_Command_Declare(subNode);
                break;

            case GMacParseNodeNames.CommandLet:
                translate_Command_Let(subNode);
                break;

            case GMacParseNodeNames.CommandReturn:
                translate_Command_Return(subNode);
                break;

            //case GMacParseNodeNames.Command_Output:
            //    this.translate_Command_Output(sub_node);
            //    break;

            case GMacParseNodeNames.CommandBlock:
                GMacCommandBlockGenerator.Translate(Context, subNode);
                break;

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

            _generatedCommands.AddRange(Context.ActiveParentCommandBlock.Commands.Skip(oldCommandsCount));
        }