blob: a88de886009b99e6ab784f7fe6f3bed2d324ab41 [file] [log] [blame]
Brian Osman00185012021-02-04 16:07:11 -05001/*
2 * Copyright 2021 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SKSL_OPERATORS
9#define SKSL_OPERATORS
10
11#include "src/sksl/SkSLLexer.h"
12
13namespace SkSL {
14namespace Operators {
15
16 enum class Precedence {
17 kParentheses = 1,
18 kPostfix = 2,
19 kPrefix = 3,
20 kMultiplicative = 4,
21 kAdditive = 5,
22 kShift = 6,
23 kRelational = 7,
24 kEquality = 8,
25 kBitwiseAnd = 9,
26 kBitwiseXor = 10,
27 kBitwiseOr = 11,
28 kLogicalAnd = 12,
29 kLogicalXor = 13,
30 kLogicalOr = 14,
31 kTernary = 15,
32 kAssignment = 16,
33 kSequence = 17,
34 kTopLevel = kSequence
35 };
36
37 Precedence GetBinaryPrecedence(Token::Kind op);
38
39 const char* OperatorName(Token::Kind op);
40
41 // Returns true if op is '=' or any compound assignment operator ('+=', '-=', etc.)
42 bool IsAssignment(Token::Kind op);
43
44 // Given a compound assignment operator, returns the non-assignment version of the operator
45 // (e.g. '+=' becomes '+')
46 Token::Kind RemoveAssignment(Token::Kind op);
47
48} // namespace Operators
49} // namespace SkSL
50
51#endif