예제 #1
0
        public override Expression VisitSignal([NotNull] SignalContext context)
        {
            Signal signal = null;

            if (context.channel().single() != null)
            {
                var varIndex = int.Parse(context.channel().single().index().NUMBER().ToString());

                if (context.nature().input() != null)
                {
                    if (context.nature().input().presAction().HYPHEN() == null)
                    {
                        throw new UnsupportedSyntaxException("Present action of signal", context.nature().input().presAction().Start);
                    }

                    signal = new SingleInputSignal {
                        Name = context.nature().input().IDENTIFIER().ToString(), VarIndex = varIndex
                    };
                }
                else if (context.nature().output() != null)
                {
                    if (context.nature().output().outAction().HYPHEN() == null)
                    {
                        throw new UnsupportedSyntaxException("Output action of signal", context.nature().output().outAction().Start);
                    }

                    signal = new SingleOutputSignal {
                        Name = context.nature().output().IDENTIFIER().ToString(), VarIndex = varIndex
                    };
                }
            }
            else
            {
                throw new UnsupportedSyntaxException($"Channel {context.channel()}", context.channel().Start);
            }

            if (context.@bool() != null)
            {
                signal.BoolIndex = int.Parse(context.@bool().index().NUMBER().ToString());
            }

            Oc5Model.Signals.Add(signal);

            return(null);
        }