Esempio n. 1
0
        private NthDayOfWeekBuilder Ordinal(DayOfWeek day, string ordinal)
        {
            GrammarChecker.CheckGrammar(Configuration.N, ordinal);

            Configuration.DayOfWeek = day;
            return(new NthDayOfWeekBuilder(Configuration));
        }
        private static GrammarChecker <T> BuildGrammarCheckerFrom <T>(IEnumerable <dynamic> rules, IEnumerable <T> startRules, IEnumerable <T> endRules)
        {
            var checker = new GrammarChecker <T>();

            rules.ForEach(rule => checker.AddRule(rule.From, rule.To));

            startRules.ForEach(checker.AddStartState);
            endRules.ForEach(checker.AddEndState);
            return(checker);
        }
        public void Check_AllWordsWithLengthFrom5To15_ShouldReturnTrue()
        {
            GrammarChecker <char> checker = GetChecker();

            Enumerable.Range(start: 5, count: 10)
            .SelectMany(length => checker.GetPossibleWordsWithLength(length))
            .ForEach(word =>
            {
                Assert.IsTrue(checker.Check(word));
            });
        }
        private GrammarChecker <char> GetChecker()
        {
            var grammarRules = (new string[] { "a->b", "a->l", "a->a", "a-> ", "l->a", "b-a", " ->b" })
                               .Select(rule => new
            {
                From = rule[0],
                To   = rule[rule.Length - 1]
            });

            string startStates            = "ab";
            string endStates              = "al";
            GrammarChecker <char> checker = BuildGrammarCheckerFrom(grammarRules, startStates, endStates);

            return(checker);
        }
Esempio n. 5
0
        private void View_GrammarAnalyzeRequired()
        {
            var fileManager = new FileManager();

            if (fileManager.OpenFileDialog())
            {
                try
                {
                    grammarChecker = new GrammarChecker();
                    var table = grammarChecker.Check(fileManager.Text);
                    view.ShowGrammarTable(table);
                }
                catch (Exception e)
                {
                    view.ShowGrammarError(e.Message);
                    grammarChecker = null;
                }
            }
        }
Esempio n. 6
0
        private AtBuilder OrdinalOfTheMonth(string ordinal)
        {
            GrammarChecker.CheckGrammar(Configuration.N, ordinal);

            var first = Configuration.First;

            first = new DateTimeOffset(first.Year, first.Month, Configuration.N, first.Hour, first.Minute, first.Second, first.Offset);

            if (first < DateTimeOffset.Now)
            {
                first = first.AddMonths(1);
            }

            Configuration.First = first;

            Configuration.CalculateNext = next =>
            {
                next = next.AddMonths(1);

                return(next);
            };

            return(new AtBuilder(Configuration));
        }
 public AscendingSyntaxAnalyzer(GrammarChecker grammarChecker, Action <List <AscendingInfo> > onReady)
 {
     GrammarChecker = grammarChecker;
     this.onReady   = onReady;
 }