Esempio n. 1
0
        public override Result VisitPlcsim_main([NotNull] plcsimParser.Plcsim_mainContext context)
        {
            //命令語の解析
            var retInst = InstructionAnalyzer.TryAnalyze(context.instruction());

            if (!retInst.IsSuccess)
            {
                return(retInst);
            }
            var inst = retInst.Info as Instruction;

            //オペランドの解析
            var operands = new List <IOperand>();
            var retOpe   = OperandAnalyzer.TryAnalyze(context.operand(), ref operands);

            if (!retOpe.IsSuccess)
            {
                return(retOpe);
            }

            // 命令語実行
            var errid = InstructionExecuter.Execute(_plc, inst, operands);

            if (errid != ErrString.ErrID.None)
            {
                return(new Result(false, errid));
            }

            return(new Result(true, 0));
        }
Esempio n. 2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>plcsim_main</c>
 /// labeled alternative in <see cref="plcsimParser.mnemonic"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitPlcsim_main([NotNull] plcsimParser.Plcsim_mainContext context)
 {
     return(VisitChildren(context));
 }