Ejemplo n.º 1
0
        private Dictionary <int, IMark> ReadMarks(XmlReader reader)
        {
            var marks = new Dictionary <int, IMark>();

            reader.ReadStartElement("Marks");
            reader.MoveToElement();

            while (reader.IsStartElement("Mark"))
            {
                int index = XmlConvert.ToInt32(reader.GetAttribute("id"));

                var mark = new MarkImpl()
                {
                    Mark     = (Marks)Enum.Parse(typeof(Marks), reader.GetAttribute("mark")),
                    Name     = reader.GetAttribute("name"),
                    Priority = XmlConvert.ToInt32(reader.GetAttribute("priority")),
                    Value    = reader.GetAttribute("value"),
                    Max      = XmlConvert.ToInt32(reader.GetAttribute("max")),
                    Default  = reader.GetAttribute("default"),
                    Offset   = XmlConvert.ToInt32(reader.GetAttribute("offset")),
                    Type     = reader.GetAttribute("type"),
                };

                marks.Add(index, mark);

                reader.Read();
                reader.MoveToElement();
            }

            reader.ReadEndElement();

            return(marks);
        }
Ejemplo n.º 2
0
Archivo: State.cs Proyecto: vf1/bnf2dfa
        protected void MarkNext(string name, Marks markType, int offset)
        {
            var proccessed = new HashSet <State>();
            var eclosure   = Eclosure();
            var end        = FindEnd();

            foreach (var first in eclosure)
            {
                foreach (var pair in first.Transition)
                {
                    if (pair.Key != null)
                    {
                        var next = pair.Value;
                        if (proccessed.Contains(next) == false)
                        {
                            proccessed.Add(next);

                            var mark = new MarkImpl()
                            {
                                Name   = name,
                                Mark   = markType,
                                Offset = offset,
                            };

                            next.AddMark(mark);

                            //var mark = new State(Epsilon, next)
                            //{
                            //    Name = name,
                            //    Mark = markType,
                            //    Offset = offset,
                            //};

                            //next.Transition.Add(Epsilon, mark);
                        }
                    }
                }
            }

            end.Transition.Add(Epsilon, new State());
        }
Ejemplo n.º 3
0
Archivo: State.cs Proyecto: vf1/bnf2dfa
        public void MarkBool(Marks mark, string name)
        {
            var mark2 = new MarkImpl()
            {
                Mark = mark,
                Name = name,
            };

            var end1 = FindEnd();

            end1.AddMark(mark2);

            //var end2 = new State()
            //{
            //    Mark = mark,
            //    Name = name,
            //};

            //var end1 = FindEnd();
            //end1.Transition.Add(Epsilon, end2);
        }
Ejemplo n.º 4
0
Archivo: State.cs Proyecto: vf1/bnf2dfa
        public void MarkCount(string name, int max, int default1)
        {
            var mark = new MarkImpl();

            mark.Mark    = Marks.Count;
            mark.Name    = name;
            mark.Max     = max;
            mark.Default = default1.ToString();

            var end1 = FindEnd();

            end1.AddMark(mark);

            //var end2 = new State();
            ////end2.CountName = name;
            ////end2.CountMax = max;
            //end2.Mark = Marks.Count;
            //end2.Name = name;
            //end2.Max = max;
            //end2.Default = default1;

            //var end1 = FindEnd();
            //end1.Transition.Add(Epsilon, end2);
        }