Exemplo n.º 1
0
        public new static TCall LeftClaim(StringClaimer claimer, TExpression left)
        {
            Claim lb = claimer.Claim(LeftBracket);

            if (!lb.Success) // Left Bracket is a requirement.
            {
                return(null);
            }
            lb.Pass(); // At this point, we cannot fail.

            TCall newCall = new TCall {
                _caller = left
            };

            while (true)
            {
                Claim rb = claimer.Claim(RightBracket);
                if (rb.Success)
                {
                    rb.Pass();
                    break;
                }
                TArgument newArg = TArgument.Claim(claimer);
                if (newArg == null)
                {
                    break;
                }
                newCall._arguments.Add(newArg);
                claimer.Claim(Comma);
            }

            return(newCall);
        }
Exemplo n.º 2
0
        public new static TParenExpression Claim(StringClaimer claimer)
        {
            Claim lb = claimer.Claim(LeftBracket);

            if (!lb.Success)
            {
                return(null);
            }
            TParenExpression ptoken = new TParenExpression {
                _realExpression = TExpression.Claim(claimer)
            };

            if (ptoken._realExpression == null)
            {
                lb.Fail();
                return(null);
            }
            lb.Pass();
            Claim rb = claimer.Claim(RightBracket);

            if (rb.Success)
            {
                rb.Pass();            // right bracket is optional. So just pass it if we get it.
            }
            return(ptoken);
        }
Exemplo n.º 3
0
        public new static TBlock Claim(StringClaimer claimer)
        {
            Claim c = claimer.Claim(LeftBracket);

            if (!c.Success)
            {
                return(null);
            }
            c.Pass();
            TBlock      newBlock = new TBlock();
            TExpression nExp;

            while ((nExp = TExpression.Claim(claimer)) != null)
            {
                newBlock._expressions.Add(nExp);
                claimer.Claim(SemiColon);
                if (!(c = claimer.Claim(RightBracket)).Success)
                {
                    continue;
                }
                c.Pass();
                return(newBlock);
            }
            return(newBlock);
        }
Exemplo n.º 4
0
        public new static TArgExpression Claim(StringClaimer claimer)
        {
            TExpression heldExpr = TExpression.Claim(claimer);

            if (heldExpr == null)
            {
                return(null);
            }
            TArgExpression newArgExp = new TArgExpression {
                _heldExp = heldExpr
            };

            return(newArgExp);
        }
Exemplo n.º 5
0
        public new static TExpression Claim(StringClaimer claimer)
        {
            TExpression preClaimed = pre_claim(claimer);

            if (preClaimed == null)
            {
                return(null);
            }
            TExpression nextClaim;

            while ((nextClaim = post_claim(claimer, preClaimed)) != null)
            {
                preClaimed = nextClaim;
            }
            return(preClaimed);
        }
Exemplo n.º 6
0
        public new static TAssignment Claim(StringClaimer claimer)
        {
            Claim failTo = claimer.FailPoint();

            TVariable toAssign = TVariable.Claim(claimer);

            if (toAssign == null)
            {
                failTo.Fail();
                return(null);
            }

            TOperator newOp = TOperator.Claim(claimer);

            Claim c = claimer.Claim(Set);

            if (!c.Success)
            {
                failTo.Fail();
                return(null);
            }
            TExpression assignValue = TExpression.Claim(claimer);

            if (assignValue == null)
            {
                failTo.Fail();
                return(null);
            }

            TAssignment newAssign = new TAssignment
            {
                _var   = toAssign,
                _op    = newOp,
                _value = assignValue
            };

            return(newAssign);
        }
Exemplo n.º 7
0
 public override void SetLeft(TExpression newLeft)
 {
     _caller = newLeft;
 }
Exemplo n.º 8
0
 private static TExpression post_claim(StringClaimer claimer, TExpression lastClaim)
 {
     return(TCall.LeftClaim(claimer, lastClaim) ??
            TArithmetic.LeftClaim(claimer, lastClaim));
 }