1 //===--- OperatorPrecedence.h - Operator precedence levels ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Defines and computes precedence levels for binary/ternary operators.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_OPERATOR_PRECEDENCE_H
16 #define LLVM_CLANG_OPERATOR_PRECEDENCE_H
18 #include "clang/Basic/TokenKinds.h"
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.
28 Unknown = 0, // Not binary operator.
30 Assignment = 2, // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=
37 Equality = 9, // ==, !=
38 Relational = 10, // >=, <=, >, <
40 Additive = 12, // -, +
41 Multiplicative = 13, // *, /, %
42 PointerToMember = 14 // .*, ->*
46 /// \brief Return the precedence of the specified binary operator token.
47 prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator,
50 } // end namespace clang
52 #endif // LLVM_CLANG_OPERATOR_PRECEDENCE_H