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 /// Defines and computes precedence levels for binary/ternary operators.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_BASIC_OPERATORPRECEDENCE_H
16 #define LLVM_CLANG_BASIC_OPERATORPRECEDENCE_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, // >=, <=, >, <
39 Spaceship = 11, // <=>
41 Additive = 13, // -, +
42 Multiplicative = 14, // *, /, %
43 PointerToMember = 15 // .*, ->*
47 /// Return the precedence of the specified binary operator token.
48 prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator,
51 } // end namespace clang
53 #endif // LLVM_CLANG_OPERATOR_PRECEDENCE_H