1249261Sdim//===--- OperatorPrecedence.h - Operator precedence levels ------*- C++ -*-===// 2249261Sdim// 3249261Sdim// The LLVM Compiler Infrastructure 4249261Sdim// 5249261Sdim// This file is distributed under the University of Illinois Open Source 6249261Sdim// License. See LICENSE.TXT for details. 7249261Sdim// 8249261Sdim//===----------------------------------------------------------------------===// 9249261Sdim/// 10249261Sdim/// \file 11249261Sdim/// \brief Defines and computes precedence levels for binary/ternary operators. 12249261Sdim/// 13249261Sdim//===----------------------------------------------------------------------===// 14249261Sdim 15249261Sdim#ifndef LLVM_CLANG_OPERATOR_PRECEDENCE_H 16249261Sdim#define LLVM_CLANG_OPERATOR_PRECEDENCE_H 17249261Sdim 18249261Sdim#include "clang/Basic/TokenKinds.h" 19249261Sdim 20249261Sdimnamespace clang { 21249261Sdim 22249261Sdim/// PrecedenceLevels - These are precedences for the binary/ternary 23249261Sdim/// operators in the C99 grammar. These have been named to relate 24249261Sdim/// with the C99 grammar productions. Low precedences numbers bind 25249261Sdim/// more weakly than high numbers. 26249261Sdimnamespace prec { 27249261Sdim enum Level { 28249261Sdim Unknown = 0, // Not binary operator. 29249261Sdim Comma = 1, // , 30249261Sdim Assignment = 2, // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |= 31249261Sdim Conditional = 3, // ? 32249261Sdim LogicalOr = 4, // || 33249261Sdim LogicalAnd = 5, // && 34249261Sdim InclusiveOr = 6, // | 35249261Sdim ExclusiveOr = 7, // ^ 36249261Sdim And = 8, // & 37249261Sdim Equality = 9, // ==, != 38249261Sdim Relational = 10, // >=, <=, >, < 39249261Sdim Shift = 11, // <<, >> 40249261Sdim Additive = 12, // -, + 41249261Sdim Multiplicative = 13, // *, /, % 42249261Sdim PointerToMember = 14 // .*, ->* 43249261Sdim }; 44249261Sdim} 45249261Sdim 46249261Sdim/// \brief Return the precedence of the specified binary operator token. 47249261Sdimprec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, 48249261Sdim bool CPlusPlus11); 49249261Sdim 50249261Sdim} // end namespace clang 51249261Sdim 52249261Sdim#endif // LLVM_CLANG_OPERATOR_PRECEDENCE_H 53