Shinichiro Hamaji | 1d545aa | 2015-06-23 15:29:13 +0900 | [diff] [blame] | 1 | // Copyright 2015 Google Inc. All rights reserved |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 15 | #ifndef RULE_H_ |
| 16 | #define RULE_H_ |
| 17 | |
Shinichiro Hamaji | c4f7662 | 2016-06-30 13:05:10 +0900 | [diff] [blame] | 18 | #include <functional> |
| 19 | #include <string> |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 20 | #include <vector> |
| 21 | |
| 22 | #include "loc.h" |
| 23 | #include "log.h" |
Shinichiro Hamaji | 645cca7 | 2015-09-24 17:04:21 +0900 | [diff] [blame] | 24 | #include "stmt.h" |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 25 | #include "string_piece.h" |
Shinichiro Hamaji | e799275 | 2015-06-29 18:38:35 +0900 | [diff] [blame] | 26 | #include "symtab.h" |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 27 | |
| 28 | using namespace std; |
| 29 | |
| 30 | class Value; |
| 31 | |
| 32 | class Rule { |
| 33 | public: |
| 34 | Rule(); |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 35 | |
Shinichiro Hamaji | e30b3be | 2015-06-19 16:15:42 +0900 | [diff] [blame] | 36 | Loc cmd_loc() const { return Loc(loc.filename, cmd_lineno); } |
| 37 | |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 38 | string DebugString() const; |
| 39 | |
Sasha Smundak | ce812f5 | 2018-08-15 14:49:39 -0700 | [diff] [blame] | 40 | void ParseInputs(const StringPiece& inputs_string); |
| 41 | |
| 42 | void ParsePrerequisites(const StringPiece& line, |
| 43 | size_t pos, |
| 44 | const RuleStmt* rule_stmt); |
| 45 | |
| 46 | static bool IsPatternRule(const StringPiece& target_string) { |
| 47 | return target_string.find('%') != string::npos; |
| 48 | } |
| 49 | |
Shinichiro Hamaji | e799275 | 2015-06-29 18:38:35 +0900 | [diff] [blame] | 50 | vector<Symbol> outputs; |
| 51 | vector<Symbol> inputs; |
| 52 | vector<Symbol> order_only_inputs; |
| 53 | vector<Symbol> output_patterns; |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 54 | bool is_double_colon; |
| 55 | bool is_suffix_rule; |
| 56 | vector<Value*> cmds; |
| 57 | Loc loc; |
| 58 | int cmd_lineno; |
| 59 | |
| 60 | private: |
Dan Willemsen | 3ce083f | 2017-10-11 22:17:48 -0700 | [diff] [blame] | 61 | void Error(const string& msg) { ERROR_LOC(loc, "%s", msg.c_str()); } |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 62 | }; |
| 63 | |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 64 | #endif // RULE_H_ |