Exemplo n.º 1
0
        public override bool ExpectIt(ref IWordWalker ww, object additionalParam = null)
        {
            result = new SingaState();

            var sigNameExpector = new CNameExpector();

            if (!sigNameExpector.ExpectIt(ref ww))
            {
                error = sigNameExpector.error;
                return(false);
            }
            result.Name = sigNameExpector.result;

            var colonExpector = new CExactWordExpector(":");

            if (!colonExpector.ExpectIt(ref ww) || !colonExpector.HasNoErrors())
            {
                error = colonExpector.error;
                return(false);
            }

            new CWhiteSpaceSkipper().ExpectIt(ref ww);

            ww.LockLockableMoves = true;
            if (new CExactWordExpector("str").ExpectIt(ref ww))
            {
                ww.LockLockableMoves = false;
                var stringSigExpector = new CStringSignatureExpector();
                if (!stringSigExpector.ExpectIt(ref ww))
                {
                    error = stringSigExpector.error;
                    return(false);
                }
                result.Signature = stringSigExpector.result;
            }
            else if (new CExactWordExpector("hex").ExpectIt(ref ww))
            {
                ww.LockLockableMoves = false;
                var hexSigExpector = new CHexSignatureExpector();
                if (!hexSigExpector.ExpectIt(ref ww))
                {
                    error = hexSigExpector.error;
                    return(false);
                }
                result.Signature = hexSigExpector.result;
            }
            else
            {
                ww.LockLockableMoves = false;
                error = BuildExpectedError(string.Join("`, `", "str", "hex"), ww.GetConcatedNWords(3).GetValue());
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public override bool ExpectIt(ref IWordWalker ww, object additionalParam = null)
        {
            result = new SingaRule();

            var spaceSkipper = new CWhiteSpaceSkipper();

            spaceSkipper.ExpectIt(ref ww);

            var rExpector = new CExactWordExpector("r");

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

            spaceSkipper.ExpectIt(ref ww);

            var genericNameExpector = new CNameExpector();

            if (!genericNameExpector.ExpectIt(ref ww))
            {
                error = genericNameExpector.error;
                return(false);
            }
            result.name = genericNameExpector.result.ToString();

            spaceSkipper.ExpectIt(ref ww);

            var openBraceExpector = new CExactWordExpector("{");

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

            spaceSkipper.ExpectIt(ref ww);

            var ruleExpector = new CRuleExpector();

            if (!ruleExpector.ExpectIt(ref ww, result))
            {
                error = ruleExpector.error;
                return(false);
            }
            result = ruleExpector.result;

            spaceSkipper.ExpectIt(ref ww);

            var closeBraceExpector = new CExactWordExpector("}");

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

            spaceSkipper.ExpectIt(ref ww);

            var eofExpector = new CEOFExpector();

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

            return(true);
        }