Esempio n. 1
0
 public WorkFlow()
 {
     workTimeList      = new List <WorkTime>();
     workDayOfWeekList = new List <DayOfWeek>();
     clientManagement  = new ClientManagement(this);
     try {
         dataNotationModel = ReadDNModelFromFile(FILE_PATH);
         FillWeekDays();
         FillWorkTime();
         FillClientsFromDNObject(dataNotationModel.GetNotationObject("clients"));
     } catch (Exception exception) { Console.WriteLine("Exception: {0}", exception.Message); }
 }
Esempio n. 2
0
        public DataNotationModel Parse()
        {
            var currentState    = DNStates.Start;
            var dnModel         = new DataNotationModel();
            var currentList     = new DataNotationCollection();
            var currentObject   = new DataNotationObject();
            var currentProperty = new DataNotationProperty();

            while (!IsEndOfBuffer())
            {
                if (Peek().kind == TokenKind.End)
                {
                    break;
                }

                if (currentState == DNStates.Start)
                {
                    if (Expect(TokenKind.Identifier))
                    {
                        currentState = DNStates.ObjectStart;
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }

                if (currentState == DNStates.ObjectStart)
                {
                    if (Expect(TokenKind.Identifier) && Expect(TokenKind.Colon, 1))
                    {
                        currentObject      = new DataNotationObject();
                        currentObject.name = Peek().value;
                        currentState       = DNStates.OpenList;
                        Skip(2); continue;
                    }
                    else
                    {
                        RaiseUnexpectedError(Peek());
                    }
                }

                if (currentState == DNStates.OpenList)
                {
                    if (Expect(TokenKind.OpenBracket))
                    {
                        currentList  = new DataNotationCollection();
                        currentState = DNStates.PropertyStart;
                        Skip(); continue;
                    }
                    else
                    {
                        RaiseUnexpectedError(Peek());
                    }
                }

                if (currentState == DNStates.PropertyStart)
                {
                    if (Expect(TokenKind.Identifier) && Expect(TokenKind.Assign, 1))
                    {
                        currentProperty     = new DataNotationProperty();
                        currentProperty.key = Peek().value;
                        Skip(2);
                        if (Expect(TokenKind.Number) || Expect(TokenKind.String))
                        {
                            currentProperty.value = Peek().value;
                            currentState          = DNStates.PropertyEnd;
                            Skip(); continue;
                        }
                        else
                        {
                            RaiseUnexpectedError(Peek());
                        }
                    }
                    else if (Expect(TokenKind.CloseBracket))
                    {
                        currentState = DNStates.CloseList;
                    }
                    else
                    {
                        RaiseUnexpectedError(Peek());
                    }
                }

                if (currentState == DNStates.PropertyEnd)
                {
                    currentList.AddProperty(currentProperty);
                    currentState = Expect(TokenKind.Comma) ? DNStates.PropertyStart : DNStates.CloseList;
                    if (Expect(TokenKind.Comma))
                    {
                        Skip();
                    }
                    continue;
                }

                if (currentState == DNStates.CloseList)
                {
                    if (Expect(TokenKind.CloseBracket))
                    {
                        currentObject.AddCollection(currentList);
                        Skip();
                        if (Expect(TokenKind.Semicolon))
                        {
                            dnModel.objectList.Add(currentObject);
                            currentState = DNStates.Start;
                            Skip(); continue;
                        }

                        if (Expect(TokenKind.Comma))
                        {
                            currentState = DNStates.OpenList;
                            Skip(); continue;
                        }

                        RaiseUnexpectedError(Peek());
                    }
                    else
                    {
                        RaiseUnexpectedError(Peek());
                    }
                }

                RaiseUnexpectedError(Peek());
            }

            return(dnModel);
        }