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

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

Issue 63153003: mac: Prepare for -Wunused-functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/input_conversion.cc ('k') | tools/gn/setup.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 #include "tools/gn/parser.h" 5 #include "tools/gn/parser.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "tools/gn/functions.h" 8 #include "tools/gn/functions.h"
9 #include "tools/gn/operators.h" 9 #include "tools/gn/operators.h"
10 #include "tools/gn/token.h" 10 #include "tools/gn/token.h"
11 11
12 // grammar: 12 // grammar:
13 // 13 //
14 // file := (statement)* 14 // file := (statement)*
15 // statement := block | if | assignment 15 // statement := block | if | assignment
16 // block := '{' statement* '}' 16 // block := '{' statement* '}'
17 // if := 'if' '(' expr ')' statement [ else ] 17 // if := 'if' '(' expr ')' statement [ else ]
18 // else := 'else' (if | statement)* 18 // else := 'else' (if | statement)*
19 // assignment := ident {'=' | '+=' | '-='} expr 19 // assignment := ident {'=' | '+=' | '-='} expr
20 20
21 namespace {
22
23 // Returns true if the two tokens are on the same line. We assume they're in
24 // the same file.
25 bool IsSameLine(const Token& a, const Token& b) {
26 DCHECK(a.location().file() == b.location().file());
27 return a.location().line_number() == b.location().line_number();
28 }
29
30 } // namespace
31
32 enum Precedence { 21 enum Precedence {
33 PRECEDENCE_ASSIGNMENT = 1, 22 PRECEDENCE_ASSIGNMENT = 1,
34 PRECEDENCE_OR = 2, 23 PRECEDENCE_OR = 2,
35 PRECEDENCE_AND = 3, 24 PRECEDENCE_AND = 3,
36 PRECEDENCE_EQUALITY = 4, 25 PRECEDENCE_EQUALITY = 4,
37 PRECEDENCE_RELATION = 5, 26 PRECEDENCE_RELATION = 5,
38 PRECEDENCE_SUM = 6, 27 PRECEDENCE_SUM = 6,
39 PRECEDENCE_PREFIX = 7, 28 PRECEDENCE_PREFIX = 7,
40 PRECEDENCE_CALL = 8, 29 PRECEDENCE_CALL = 8,
41 }; 30 };
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (IsAssignment(condition->condition())) 419 if (IsAssignment(condition->condition()))
431 *err_ = Err(condition->condition(), "Assignment not allowed in 'if'."); 420 *err_ = Err(condition->condition(), "Assignment not allowed in 'if'.");
432 Consume(Token::RIGHT_PAREN, "Expected ')' after condition of 'if'."); 421 Consume(Token::RIGHT_PAREN, "Expected ')' after condition of 'if'.");
433 condition->set_if_true(ParseBlock().Pass()); 422 condition->set_if_true(ParseBlock().Pass());
434 if (Match(Token::ELSE)) 423 if (Match(Token::ELSE))
435 condition->set_if_false(ParseStatement().Pass()); 424 condition->set_if_false(ParseStatement().Pass());
436 if (has_error()) 425 if (has_error())
437 return scoped_ptr<ParseNode>(); 426 return scoped_ptr<ParseNode>();
438 return condition.PassAs<ParseNode>(); 427 return condition.PassAs<ParseNode>();
439 } 428 }
OLDNEW
« no previous file with comments | « tools/gn/input_conversion.cc ('k') | tools/gn/setup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698