Check() 공개 정적인 메소드

public static Check ( CSymbol s, Production p, int d ) : int
s CSymbol
p Production
d int
리턴 int
예제 #1
0
 public static int Check(Precedence p, Precedence.PrecType t, int d)
 {
     if (p == null)
     {
         return(0);
     }
     if (p.m_type == t)
     {
         return(p.m_prec);
     }
     return(Precedence.Check(p.m_next, t, d + 1));
 }
예제 #2
0
 private static int CheckType(Precedence p, Precedence.PrecType t, int d)
 {
     if (p == null)
     {
         return(0);
     }
     if (p.m_type == t || p.m_type <= Precedence.PrecType.nonassoc && t <= Precedence.PrecType.nonassoc)
     {
         return(p.m_prec);
     }
     return(Precedence.Check(p.m_next, t, d + 1));
 }
예제 #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;
            }
        }
예제 #4
0
        public Precedence.PrecType ShiftPrecedence(Production prod, ParseState ps)
        {
            if (prod == null || !prod.m_lhs.m_follow.Contains(this))
            {
                return(Precedence.PrecType.left);
            }
            if (this.m_prec == null)
            {
                Console.WriteLine("Shift/Reduce conflict {0} on reduction {1} in state {2}", (object)this.yytext, (object)prod.m_pno, (object)ps.m_state);
                return(Precedence.PrecType.left);
            }
            if (this.m_prec.m_type == Precedence.PrecType.nonassoc)
            {
                return(Precedence.PrecType.nonassoc);
            }
            int num = Precedence.Check(this, prod, 0);

            if (num == 0)
            {
                return(Precedence.Check(this.m_prec, Precedence.PrecType.right, 0) != 0 ? Precedence.PrecType.left : Precedence.PrecType.right);
            }
            return(num > 0 ? Precedence.PrecType.left : Precedence.PrecType.right);
        }