diff options
Diffstat (limited to 'clang/include/clang')
-rw-r--r-- | clang/include/clang/Basic/OperatorPrecedence.h | 52 | ||||
-rw-r--r-- | clang/include/clang/Parse/Parser.h | 25 |
2 files changed, 53 insertions, 24 deletions
diff --git a/clang/include/clang/Basic/OperatorPrecedence.h b/clang/include/clang/Basic/OperatorPrecedence.h new file mode 100644 index 00000000000..7dda68365be --- /dev/null +++ b/clang/include/clang/Basic/OperatorPrecedence.h @@ -0,0 +1,52 @@ +//===--- OperatorPrecedence.h - Operator precedence levels ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// \brief Defines and computes precedence levels for binary/ternary operators. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_OPERATOR_PRECEDENCE_H +#define LLVM_CLANG_OPERATOR_PRECEDENCE_H + +#include "clang/Basic/TokenKinds.h" + +namespace clang { + +/// PrecedenceLevels - These are precedences for the binary/ternary +/// operators in the C99 grammar. These have been named to relate +/// with the C99 grammar productions. Low precedences numbers bind +/// more weakly than high numbers. +namespace prec { + enum Level { + Unknown = 0, // Not binary operator. + Comma = 1, // , + Assignment = 2, // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |= + Conditional = 3, // ? + LogicalOr = 4, // || + LogicalAnd = 5, // && + InclusiveOr = 6, // | + ExclusiveOr = 7, // ^ + And = 8, // & + Equality = 9, // ==, != + Relational = 10, // >=, <=, >, < + Shift = 11, // <<, >> + Additive = 12, // -, + + Multiplicative = 13, // *, /, % + PointerToMember = 14 // .*, ->* + }; +} + +/// \brief Return the precedence of the specified binary operator token. +prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, + bool CPlusPlus0x); + +} // end namespace clang + +#endif // LLVM_CLANG_OPERATOR_PRECEDENCE_H diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 66c1d35cbf8..ed8d44be544 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_PARSE_PARSER_H #define LLVM_CLANG_PARSE_PARSER_H +#include "clang/Basic/OperatorPrecedence.h" #include "clang/Basic/Specifiers.h" #include "clang/Lex/CodeCompletionHandler.h" #include "clang/Lex/Preprocessor.h" @@ -44,30 +45,6 @@ namespace clang { class PoisonSEHIdentifiersRAIIObject; class VersionTuple; -/// PrecedenceLevels - These are precedences for the binary/ternary -/// operators in the C99 grammar. These have been named to relate -/// with the C99 grammar productions. Low precedences numbers bind -/// more weakly than high numbers. -namespace prec { - enum Level { - Unknown = 0, // Not binary operator. - Comma = 1, // , - Assignment = 2, // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |= - Conditional = 3, // ? - LogicalOr = 4, // || - LogicalAnd = 5, // && - InclusiveOr = 6, // | - ExclusiveOr = 7, // ^ - And = 8, // & - Equality = 9, // ==, != - Relational = 10, // >=, <=, >, < - Shift = 11, // <<, >> - Additive = 12, // -, + - Multiplicative = 13, // *, /, % - PointerToMember = 14 // .*, ->* - }; -} - /// Parser - This implements a parser for the C family of languages. After /// parsing units of the grammar, productions are invoked to handle whatever has /// been read. |