예제 #1
0
        PluralFormsNode RelationalExpression()
        {
            PluralFormsNode p = MultiplicativeExpression();

            if (p == null)
            {
                return(null);
            }
            PluralFormsNode n = p;

            if (Token.TokenType == PluralFormsToken.Type.Greater ||
                Token.TokenType == PluralFormsToken.Type.Less ||
                Token.TokenType == PluralFormsToken.Type.GreaterOrEqual ||
                Token.TokenType == PluralFormsToken.Type.LessOrEqual)
            {
                PluralFormsNode qn = new PluralFormsNode(new PluralFormsToken(Token));
                if (!NextToken())
                {
                    return(null);
                }
                p = MultiplicativeExpression();
                if (p == null)
                {
                    return(null);
                }
                qn.SetNode(1, p);
                qn.SetNode(0, n);
                return(qn);
            }
            return(n);
        }
예제 #2
0
        PluralFormsNode EqualityExpression()
        {
            PluralFormsNode p = RelationalExpression();

            if (p == null)
            {
                return(null);
            }
            PluralFormsNode n = p;

            if (Token.TokenType == PluralFormsToken.Type.Equal || Token.TokenType == PluralFormsToken.Type.NotEqual)
            {
                PluralFormsNode qn = new PluralFormsNode(new PluralFormsToken(Token));
                if (!NextToken())
                {
                    return(null);
                }
                p = RelationalExpression();
                if (p == null)
                {
                    return(null);
                }
                qn.SetNode(1, p);
                qn.SetNode(0, n);
                return(qn);
            }
            return(n);
        }
예제 #3
0
        PluralFormsNode MultiplicativeExpression()
        {
            PluralFormsNode p = PmExpression();

            if (p == null)
            {
                return(null);
            }
            PluralFormsNode n = p;

            if (Token.TokenType == PluralFormsToken.Type.Reminder)
            {
                PluralFormsNode qn = new PluralFormsNode(new PluralFormsToken(Token));
                if (!NextToken())
                {
                    return(null);
                }
                p = PmExpression();
                if (p == null)
                {
                    return(null);
                }
                qn.SetNode(1, p);
                qn.SetNode(0, n);
                return(qn);
            }
            return(n);
        }
예제 #4
0
        PluralFormsNode Expression()
        {
            PluralFormsNode p = LogicalOrExpression();

            if (p == null)
            {
                return(null);
            }
            PluralFormsNode n = p;

            if (Token.TokenType == PluralFormsToken.Type.Question)
            {
                PluralFormsNode qn = new PluralFormsNode(new PluralFormsToken(Token));
                if (!NextToken())
                {
                    return(null);
                }
                p = Expression();
                if (p == null)
                {
                    return(null);
                }
                qn.SetNode(1, p);
                if (Token.TokenType != PluralFormsToken.Type.Colon)
                {
                    return(null);
                }
                if (!NextToken())
                {
                    return(null);
                }
                p = Expression();
                if (p == null)
                {
                    return(null);
                }
                qn.SetNode(2, p);
                qn.SetNode(0, n);
                return(qn);
            }
            return(n);
        }
예제 #5
0
        PluralFormsNode LogicalAndExpression()
        {
            PluralFormsNode p = EqualityExpression();

            if (p == null)
            {
                return(null);
            }
            PluralFormsNode ln = p;             // left

            if (Token.TokenType == PluralFormsToken.Type.LogicalAnd)
            {
                PluralFormsNode un = new PluralFormsNode(new PluralFormsToken(Token));                  // up
                if (!NextToken())
                {
                    return(null);
                }
                p = LogicalAndExpression();
                if (p == null)
                {
                    return(null);
                }
                PluralFormsNode rn = p;                 // right
                if (rn.Token.TokenType == PluralFormsToken.Type.LogicalAnd)
                {
                    // transform 1 && (2 && 3) -> (1 && 2) && 3
                    //     u                  r
                    // l       r     ->   u      3
                    //       2   3      l   2
                    un.SetNode(0, ln);
                    un.SetNode(1, rn.ReleaseNode(0));
                    rn.SetNode(0, un);
                    return(rn);
                }

                un.SetNode(0, ln);
                un.SetNode(1, rn);
                return(un);
            }
            return(ln);
        }
예제 #6
0
        PluralFormsNode LogicalOrExpression()
        {
            PluralFormsNode p = LogicalAndExpression();

            if (p == null)
            {
                return(null);
            }
            PluralFormsNode ln = p;

            if (Token.TokenType == PluralFormsToken.Type.LogicalOr)
            {
                PluralFormsNode un = new PluralFormsNode(new PluralFormsToken(Token));
                if (!NextToken())
                {
                    return(null);
                }
                p = LogicalOrExpression();
                if (p == null)
                {
                    return(null);
                }
                PluralFormsNode rn = p;                 // right
                if (rn.Token.TokenType == PluralFormsToken.Type.LogicalOr)
                {
                    // see logicalAndExpression comment
                    un.SetNode(0, ln);
                    un.SetNode(1, rn.ReleaseNode(0));
                    rn.SetNode(0, un);
                    return(rn);
                }

                un.SetNode(0, ln);
                un.SetNode(1, rn);
                return(un);
            }
            return(ln);
        }
예제 #7
0
		PluralFormsNode RelationalExpression ()
		{
			PluralFormsNode p = MultiplicativeExpression ();
			if (p == null)
				return null;
			PluralFormsNode n = p;
			if (Token.TokenType == PluralFormsToken.Type.Greater
			    || Token.TokenType == PluralFormsToken.Type.Less
				|| Token.TokenType == PluralFormsToken.Type.GreaterOrEqual
				|| Token.TokenType == PluralFormsToken.Type.LessOrEqual)
			{
				PluralFormsNode qn = new PluralFormsNode (new PluralFormsToken(Token));
				if (! NextToken ()) {
					return null;
				}
				p = MultiplicativeExpression ();
				if (p == null) {
					return null;
				}
				qn.SetNode (1, p);
				qn.SetNode (0, n);
				return qn;
			}
			return n;
		}
예제 #8
0
		PluralFormsNode MultiplicativeExpression ()
		{
			PluralFormsNode p = PmExpression ();
			if (p == null)
			{
				return null;
			}
			PluralFormsNode n = p;
			if (Token.TokenType == PluralFormsToken.Type.Reminder)
			{
				PluralFormsNode qn = new PluralFormsNode (new PluralFormsToken(Token));
				if (! NextToken())
				{
					return null;
				}
				p = PmExpression ();
				if (p == null)
				{
					return null;
				}
				qn.SetNode (1, p);
				qn.SetNode (0, n);
				return qn;
			}
			return n;
		}
예제 #9
0
		PluralFormsNode EqualityExpression ()
		{
			PluralFormsNode p = RelationalExpression ();
			if (p == null)
				return null;
			PluralFormsNode n = p;
			if (Token.TokenType == PluralFormsToken.Type.Equal || Token.TokenType == PluralFormsToken.Type.NotEqual)
			{
				PluralFormsNode qn = new PluralFormsNode (new PluralFormsToken(Token));
				if (! NextToken ())
				{
					return null;
				}
				p = RelationalExpression ();
				if (p == null)
				{
					return null;
				}
				qn.SetNode (1, p);
				qn.SetNode (0, n);
				return qn;
			}
			return n;
		}
예제 #10
0
		PluralFormsNode LogicalAndExpression ()
		{
			PluralFormsNode p = EqualityExpression ();
			if (p == null)
				return null;
			PluralFormsNode ln = p; // left
			if (Token.TokenType == PluralFormsToken.Type.LogicalAnd)
			{
				PluralFormsNode un = new PluralFormsNode (new PluralFormsToken(Token)); // up
				if (! NextToken ())
				{
					return null;
				}
				p = LogicalAndExpression ();
				if (p == null)
				{
					return null;
				}
				PluralFormsNode rn = p; // right
				if (rn.Token.TokenType == PluralFormsToken.Type.LogicalAnd)
				{
					// transform 1 && (2 && 3) -> (1 && 2) && 3
					//     u                  r
					// l       r     ->   u      3
					//       2   3      l   2
					un.SetNode (0, ln);
					un.SetNode (1, rn.ReleaseNode (0));
					rn.SetNode (0, un);
					return rn;
				}

				un.SetNode (0, ln);
				un.SetNode (1, rn);
				return un;
			}
			return ln;
		}
예제 #11
0
		PluralFormsNode LogicalOrExpression ()
		{
			PluralFormsNode p = LogicalAndExpression ();
			if (p == null)
				return null;
			PluralFormsNode ln = p;
			if (Token.TokenType == PluralFormsToken.Type.LogicalOr)
			{
				PluralFormsNode un = new PluralFormsNode (new PluralFormsToken(Token));
				if (! NextToken ())
				{
					return null;
				}
				p = LogicalOrExpression ();
				if (p == null)
				{
					return null;
				}
				PluralFormsNode rn = p; // right
				if (rn.Token.TokenType == PluralFormsToken.Type.LogicalOr)
				{
					// see logicalAndExpression comment
					un.SetNode (0, ln);
					un.SetNode (1, rn.ReleaseNode (0));
					rn.SetNode (0, un);
					return rn;
				}
				
				un.SetNode (0, ln);
				un.SetNode (1, rn);
				return un;
			}
			return ln;
		}
예제 #12
0
		PluralFormsNode Expression ()
		{
			PluralFormsNode p = LogicalOrExpression ();
			if (p == null)
				return null;
			PluralFormsNode n = p;
			if (Token.TokenType == PluralFormsToken.Type.Question)
			{
				PluralFormsNode qn = new PluralFormsNode (new PluralFormsToken (Token));
				if (! NextToken ())
				{
					return null;
				}
				p = Expression ();
				if (p == null)
				{
					return null;
				}
				qn.SetNode (1, p);
				if (Token.TokenType != PluralFormsToken.Type.Colon)
				{
					return null;
				}
				if (! NextToken ())
				{
					return null;
				}
				p = Expression ();
				if (p == null)
				{
					return null;
				}
				qn.SetNode (2, p);
				qn.SetNode (0, n);
				return qn;
			}
			return n;
		}