Example #1
0
        public override void Apply(CstDeclaration cstDeclaration)
        {
            var node = new DotNode(cstDeclaration.IdShort);

            node.Attributes.Label = $"Declaration.{cstDeclaration.Identity.Name}";
            _graph.Nodes.Add(node);

            cstDeclaration.Identity.Visit(this);
            _graph.Edges.Add(node.Id, cstDeclaration.Identity.IdShort);

            if (cstDeclaration.States != null)
            {
                var statesBlockNode = CreateAttributeNode(nameof(cstDeclaration.States));
                _graph.Nodes.Add(statesBlockNode);

                foreach (var state in cstDeclaration.States)
                {
                    state.Visit(this);
                    _graph.Edges.Add(statesBlockNode.Id, state.IdShort);
                }

                _graph.Edges.Add(node.Id, statesBlockNode.Id);
            }

            var initialBlockNode = CreateAttributeNode(nameof(cstDeclaration.InitialStateName));

            _graph.Nodes.Add(initialBlockNode);

            cstDeclaration.InitialStateName.Visit(this);

            _graph.Edges.Add(initialBlockNode.Id, cstDeclaration.InitialStateName.IdShort);
            _graph.Edges.Add(node.Id, initialBlockNode.Id);

            var finalBlockNode = CreateAttributeNode(nameof(cstDeclaration.Finals));

            _graph.Nodes.Add(finalBlockNode);

            foreach (var final in cstDeclaration.Finals)
            {
                final.Visit(this);
                _graph.Edges.Add(finalBlockNode.Id, final.IdShort);
            }

            _graph.Edges.Add(node.Id, finalBlockNode.Id);

            var tableBlockNode = CreateAttributeNode(nameof(cstDeclaration.Trancitions));

            _graph.Nodes.Add(tableBlockNode);

            foreach (var transition in cstDeclaration.Trancitions)
            {
                transition.Visit(this);
                _graph.Edges.Add(tableBlockNode.Id, transition.IdShort);
            }

            _graph.Edges.Add(node.Id, tableBlockNode.Id);
        }
        public override void Apply(CstDeclaration cstDeclaration)
        {
            var stateMachineArchOptions = new SMOptions();

            cstDeclaration.Identity.Visit(this);

            if (cstDeclaration.States != null)
            {
                stateMachineArchOptions.States = new List <string>();

                foreach (var state in cstDeclaration.States)
                {
                    state.Visit(this);
                    stateMachineArchOptions.States.Add((string)_buffer.Pop());
                }
            }


            stateMachineArchOptions.FinalStates = new List <string>();

            foreach (var final in cstDeclaration.Finals)
            {
                final.Visit(this);
                stateMachineArchOptions.FinalStates.Add((string)_buffer.Pop());
            }


            cstDeclaration.InitialStateName.Visit(this);
            stateMachineArchOptions.InitialState = (string)_buffer.Pop();


            stateMachineArchOptions.Transitions = new List <TransitionOptions>();

            foreach (var transition in cstDeclaration.Trancitions)
            {
                transition.Visit(this);
                stateMachineArchOptions.Transitions.Add((TransitionOptions)_buffer.Pop());
            }

            var identity = (string)_buffer.Pop();

            stateMachineArchOptions.MachineId = identity;

            _buffer.Push(stateMachineArchOptions);
        }
Example #3
0
 public abstract void Apply(CstDeclaration cstDeclaration);