1 //===--- OperatorPrecedence.h - Operator precedence levels ------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// Defines and computes precedence levels for binary/ternary operators.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_BASIC_OPERATORPRECEDENCE_H
15 #define LLVM_CLANG_BASIC_OPERATORPRECEDENCE_H
17 #include "clang/Basic/TokenKinds.h"
21 /// PrecedenceLevels - These are precedences for the binary/ternary
22 /// operators in the C99 grammar. These have been named to relate
23 /// with the C99 grammar productions. Low precedences numbers bind
24 /// more weakly than high numbers.
27 Unknown = 0, // Not binary operator.
29 Assignment = 2, // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=
36 Equality = 9, // ==, !=
37 Relational = 10, // >=, <=, >, <
38 Spaceship = 11, // <=>
40 Additive = 13, // -, +
41 Multiplicative = 14, // *, /, %
42 PointerToMember = 15 // .*, ->*
46 /// 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