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); }
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); }