Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Side by Side Diff: tools/gn/parser.h

Issue 1048913003: tools/gn: don't allow trailing junk or non-literals in "value" conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clang-format Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/input_conversion_unittest.cc ('k') | tools/gn/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 22 matching lines...) Expand all
33 class Parser { 33 class Parser {
34 public: 34 public:
35 // Will return a null pointer and set the err on error. 35 // Will return a null pointer and set the err on error.
36 static scoped_ptr<ParseNode> Parse(const std::vector<Token>& tokens, 36 static scoped_ptr<ParseNode> Parse(const std::vector<Token>& tokens,
37 Err* err); 37 Err* err);
38 38
39 // Alternative to parsing that assumes the input is an expression. 39 // Alternative to parsing that assumes the input is an expression.
40 static scoped_ptr<ParseNode> ParseExpression(const std::vector<Token>& tokens, 40 static scoped_ptr<ParseNode> ParseExpression(const std::vector<Token>& tokens,
41 Err* err); 41 Err* err);
42 42
43 scoped_ptr<ParseNode> ParseExpression(); 43 // Alternative to parsing that assumes the input is a literal value.
44 static scoped_ptr<ParseNode> ParseValue(const std::vector<Token>& tokens,
45 Err* err);
44 46
45 private: 47 private:
46 // Vector must be valid for lifetime of call. 48 // Vector must be valid for lifetime of call.
47 Parser(const std::vector<Token>& tokens, Err* err); 49 Parser(const std::vector<Token>& tokens, Err* err);
48 ~Parser(); 50 ~Parser();
49 51
52 scoped_ptr<ParseNode> ParseExpression();
53
50 // Parses an expression with the given precedence or higher. 54 // Parses an expression with the given precedence or higher.
51 scoped_ptr<ParseNode> ParseExpression(int precedence); 55 scoped_ptr<ParseNode> ParseExpression(int precedence);
52 56
53 // |PrefixFunc|s used in parsing expressions. 57 // |PrefixFunc|s used in parsing expressions.
54 scoped_ptr<ParseNode> Literal(Token token); 58 scoped_ptr<ParseNode> Literal(Token token);
55 scoped_ptr<ParseNode> Name(Token token); 59 scoped_ptr<ParseNode> Name(Token token);
56 scoped_ptr<ParseNode> Group(Token token); 60 scoped_ptr<ParseNode> Group(Token token);
57 scoped_ptr<ParseNode> Not(Token token); 61 scoped_ptr<ParseNode> Not(Token token);
58 scoped_ptr<ParseNode> List(Token token); 62 scoped_ptr<ParseNode> List(Token token);
59 scoped_ptr<ParseNode> BlockComment(Token token); 63 scoped_ptr<ParseNode> BlockComment(Token token);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 FRIEND_TEST_ALL_PREFIXES(Parser, Expression); 123 FRIEND_TEST_ALL_PREFIXES(Parser, Expression);
120 FRIEND_TEST_ALL_PREFIXES(Parser, FunctionCall); 124 FRIEND_TEST_ALL_PREFIXES(Parser, FunctionCall);
121 FRIEND_TEST_ALL_PREFIXES(Parser, List); 125 FRIEND_TEST_ALL_PREFIXES(Parser, List);
122 FRIEND_TEST_ALL_PREFIXES(Parser, ParenExpression); 126 FRIEND_TEST_ALL_PREFIXES(Parser, ParenExpression);
123 FRIEND_TEST_ALL_PREFIXES(Parser, UnaryOp); 127 FRIEND_TEST_ALL_PREFIXES(Parser, UnaryOp);
124 128
125 DISALLOW_COPY_AND_ASSIGN(Parser); 129 DISALLOW_COPY_AND_ASSIGN(Parser);
126 }; 130 };
127 131
128 #endif // TOOLS_GN_PARSER_H_ 132 #endif // TOOLS_GN_PARSER_H_
OLDNEW
« no previous file with comments | « tools/gn/input_conversion_unittest.cc ('k') | tools/gn/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698