OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TOOLS_GN_PARSER_H_ | 5 #ifndef TOOLS_GN_PARSER_H_ |
6 #define TOOLS_GN_PARSER_H_ | 6 #define TOOLS_GN_PARSER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "tools/gn/err.h" | 14 #include "tools/gn/err.h" |
15 #include "tools/gn/parse_tree.h" | 15 #include "tools/gn/parse_tree.h" |
16 | 16 |
17 class Parser; | 17 class Parser; |
18 typedef scoped_ptr<ParseNode> (Parser::*PrefixFunc)(Token token); | 18 typedef scoped_ptr<ParseNode> (Parser::*PrefixFunc)(Token token); |
19 typedef scoped_ptr<ParseNode> (Parser::*InfixFunc)(scoped_ptr<ParseNode> left, | 19 typedef scoped_ptr<ParseNode> (Parser::*InfixFunc)(scoped_ptr<ParseNode> left, |
20 Token token); | 20 Token token); |
21 | 21 |
| 22 extern const char kGrammar_Help[]; |
| 23 |
22 struct ParserHelper { | 24 struct ParserHelper { |
23 PrefixFunc prefix; | 25 PrefixFunc prefix; |
24 InfixFunc infix; | 26 InfixFunc infix; |
25 int precedence; | 27 int precedence; |
26 }; | 28 }; |
27 | 29 |
28 // Parses a series of tokens. The resulting AST will refer to the tokens passed | 30 // Parses a series of tokens. The resulting AST will refer to the tokens passed |
29 // to the input, so the tokens an the file data they refer to must outlive your | 31 // to the input, so the tokens an the file data they refer to must outlive your |
30 // use of the ParseNode. | 32 // use of the ParseNode. |
31 class Parser { | 33 class Parser { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 FRIEND_TEST_ALL_PREFIXES(Parser, Expression); | 119 FRIEND_TEST_ALL_PREFIXES(Parser, Expression); |
118 FRIEND_TEST_ALL_PREFIXES(Parser, FunctionCall); | 120 FRIEND_TEST_ALL_PREFIXES(Parser, FunctionCall); |
119 FRIEND_TEST_ALL_PREFIXES(Parser, List); | 121 FRIEND_TEST_ALL_PREFIXES(Parser, List); |
120 FRIEND_TEST_ALL_PREFIXES(Parser, ParenExpression); | 122 FRIEND_TEST_ALL_PREFIXES(Parser, ParenExpression); |
121 FRIEND_TEST_ALL_PREFIXES(Parser, UnaryOp); | 123 FRIEND_TEST_ALL_PREFIXES(Parser, UnaryOp); |
122 | 124 |
123 DISALLOW_COPY_AND_ASSIGN(Parser); | 125 DISALLOW_COPY_AND_ASSIGN(Parser); |
124 }; | 126 }; |
125 | 127 |
126 #endif // TOOLS_GN_PARSER_H_ | 128 #endif // TOOLS_GN_PARSER_H_ |
OLD | NEW |