CheckType() static private method

static private CheckType ( Precedence p, PrecType t, int d ) : int
p Precedence
t PrecType
d int
return int
Beispiel #1
0
 public Precedence(Precedence.PrecType t, int p, Precedence next)
 {
     if (Precedence.CheckType(next, t, 0) != 0)
     {
         Console.WriteLine("redeclaration of precedence");
     }
     this.m_next = next;
     this.m_type = t;
     this.m_prec = p;
 }
Beispiel #2
0
        public static int Check(CSymbol s, Production p, int d)
        {
            if (s.m_prec == null)
            {
                return(0);
            }
            int num1 = Precedence.CheckType(s.m_prec, Precedence.PrecType.after, d + 1);
            int num2 = Precedence.CheckType(s.m_prec, Precedence.PrecType.left, d + 1);

            if (num1 > num2)
            {
                return(num1 - p.m_prec);
            }
            return(num2 - p.m_prec);
        }
Beispiel #3
0
        public static void Check(Production p)
        {
            int count = p.m_rhs.Count;

            while (count > 1 && ((SYMBOL)p.m_rhs[count - 1]).IsAction())
            {
                --count;
            }
            switch (count)
            {
            case 2:
                if ((CSymbol)p.m_rhs[0] == p.m_lhs)
                {
                    int num = Precedence.Check(((CSymbol)p.m_rhs[1]).m_prec, Precedence.PrecType.after, 0);
                    if (num == 0)
                    {
                        break;
                    }
                    p.m_prec = num;
                    break;
                }
                if ((CSymbol)p.m_rhs[1] != p.m_lhs)
                {
                    break;
                }
                int num1 = Precedence.Check(((CSymbol)p.m_rhs[0]).m_prec, Precedence.PrecType.before, 0);
                if (num1 == 0)
                {
                    break;
                }
                p.m_prec = num1;
                break;

            case 3:
                int num2 = Precedence.CheckType(((CSymbol)p.m_rhs[1]).m_prec, Precedence.PrecType.left, 0);
                if (num2 == 0 || (CSymbol)p.m_rhs[2] != p.m_lhs)
                {
                    break;
                }
                p.m_prec = num2;
                break;
            }
        }