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

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

Issue 2187523003: Allow creation and modification of scopes in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 4 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/parse_tree_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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Vector must be valid for lifetime of call. 51 // Vector must be valid for lifetime of call.
52 Parser(const std::vector<Token>& tokens, Err* err); 52 Parser(const std::vector<Token>& tokens, Err* err);
53 ~Parser(); 53 ~Parser();
54 54
55 std::unique_ptr<ParseNode> ParseExpression(); 55 std::unique_ptr<ParseNode> ParseExpression();
56 56
57 // Parses an expression with the given precedence or higher. 57 // Parses an expression with the given precedence or higher.
58 std::unique_ptr<ParseNode> ParseExpression(int precedence); 58 std::unique_ptr<ParseNode> ParseExpression(int precedence);
59 59
60 // |PrefixFunc|s used in parsing expressions. 60 // |PrefixFunc|s used in parsing expressions.
61 std::unique_ptr<ParseNode> Block(Token token);
61 std::unique_ptr<ParseNode> Literal(Token token); 62 std::unique_ptr<ParseNode> Literal(Token token);
62 std::unique_ptr<ParseNode> Name(Token token); 63 std::unique_ptr<ParseNode> Name(Token token);
63 std::unique_ptr<ParseNode> Group(Token token); 64 std::unique_ptr<ParseNode> Group(Token token);
64 std::unique_ptr<ParseNode> Not(Token token); 65 std::unique_ptr<ParseNode> Not(Token token);
65 std::unique_ptr<ParseNode> List(Token token); 66 std::unique_ptr<ParseNode> List(Token token);
66 std::unique_ptr<ParseNode> BlockComment(Token token); 67 std::unique_ptr<ParseNode> BlockComment(Token token);
67 68
68 // |InfixFunc|s used in parsing expressions. 69 // |InfixFunc|s used in parsing expressions.
69 std::unique_ptr<ParseNode> BinaryOperator(std::unique_ptr<ParseNode> left, 70 std::unique_ptr<ParseNode> BinaryOperator(std::unique_ptr<ParseNode> left,
70 Token token); 71 Token token);
71 std::unique_ptr<ParseNode> IdentifierOrCall(std::unique_ptr<ParseNode> left, 72 std::unique_ptr<ParseNode> IdentifierOrCall(std::unique_ptr<ParseNode> left,
72 Token token); 73 Token token);
73 std::unique_ptr<ParseNode> Assignment(std::unique_ptr<ParseNode> left, 74 std::unique_ptr<ParseNode> Assignment(std::unique_ptr<ParseNode> left,
74 Token token); 75 Token token);
75 std::unique_ptr<ParseNode> Subscript(std::unique_ptr<ParseNode> left, 76 std::unique_ptr<ParseNode> Subscript(std::unique_ptr<ParseNode> left,
76 Token token); 77 Token token);
77 std::unique_ptr<ParseNode> DotOperator(std::unique_ptr<ParseNode> left, 78 std::unique_ptr<ParseNode> DotOperator(std::unique_ptr<ParseNode> left,
78 Token token); 79 Token token);
79 80
80 // Helper to parse a comma separated list, optionally allowing trailing 81 // Helper to parse a comma separated list, optionally allowing trailing
81 // commas (allowed in [] lists, not in function calls). 82 // commas (allowed in [] lists, not in function calls).
82 std::unique_ptr<ListNode> ParseList(Token start_token, 83 std::unique_ptr<ListNode> ParseList(Token start_token,
83 Token::Type stop_before, 84 Token::Type stop_before,
84 bool allow_trailing_comma); 85 bool allow_trailing_comma);
85 86
86 std::unique_ptr<ParseNode> ParseFile(); 87 std::unique_ptr<ParseNode> ParseFile();
87 std::unique_ptr<ParseNode> ParseStatement(); 88 std::unique_ptr<ParseNode> ParseStatement();
88 std::unique_ptr<BlockNode> ParseBlock(); 89 // Expects to be passed the token corresponding to the '{' and that the
90 // current token is the one following the '{'.
91 std::unique_ptr<BlockNode> ParseBlock(Token being_brace,
92 BlockNode::ResultMode result_mode);
89 std::unique_ptr<ParseNode> ParseCondition(); 93 std::unique_ptr<ParseNode> ParseCondition();
90 94
91 // Generates a pre- and post-order traversal of the tree. 95 // Generates a pre- and post-order traversal of the tree.
92 void TraverseOrder(const ParseNode* root, 96 void TraverseOrder(const ParseNode* root,
93 std::vector<const ParseNode*>* pre, 97 std::vector<const ParseNode*>* pre,
94 std::vector<const ParseNode*>* post); 98 std::vector<const ParseNode*>* post);
95 99
96 // Attach comments to nearby syntax. 100 // Attach comments to nearby syntax.
97 void AssignComments(ParseNode* file); 101 void AssignComments(ParseNode* file);
98 102
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 FRIEND_TEST_ALL_PREFIXES(Parser, Expression); 134 FRIEND_TEST_ALL_PREFIXES(Parser, Expression);
131 FRIEND_TEST_ALL_PREFIXES(Parser, FunctionCall); 135 FRIEND_TEST_ALL_PREFIXES(Parser, FunctionCall);
132 FRIEND_TEST_ALL_PREFIXES(Parser, List); 136 FRIEND_TEST_ALL_PREFIXES(Parser, List);
133 FRIEND_TEST_ALL_PREFIXES(Parser, ParenExpression); 137 FRIEND_TEST_ALL_PREFIXES(Parser, ParenExpression);
134 FRIEND_TEST_ALL_PREFIXES(Parser, UnaryOp); 138 FRIEND_TEST_ALL_PREFIXES(Parser, UnaryOp);
135 139
136 DISALLOW_COPY_AND_ASSIGN(Parser); 140 DISALLOW_COPY_AND_ASSIGN(Parser);
137 }; 141 };
138 142
139 #endif // TOOLS_GN_PARSER_H_ 143 #endif // TOOLS_GN_PARSER_H_
OLDNEW
« no previous file with comments | « tools/gn/parse_tree_unittest.cc ('k') | tools/gn/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698