Beispiel #1
0
        public override IEnumerable <StructureBase> VisitStateDefinition(CdeltaParser.StateDefinitionContext context)
        {
            var result = new State(context.IDENTIFIER().GetText())
            {
                IsStart = context.START() != null,
                IsEnd   = context.END() != null,
            };

            foreach (var child in base.VisitStateDefinition(context))
            {
                if (child is StateEnter enter)
                {
                    enter.Parent = result;
                    result.Enter = enter;
                }
                else if (child is StateExit exit)
                {
                    exit.Parent = result;
                    result.Exit = exit;
                }
            }

            yield return(result);
        }
        public override object VisitStateDefinition(CdeltaParser.StateDefinitionContext context)
        {
            State state = new State(context.IDENTIFIER().GetText(), context.START() != null, context.END() != null);

            ((Automaton)contextWithStructure[context.Parent]).States.Add(state.Name, state);
            contextWithStructure.Add(context, state);

            return(base.VisitStateDefinition(context));
        }