Ejemplo n.º 1
0
        private int GetPrecedenceLevel(Operator op)
        {
            Attribute[] attrs = Attribute.GetCustomAttributes(op.GetType().GetField(op.ToString()));
            if (attrs.Length != 1 || !(attrs[0] is OpAttr))
            {
                throw new InternalCompilerException(
                          string.Format(
                              "Operator '{0}' did not specify attributes",
                              op
                              )
                          );
            }
            OpAttr attribute = attrs[0] as OpAttr;

            return(attribute.Precedence);
        }
Ejemplo n.º 2
0
        private Associativity GetOperatorAssociativity(Operator op)
        {
            Attribute[] attrs = Attribute.GetCustomAttributes(op.GetType().GetField(op.ToString()));
            if (attrs.Length != 1 || !(attrs[0] is OpAttr))
            {
                throw new InternalCompilerException(
                          string.Format(
                              "Operator '{0}' did not specify attributes",
                              op
                              )
                          );
            }
            OpAttr attribute = attrs[0] as OpAttr;

            return(attribute.Associativity);
        }