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

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

Issue 1268973003: Enhance GN string interpolation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grammar Created 5 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 | « no previous file | tools/gn/string_utils.cc » ('j') | tools/gn/string_utils.cc » ('J')
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"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 "\n" 49 "\n"
50 " integer = [ \"-\" ] digit { digit } .\n" 50 " integer = [ \"-\" ] digit { digit } .\n"
51 "\n" 51 "\n"
52 " Leading zeros and negative zero are disallowed.\n" 52 " Leading zeros and negative zero are disallowed.\n"
53 "\n" 53 "\n"
54 "String literals\n" 54 "String literals\n"
55 "\n" 55 "\n"
56 " A string literal represents a string value consisting of the quoted\n" 56 " A string literal represents a string value consisting of the quoted\n"
57 " characters with possible escape sequences and variable expansions.\n" 57 " characters with possible escape sequences and variable expansions.\n"
58 "\n" 58 "\n"
59 " string = `\"` { char | escape | expansion } `\"` .\n" 59 " string = `\"` { char | escape | expansion } `\"` .\n"
60 " escape = `\\` ( \"$\" | `\"` | char ) .\n" 60 " escape = `\\` ( \"$\" | `\"` | char ) .\n"
61 " expansion = \"$\" ( identifier | \"{\" identifier \"}\" ) .\n" 61 " BracketExpansion = \"{\" ( identifier | ArrayAccess | ScopeAccess "
62 " char = /* any character except \"$\", `\"`, or newline */ .\n" 62 ") \"}\" .\n"
63 " expansion = \"$\" ( identifier | BracketExpansion ) .\n"
64 " char = /* any character except \"$\", `\"`, or newline "
65 "*/ .\n"
63 "\n" 66 "\n"
64 " After a backslash, certain sequences represent special characters:\n" 67 " After a backslash, certain sequences represent special characters:\n"
65 "\n" 68 "\n"
66 " \\\" U+0022 quotation mark\n" 69 " \\\" U+0022 quotation mark\n"
67 " \\$ U+0024 dollar sign\n" 70 " \\$ U+0024 dollar sign\n"
68 " \\\\ U+005C backslash\n" 71 " \\\\ U+005C backslash\n"
69 "\n" 72 "\n"
70 " All other backslashes represent themselves.\n" 73 " All other backslashes represent themselves.\n"
71 "\n" 74 "\n"
72 "Punctuation\n" 75 "Punctuation\n"
(...skipping 12 matching lines...) Expand all
85 " File = StatementList .\n" 88 " File = StatementList .\n"
86 "\n" 89 "\n"
87 " Statement = Assignment | Call | Condition .\n" 90 " Statement = Assignment | Call | Condition .\n"
88 " Assignment = identifier AssignOp Expr .\n" 91 " Assignment = identifier AssignOp Expr .\n"
89 " Call = identifier \"(\" [ ExprList ] \")\" [ Block ] .\n" 92 " Call = identifier \"(\" [ ExprList ] \")\" [ Block ] .\n"
90 " Condition = \"if\" \"(\" Expr \")\" Block\n" 93 " Condition = \"if\" \"(\" Expr \")\" Block\n"
91 " [ \"else\" ( Condition | Block ) ] .\n" 94 " [ \"else\" ( Condition | Block ) ] .\n"
92 " Block = \"{\" StatementList \"}\" .\n" 95 " Block = \"{\" StatementList \"}\" .\n"
93 " StatementList = { Statement } .\n" 96 " StatementList = { Statement } .\n"
94 "\n" 97 "\n"
98 " ArrayAccess = identifier \"[\" { identifier | integer } \"]\" .\n"
99 " ScopeAccess = identifier \".\" identifier .\n"
95 " Expr = UnaryExpr | Expr BinaryOp Expr .\n" 100 " Expr = UnaryExpr | Expr BinaryOp Expr .\n"
96 " UnaryExpr = PrimaryExpr | UnaryOp UnaryExpr .\n" 101 " UnaryExpr = PrimaryExpr | UnaryOp UnaryExpr .\n"
97 " PrimaryExpr = identifier | integer | string | Call\n" 102 " PrimaryExpr = identifier | integer | string | Call\n"
98 " | identifier \"[\" Expr \"]\"\n" 103 " | ArrayAccess | ScopeAccess\n"
99 " | identifier \".\" identifier\n"
100 " | \"(\" Expr \")\"\n" 104 " | \"(\" Expr \")\"\n"
101 " | \"[\" [ ExprList [ \",\" ] ] \"]\" .\n" 105 " | \"[\" [ ExprList [ \",\" ] ] \"]\" .\n"
102 " ExprList = Expr { \",\" Expr } .\n" 106 " ExprList = Expr { \",\" Expr } .\n"
103 "\n" 107 "\n"
104 " AssignOp = \"=\" | \"+=\" | \"-=\" .\n" 108 " AssignOp = \"=\" | \"+=\" | \"-=\" .\n"
105 " UnaryOp = \"!\" .\n" 109 " UnaryOp = \"!\" .\n"
106 " BinaryOp = \"+\" | \"-\" // highest priority\n" 110 " BinaryOp = \"+\" | \"-\" // highest priority\n"
107 " | \"<\" | \"<=\" | \">\" | \">=\"\n" 111 " | \"<\" | \"<=\" | \">\" | \">=\"\n"
108 " | \"==\" | \"!=\"\n" 112 " | \"==\" | \"!=\"\n"
109 " | \"&&\"\n" 113 " | \"&&\"\n"
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 break; 741 break;
738 } 742 }
739 } 743 }
740 744
741 // Suffix comments were assigned in reverse, so if there were multiple on 745 // Suffix comments were assigned in reverse, so if there were multiple on
742 // the same node, they need to be reversed. 746 // the same node, they need to be reversed.
743 if ((*i)->comments() && !(*i)->comments()->suffix().empty()) 747 if ((*i)->comments() && !(*i)->comments()->suffix().empty())
744 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix(); 748 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix();
745 } 749 }
746 } 750 }
OLDNEW
« no previous file with comments | « no previous file | tools/gn/string_utils.cc » ('j') | tools/gn/string_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698