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

Side by Side Diff: tools/gn/docs/reference.md

Issue 1106003002: Add 'gn help grammar' contents to 'gn help all'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/command_help.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # GN Reference 1 # GN Reference
2 2
3 *This page is automatically generated from* `gn help --markdown all`. 3 *This page is automatically generated from* `gn help --markdown all`.
4 4
5 ## **--args**: Specifies build arguments overrides. 5 ## **--args**: Specifies build arguments overrides.
6 6
7 ``` 7 ```
8 See "gn help buildargs" for an overview of how build arguments work. 8 See "gn help buildargs" for an overview of how build arguments work.
9 9
10 Most operations take a build directory. The build arguments are taken 10 Most operations take a build directory. The build arguments are taken
(...skipping 4055 matching lines...) Expand 10 before | Expand all | Expand 10 after
4066 "//doom_melon/*", # Check everything in this subtree. 4066 "//doom_melon/*", # Check everything in this subtree.
4067 "//tools:mind_controlling_ant", # Check this specific target. 4067 "//tools:mind_controlling_ant", # Check this specific target.
4068 ] 4068 ]
4069 4069
4070 root = "//:root" 4070 root = "//:root"
4071 4071
4072 secondary_source = "//build/config/temporary_buildfiles/" 4072 secondary_source = "//build/config/temporary_buildfiles/"
4073 4073
4074 4074
4075 ``` 4075 ```
4076 ## **GN build language grammar**
4077
4078 ### **Tokens**
4079
4080 ```
4081 GN build files are read as sequences of tokens. While splitting the
4082 file into tokens, the next token is the longest sequence of characters
4083 that form a valid token.
4084
4085 ```
4086
4087 ### **White space and comments**
4088
4089 ```
4090 White space is comprised of spaces (U+0020), horizontal tabs (U+0009),
4091 carriage returns (U+000D), and newlines (U+000A).
4092
4093 Comments start at the character "#" and stop at the next newline.
4094
4095 White space and comments are ignored except that they may separate
4096 tokens that would otherwise combine into a single token.
4097
4098 ```
4099
4100 ### **Identifiers**
4101
4102 ```
4103 Identifiers name variables and functions.
4104
4105 identifier = letter { letter | digit } .
4106 letter = "A" ... "Z" | "a" ... "z" | "_" .
4107 digit = "0" ... "9" .
4108
4109 ```
4110
4111 ### **Keywords**
4112
4113 ```
4114 The following keywords are reserved and may not be used as
4115 identifiers:
4116
4117 else false if true
4118
4119 ```
4120
4121 ### **Integer literals**
4122
4123 ```
4124 An integer literal represents a decimal integer value.
4125
4126 integer = [ "-" ] digit { digit } .
4127
4128 Leading zeros and negative zero are disallowed.
4129
4130 ```
4131
4132 ### **String literals**
4133
4134 ```
4135 A string literal represents a string value consisting of the quoted
4136 characters with possible escape sequences and variable expansions.
4137
4138 string = `"` { char | escape | expansion } `"` .
4139 escape = `\` ( "$" | `"` | char ) .
4140 expansion = "$" ( identifier | "{" identifier "}" ) .
4141 char = /* any character except "$", `"`, or newline */ .
4142
4143 After a backslash, certain sequences represent special characters:
4144
4145 \" U+0022 quotation mark
4146 \$ U+0024 dollar sign
4147 \\ U+005C backslash
4148
4149 All other backslashes represent themselves.
4150
4151 ```
4152
4153 ### **Punctuation**
4154
4155 ```
4156 The following character sequences represent punctuation:
4157
4158 + += == != ( )
4159 - -= < <= [ ]
4160 ! = > >= { }
4161 && || . ,
4162
4163 ```
4164
4165 ### **Grammar**
4166
4167 ```
4168 The input tokens form a syntax tree following a context-free grammar:
4169
4170 File = StatementList .
4171
4172 Statement = Assignment | Call | Condition .
4173 Assignment = identifier AssignOp Expr .
4174 Call = identifier "(" [ ExprList ] ")" [ Block ] .
4175 Condition = "if" "(" Expr ")" Block
4176 [ "else" ( Condition | Block ) ] .
4177 Block = "{" StatementList "}" .
4178 StatementList = { Statement } .
4179
4180 Expr = UnaryExpr | Expr BinaryOp Expr .
4181 UnaryExpr = PrimaryExpr | UnaryOp UnaryExpr .
4182 PrimaryExpr = identifier | integer | string | Call
4183 | identifier "[" Expr "]"
4184 | identifier "." identifier
4185 | "(" Expr ")"
4186 | "[" [ ExprList [ "," ] ] "]" .
4187 ExprList = Expr { "," Expr } .
4188
4189 AssignOp = "=" | "+=" | "-=" .
4190 UnaryOp = "!" .
4191 BinaryOp = "+" | "-" // highest priority
4192 | "<" | "<=" | ">" | ">="
4193 | "==" | "!="
4194 | "&&"
4195 | "||" . // lowest priority
4196
4197 All binary operators are left-associative.
4198
4199
4200 ```
4076 ## **input_conversion**: Specifies how to transform input to a variable. 4201 ## **input_conversion**: Specifies how to transform input to a variable.
4077 4202
4078 ``` 4203 ```
4079 input_conversion is an argument to read_file and exec_script that 4204 input_conversion is an argument to read_file and exec_script that
4080 specifies how the result of the read operation should be converted 4205 specifies how the result of the read operation should be converted
4081 into a variable. 4206 into a variable.
4082 4207
4083 "" (the default) 4208 "" (the default)
4084 Discard the result and return None. 4209 Discard the result and return None.
4085 4210
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
4295 ** --markdown**: write the output in the Markdown format. 4420 ** --markdown**: write the output in the Markdown format.
4296 ** --nocolor**: Force non-colored output. 4421 ** --nocolor**: Force non-colored output.
4297 ** -q**: Quiet mode. Don't print output on success. 4422 ** -q**: Quiet mode. Don't print output on success.
4298 ** --root**: Explicitly specify source root. 4423 ** --root**: Explicitly specify source root.
4299 ** --time**: Outputs a summary of how long everything took. 4424 ** --time**: Outputs a summary of how long everything took.
4300 ** --tracelog**: Writes a Chrome-compatible trace log to the given file. 4425 ** --tracelog**: Writes a Chrome-compatible trace log to the given file.
4301 ** -v**: Verbose logging. 4426 ** -v**: Verbose logging.
4302 ** --version**: Prints the GN version number and exits. 4427 ** --version**: Prints the GN version number and exits.
4303 4428
4304 ``` 4429 ```
OLDNEW
« no previous file with comments | « tools/gn/command_help.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698