1 //===--- OperatorPrecedence.h - Operator precedence levels ------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 /// 10 /// \file 11 /// \brief Defines and computes precedence levels for binary/ternary operators. 12 /// 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CLANG_BASIC_OPERATORPRECEDENCE_H 16 #define LLVM_CLANG_BASIC_OPERATORPRECEDENCE_H 17 18 #include "clang/Basic/TokenKinds.h" 19 20 namespace clang { 21 22 /// PrecedenceLevels - These are precedences for the binary/ternary 23 /// operators in the C99 grammar. These have been named to relate 24 /// with the C99 grammar productions. Low precedences numbers bind 25 /// more weakly than high numbers. 26 namespace prec { 27 enum Level { 28 Unknown = 0, // Not binary operator. 29 Comma = 1, // , 30 Assignment = 2, // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |= 31 Conditional = 3, // ? 32 LogicalOr = 4, // || 33 LogicalAnd = 5, // && 34 InclusiveOr = 6, // | 35 ExclusiveOr = 7, // ^ 36 And = 8, // & 37 Equality = 9, // ==, != 38 Relational = 10, // >=, <=, >, < 39 Shift = 11, // <<, >> 40 Additive = 12, // -, + 41 Multiplicative = 13, // *, /, % 42 PointerToMember = 14 // .*, ->* 43 }; 44 } 45 46 /// \brief Return the precedence of the specified binary operator token. 47 prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, 48 bool CPlusPlus11); 49 50 } // end namespace clang 51 52 #endif // LLVM_CLANG_OPERATOR_PRECEDENCE_H 53