예제 #1
0
        public override bool ExpectIt(ref IWordWalker ww, object currentSingaRule = null)
        {
            if (currentSingaRule is null)
            {
                throw new ArgumentNullException();
            }

            List <string> sigNames = new List <string>();

            var andExpector             = new CExactWordExpector("&&");
            var existingSigNameExpector = new CExistingSigNameExpector();
            var spaceSkipper            = new CWhiteSpaceSkipper();

            do
            {
                if (!existingSigNameExpector.ExpectIt(ref ww, currentSingaRule))
                {
                    error = existingSigNameExpector.error;
                    return(false);
                }

                sigNames.Add(existingSigNameExpector.result);
                spaceSkipper.ExpectIt(ref ww);
            } while (andExpector.ExpectIt(ref ww) && spaceSkipper.ExpectIt(ref ww));

            result             = new CAndExpression();
            result.Expressions = sigNames.Select(x => new CStateExpression(((SingaRule)currentSingaRule).sigs[x])).ToList <ISingaExpression>();
            return(true);
        }
예제 #2
0
        public override bool ExpectIt(ref IWordWalker ww, object currentSingaRule = null)
        {
            if (currentSingaRule is null)
            {
                throw new ArgumentNullException();
            }

            result = new COrExpression();
            var orExpector   = new CExactWordExpector("||");
            var andsExpector = new CAndsExpector();
            var spaceSkipper = new CWhiteSpaceSkipper();

            do
            {
                if (!andsExpector.ExpectIt(ref ww, currentSingaRule))
                {
                    error = andsExpector.error;
                    return(false);
                }

                result.Expressions.Add(andsExpector.result);
                spaceSkipper.ExpectIt(ref ww);
            } while (orExpector.ExpectIt(ref ww) && spaceSkipper.ExpectIt(ref ww));

            spaceSkipper.ExpectIt(ref ww);

            var semicolonExpector = new CExactWordExpector(";");

            if (!semicolonExpector.ExpectIt(ref ww))
            {
                error = semicolonExpector.error;
                return(false);
            }

            return(true);
        }