clang API Documentation

OperatorPrecedence.h
Go to the documentation of this file.
00001 //===--- OperatorPrecedence.h - Operator precedence levels ------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 ///
00010 /// \file
00011 /// \brief Defines and computes precedence levels for binary/ternary operators.
00012 ///
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_CLANG_BASIC_OPERATORPRECEDENCE_H
00016 #define LLVM_CLANG_BASIC_OPERATORPRECEDENCE_H
00017 
00018 #include "clang/Basic/TokenKinds.h"
00019 
00020 namespace clang {
00021 
00022 /// PrecedenceLevels - These are precedences for the binary/ternary
00023 /// operators in the C99 grammar.  These have been named to relate
00024 /// with the C99 grammar productions.  Low precedences numbers bind
00025 /// more weakly than high numbers.
00026 namespace prec {
00027   enum Level {
00028     Unknown         = 0,    // Not binary operator.
00029     Comma           = 1,    // ,
00030     Assignment      = 2,    // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=
00031     Conditional     = 3,    // ?
00032     LogicalOr       = 4,    // ||
00033     LogicalAnd      = 5,    // &&
00034     InclusiveOr     = 6,    // |
00035     ExclusiveOr     = 7,    // ^
00036     And             = 8,    // &
00037     Equality        = 9,    // ==, !=
00038     Relational      = 10,   //  >=, <=, >, <
00039     Shift           = 11,   // <<, >>
00040     Additive        = 12,   // -, +
00041     Multiplicative  = 13,   // *, /, %
00042     PointerToMember = 14    // .*, ->*
00043   };
00044 }
00045 
00046 /// \brief Return the precedence of the specified binary operator token.
00047 prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator,
00048                                bool CPlusPlus11);
00049 
00050 }  // end namespace clang
00051 
00052 #endif  // LLVM_CLANG_OPERATOR_PRECEDENCE_H