]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/OperatorPrecedence.h
Merge clang trunk r321017 to contrib/llvm/tools/clang.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Basic / OperatorPrecedence.h
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     Spaceship       = 11,   // <=>
40     Shift           = 12,   // <<, >>
41     Additive        = 13,   // -, +
42     Multiplicative  = 14,   // *, /, %
43     PointerToMember = 15    // .*, ->*
44   };
45 }
46
47 /// \brief Return the precedence of the specified binary operator token.
48 prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator,
49                                bool CPlusPlus11);
50
51 }  // end namespace clang
52
53 #endif  // LLVM_CLANG_OPERATOR_PRECEDENCE_H