| 1 | |
|---|
| 2 | # |
|---|
| 3 | # This grammar was closely derived from |
|---|
| 4 | # ECMA-262, ECMAScript Language Specification, 3rd Edition |
|---|
| 5 | # Appendix A. |
|---|
| 6 | # |
|---|
| 7 | # Changes to specification grammar. |
|---|
| 8 | # * RegularExpressionLiteral has been added to Literal. |
|---|
| 9 | # Since we dont have a separate tokenizer. |
|---|
| 10 | # * <SourceCharacter> removals. |
|---|
| 11 | # Several "SourceCharacter but not ..." have been expressed as |
|---|
| 12 | # complemented character sets. <-[...]> They are all tagged with |
|---|
| 13 | # #SourceCharacter but not ... |
|---|
| 14 | # But <SourceCharacter> isnt called for all characters anyway, |
|---|
| 15 | # so no great loss. |
|---|
| 16 | # |
|---|
| 17 | # Other notes: |
|---|
| 18 | # * <ws> is redefined to be used, via :words, by A.3, A.4, and A.5. |
|---|
| 19 | # Note it is always an optional match. |
|---|
| 20 | # * Parts of the grammar, intended for a tokenizer, are not actually used. |
|---|
| 21 | # * Some rules, eg StringNumericLiteral, are not used in parsing JavaScript, |
|---|
| 22 | # but rather in implementing it (eg, by ToNumber). |
|---|
| 23 | # * Character sets are sometimes collapsed. |
|---|
| 24 | # Eg, <'0'> | <'1'> ... <'9'> changed to <[0..9]> |
|---|
| 25 | # * "Foo but not x" is expressed as |
|---|
| 26 | # <!before x> <Foo> |
|---|
| 27 | # * "lookahead is not an element of { x }" is expressed as |
|---|
| 28 | # <!before x> |
|---|
| 29 | # Such usage is tagged with #lookahead |
|---|
| 30 | # If rules taking arguments had any hope of working soon, |
|---|
| 31 | # I would have said <!lookahead x>. |
|---|
| 32 | # * "[no LineTerminator here]" is expressed as |
|---|
| 33 | # <no_LineTerminator_here>. |
|---|
| 34 | # |
|---|
| 35 | # Resources: |
|---|
| 36 | # http://www.ecma-international.org/publications/standards/Ecma-262.htm |
|---|
| 37 | # http://bclary.com/2004/11/07/ecma-262 |
|---|
| 38 | # |
|---|
| 39 | # The SPEC grammar SHOULD NOT BE CHANGED to accommodate the characteristics |
|---|
| 40 | # of particular regex engines. Its structure follows the spec. If for |
|---|
| 41 | # instance, your engine cannot handle left recursive rules, you should |
|---|
| 42 | # create a new grammar, inherit from this one, and redefine just those |
|---|
| 43 | # rules. See JavaScript::ECMAScript3::Grammar. |
|---|
| 44 | # |
|---|
| 45 | # Bugs: |
|---|
| 46 | # * This grammar has never yet been run, so there no doubt are some. |
|---|
| 47 | # |
|---|
| 48 | # Possible Bugs: |
|---|
| 49 | # * We are not using some of the tokenizer rules. |
|---|
| 50 | # So it isnt entirely clear we are doing an fully correct parse. |
|---|
| 51 | # |
|---|
| 52 | # Todo: |
|---|
| 53 | # * Create a second grammar which actually runs, is efficient, |
|---|
| 54 | # and has captures for easy use of the resulting matches. |
|---|
| 55 | # * Perhaps define a macro gram ($name) { "rule $name :words" }, |
|---|
| 56 | # rather than having the clutter of lots of explicit :words modifiers. |
|---|
| 57 | # |
|---|
| 58 | # Thanks to Bob Clary, who created the HTML-ified ecma-262, without which |
|---|
| 59 | # this grammar would likely not have been written. - Mitchell N Charity |
|---|
| 60 | # |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | grammar JavaScript::ECMAScript3::Grammar::Spec; |
|---|
| 64 | |
|---|
| 65 | rule ws {<?ws_input>*} |
|---|
| 66 | rule ws_required {<?ws_input>+} |
|---|
| 67 | rule ws_input { |
|---|
| 68 | <WhiteSpace> |
|---|
| 69 | | <LineTerminator> |
|---|
| 70 | | <Comment> |
|---|
| 71 | } |
|---|
| 72 | rule no_LineTerminator_here { |
|---|
| 73 | [ <ws> & <-<LineTerminator>>*? ] |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | # 7.2 White Space |
|---|
| 78 | |
|---|
| 79 | rule TAB { \x0009 } |
|---|
| 80 | rule VT { \x000B } |
|---|
| 81 | rule FF { \x000C } |
|---|
| 82 | rule SP { \x0020 } |
|---|
| 83 | rule NBSP { \x00A0 } |
|---|
| 84 | rule USP { <<Zs>-<TAB>-<VT>-<FF>-<SP>-<NBSP>> } |
|---|
| 85 | |
|---|
| 86 | # 7.3 Line Terminators |
|---|
| 87 | |
|---|
| 88 | rule LF { \x000A } |
|---|
| 89 | rule CR { \x000D } |
|---|
| 90 | rule LS { \x2028 } |
|---|
| 91 | rule PS { \x2029 } |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | # A.1 Lexical Grammar |
|---|
| 95 | |
|---|
| 96 | rule SourceCharacter { # see clause 6 |
|---|
| 97 | . #dot |
|---|
| 98 | } |
|---|
| 99 | rule InputElementDiv { # see clause 7 |
|---|
| 100 | <WhiteSpace> |
|---|
| 101 | | <LineTerminator> |
|---|
| 102 | | <Comment> |
|---|
| 103 | | <Token> <DivPunctuator> |
|---|
| 104 | } |
|---|
| 105 | rule InputElementRegExp { # see clause 7 |
|---|
| 106 | <WhiteSpace> |
|---|
| 107 | | <LineTerminator> |
|---|
| 108 | | <Comment> |
|---|
| 109 | | <Token> |
|---|
| 110 | | <RegularExpressionLiteral> |
|---|
| 111 | } |
|---|
| 112 | rule WhiteSpace { # see 7.2 |
|---|
| 113 | <TAB> |
|---|
| 114 | | <VT> |
|---|
| 115 | | <FF> |
|---|
| 116 | | <SP> |
|---|
| 117 | | <NBSP> |
|---|
| 118 | | <USP> |
|---|
| 119 | } |
|---|
| 120 | rule LineTerminator { # see 7.3 |
|---|
| 121 | <LF> |
|---|
| 122 | | <CR> |
|---|
| 123 | | <LS> |
|---|
| 124 | | <PS> |
|---|
| 125 | } |
|---|
| 126 | rule Comment { # see 7.4 |
|---|
| 127 | <MultiLineComment> |
|---|
| 128 | | <SingleLineComment> |
|---|
| 129 | } |
|---|
| 130 | rule MultiLineComment { # see 7.4 |
|---|
| 131 | <'/*'> <MultiLineCommentChars>? <'*/'> |
|---|
| 132 | } |
|---|
| 133 | rule MultiLineCommentChars { # see 7.4 |
|---|
| 134 | <MultiLineNotAsteriskChar> <MultiLineCommentChars>? |
|---|
| 135 | | <'*'> <PostAsteriskCommentChars>? |
|---|
| 136 | } |
|---|
| 137 | rule PostAsteriskCommentChars { # see 7.4 |
|---|
| 138 | <MultiLineNotForwardSlashOrAsteriskChar> <MultiLineCommentChars>? |
|---|
| 139 | | <'*'> <PostAsteriskCommentChars>? |
|---|
| 140 | } |
|---|
| 141 | rule MultiLineNotAsteriskChar { # see 7.4 |
|---|
| 142 | <-[*]> #SourceCharacter but not ... |
|---|
| 143 | } |
|---|
| 144 | rule MultiLineNotForwardSlashOrAsteriskChar { # see 7.4 |
|---|
| 145 | <-[/*]> #SourceCharacter but not ... |
|---|
| 146 | } |
|---|
| 147 | rule SingleLineComment { # see 7.4 |
|---|
| 148 | <'//'> <SingleLineCommentChars>? |
|---|
| 149 | } |
|---|
| 150 | rule SingleLineCommentChars { # see 7.4 |
|---|
| 151 | <SingleLineCommentChar> <SingleLineCommentChars>? |
|---|
| 152 | } |
|---|
| 153 | rule SingleLineCommentChar { # see 7.4 |
|---|
| 154 | <!before <LineTerminator>> <SourceCharacter> |
|---|
| 155 | } |
|---|
| 156 | rule Token { # see 7.5 |
|---|
| 157 | <ReservedWord> |
|---|
| 158 | | <Identifier> |
|---|
| 159 | | <Punctuator> |
|---|
| 160 | | <NumericLiteral> |
|---|
| 161 | | <StringLiteral> |
|---|
| 162 | } |
|---|
| 163 | rule ReservedWord { # see 7.5.1 |
|---|
| 164 | <Keyword> |
|---|
| 165 | | <FutureReservedWord> |
|---|
| 166 | | <NullLiteral> |
|---|
| 167 | | <BooleanLiteral> |
|---|
| 168 | } |
|---|
| 169 | rule Keyword { # see 7.5.2 |
|---|
| 170 | <'break'> |
|---|
| 171 | | <'else'> |
|---|
| 172 | | <'new'> |
|---|
| 173 | | <'var'> |
|---|
| 174 | | <'case'> |
|---|
| 175 | | <'finally'> |
|---|
| 176 | | <'return'> |
|---|
| 177 | | <'void'> |
|---|
| 178 | | <'catch'> |
|---|
| 179 | | <'for'> |
|---|
| 180 | | <'switch'> |
|---|
| 181 | | <'while'> |
|---|
| 182 | | <'continue'> |
|---|
| 183 | | <'function'> |
|---|
| 184 | | <'this'> |
|---|
| 185 | | <'with'> |
|---|
| 186 | | <'default'> |
|---|
| 187 | | <'if'> |
|---|
| 188 | | <'throw'> |
|---|
| 189 | | <'delete'> |
|---|
| 190 | | <'in'> |
|---|
| 191 | | <'try'> |
|---|
| 192 | | <'do'> |
|---|
| 193 | | <'instanceof'> |
|---|
| 194 | | <'typeof'> |
|---|
| 195 | } |
|---|
| 196 | rule FutureReservedWord { # see 7.5.3 |
|---|
| 197 | <'abstract'> |
|---|
| 198 | | <'enum'> |
|---|
| 199 | | <'int'> |
|---|
| 200 | | <'short'> |
|---|
| 201 | | <'boolean'> |
|---|
| 202 | | <'export'> |
|---|
| 203 | | <'interface'> |
|---|
| 204 | | <'static'> |
|---|
| 205 | | <'byte'> |
|---|
| 206 | | <'extends'> |
|---|
| 207 | | <'long'> |
|---|
| 208 | | <'super'> |
|---|
| 209 | | <'char'> |
|---|
| 210 | | <'final'> |
|---|
| 211 | | <'native'> |
|---|
| 212 | | <'synchronized'> |
|---|
| 213 | | <'class'> |
|---|
| 214 | | <'float'> |
|---|
| 215 | | <'package'> |
|---|
| 216 | | <'throws'> |
|---|
| 217 | | <'const'> |
|---|
| 218 | | <'goto'> |
|---|
| 219 | | <'private'> |
|---|
| 220 | | <'transient'> |
|---|
| 221 | | <'debugger'> |
|---|
| 222 | | <'implements'> |
|---|
| 223 | | <'protected'> |
|---|
| 224 | | <'volatile'> |
|---|
| 225 | | <'double'> |
|---|
| 226 | | <'import'> |
|---|
| 227 | | <'public'> |
|---|
| 228 | } |
|---|
| 229 | rule Identifier { # see 7.6 |
|---|
| 230 | <!before <ReservedWord>> <IdentifierName> |
|---|
| 231 | } |
|---|
| 232 | rule IdentifierName { # see 7.6 |
|---|
| 233 | <IdentifierStart> |
|---|
| 234 | | <IdentifierName> <IdentifierPart> |
|---|
| 235 | } |
|---|
| 236 | rule IdentifierStart { # see 7.6 |
|---|
| 237 | <UnicodeLetter> |
|---|
| 238 | | <'$'> |
|---|
| 239 | | <'_'> |
|---|
| 240 | | <'\\'> <UnicodeEscapeSequence> |
|---|
| 241 | } |
|---|
| 242 | rule IdentifierPart { # see 7.6 |
|---|
| 243 | <IdentifierStart> |
|---|
| 244 | | <UnicodeCombiningMark> |
|---|
| 245 | | <UnicodeDigit> |
|---|
| 246 | | <UnicodeConnectorPunctuation> |
|---|
| 247 | | <'\\'> <UnicodeEscapeSequence> |
|---|
| 248 | } |
|---|
| 249 | rule UnicodeLetter { # see 7.6 |
|---|
| 250 | # any character in the Unicode categories "Uppercase letter (Lu)", |
|---|
| 251 | # "Lowercase letter (Ll)", "Titlecase letter (Lt)", |
|---|
| 252 | # "Modifier letter (Lm)", "Other letter (Lo)", or "Letter number (Nl)". |
|---|
| 253 | <Lu> | <Ll> | <Lt> | <Lm> | <Lo> | <Nl> |
|---|
| 254 | } |
|---|
| 255 | rule UnicodeCombiningMark { # see 7.6 |
|---|
| 256 | # any character in the Unicode categories "Non-spacing mark (Mn)" |
|---|
| 257 | # or "Combining spacing mark (Mc)" |
|---|
| 258 | <Mn> | <Mc> |
|---|
| 259 | } |
|---|
| 260 | rule UnicodeDigit { # see 7.6 |
|---|
| 261 | # any character in the Unicode category "Decimal number (Nd)" |
|---|
| 262 | <Nd> |
|---|
| 263 | } |
|---|
| 264 | rule UnicodeConnectorPunctuation { # see 7.6 |
|---|
| 265 | # any character in the Unicode category "Connector punctuation (Pc)" |
|---|
| 266 | <Pc> |
|---|
| 267 | } |
|---|
| 268 | rule HexDigit { # see 7.6 |
|---|
| 269 | <[0..9a..fA..F]> |
|---|
| 270 | } |
|---|
| 271 | rule Punctuator { # see 7.7 |
|---|
| 272 | <'{'> |
|---|
| 273 | | <'}'> |
|---|
| 274 | | <'('> |
|---|
| 275 | | <')'> |
|---|
| 276 | | <'['> |
|---|
| 277 | | <']'> |
|---|
| 278 | | <'.'> |
|---|
| 279 | | <';'> |
|---|
| 280 | | <','> |
|---|
| 281 | | <'<'> |
|---|
| 282 | | <'>'> |
|---|
| 283 | | <'<='> |
|---|
| 284 | | <'>='> |
|---|
| 285 | | <'=='> |
|---|
| 286 | | <'!='> |
|---|
| 287 | | <'==='> |
|---|
| 288 | | <'!=='> |
|---|
| 289 | | <'+'> |
|---|
| 290 | | <'-'> |
|---|
| 291 | | <'*'> |
|---|
| 292 | | <'%'> |
|---|
| 293 | | <'++'> |
|---|
| 294 | | <'--'> |
|---|
| 295 | | <'<<'> |
|---|
| 296 | | <'>>'> |
|---|
| 297 | | <'>>>'> |
|---|
| 298 | | <'&'> |
|---|
| 299 | | <'|'> |
|---|
| 300 | | <'^'> |
|---|
| 301 | | <'!'> |
|---|
| 302 | | <'~'> |
|---|
| 303 | | <'&&'> |
|---|
| 304 | | <'||'> |
|---|
| 305 | | <'?'> |
|---|
| 306 | | <':'> |
|---|
| 307 | | <'='> |
|---|
| 308 | | <'+='> |
|---|
| 309 | | <'-='> |
|---|
| 310 | | <'*='> |
|---|
| 311 | | <'%='> |
|---|
| 312 | | <'<<='> |
|---|
| 313 | | <'>>='> |
|---|
| 314 | | <'>>>='> |
|---|
| 315 | | <'&='> |
|---|
| 316 | | <'|='> |
|---|
| 317 | | <'^='> |
|---|
| 318 | } |
|---|
| 319 | rule DivPunctuator { # see 7.7 |
|---|
| 320 | <'/'> |
|---|
| 321 | | <'/='> |
|---|
| 322 | } |
|---|
| 323 | rule Literal { # see 7.8 |
|---|
| 324 | <NullLiteral> |
|---|
| 325 | | <BooleanLiteral> |
|---|
| 326 | | <NumericLiteral> |
|---|
| 327 | | <StringLiteral> |
|---|
| 328 | | <RegularExpressionLiteral> # ADDED - this is not in the spec. |
|---|
| 329 | } |
|---|
| 330 | rule NullLiteral { # see 7.8.1 |
|---|
| 331 | <'null'> |
|---|
| 332 | } |
|---|
| 333 | rule BooleanLiteral { # see 7.8.2 |
|---|
| 334 | <'true'> |
|---|
| 335 | | <'false'> |
|---|
| 336 | } |
|---|
| 337 | rule NumericLiteral { # see 7.8.3 |
|---|
| 338 | <DecimalLiteral> |
|---|
| 339 | | <HexIntegerLiteral> |
|---|
| 340 | } |
|---|
| 341 | rule DecimalLiteral { # see 7.8.3 |
|---|
| 342 | <DecimalIntegerLiteral> <'.'> <DecimalDigits>? <ExponentPart>? |
|---|
| 343 | | <'.'> <DecimalDigits> <ExponentPart>? |
|---|
| 344 | | <DecimalIntegerLiteral> <ExponentPart>? |
|---|
| 345 | } |
|---|
| 346 | rule DecimalIntegerLiteral { # see 7.8.3 |
|---|
| 347 | <'0'> |
|---|
| 348 | | <NonZeroDigit> <DecimalDigits>? |
|---|
| 349 | } |
|---|
| 350 | rule DecimalDigits { # see 7.8.3 |
|---|
| 351 | <DecimalDigit> |
|---|
| 352 | | <DecimalDigits> <DecimalDigit> |
|---|
| 353 | } |
|---|
| 354 | rule DecimalDigit { # see 7.8.3 |
|---|
| 355 | <[0..9]> |
|---|
| 356 | } |
|---|
| 357 | rule ExponentIndicator { # see 7.8.3 |
|---|
| 358 | <'e'> |
|---|
| 359 | | <'E'> |
|---|
| 360 | } |
|---|
| 361 | rule SignedInteger { # see 7.8.3 |
|---|
| 362 | <DecimalDigits> |
|---|
| 363 | | <'+'> <DecimalDigits> |
|---|
| 364 | | <'-'> <DecimalDigits> |
|---|
| 365 | } |
|---|
| 366 | rule HexIntegerLiteral { # see 7.8.3 |
|---|
| 367 | <'0x'> <HexDigit> |
|---|
| 368 | | <'0X'> <HexDigit> |
|---|
| 369 | | <HexIntegerLiteral> <HexDigit> |
|---|
| 370 | } |
|---|
| 371 | rule StringLiteral { # see 7.8.4 |
|---|
| 372 | <'"'> <DoubleStringCharacters>? <'"'> |
|---|
| 373 | | <'\''> <SingleStringCharacters>? <'\''> |
|---|
| 374 | } |
|---|
| 375 | rule DoubleStringCharacters { # see 7.8.4 |
|---|
| 376 | <DoubleStringCharacter> <DoubleStringCharacters>? |
|---|
| 377 | } |
|---|
| 378 | rule SingleStringCharacters { # see 7.8.4 |
|---|
| 379 | <SingleStringCharacter> <SingleStringCharacters>? |
|---|
| 380 | } |
|---|
| 381 | rule DoubleStringCharacter { # see 7.8.4 |
|---|
| 382 | <!before <LineTerminator>> <-[\"\\]> #SourceCharacter but not ... |
|---|
| 383 | | <'\\'> <EscapeSequence> |
|---|
| 384 | } |
|---|
| 385 | rule SingleStringCharacter { # see 7.8.4 |
|---|
| 386 | <!before <LineTerminator>> <-[\'\\]> #SourceCharacter but not ... |
|---|
| 387 | | <'\\'> <EscapeSequence> |
|---|
| 388 | } |
|---|
| 389 | rule EscapeSequence { # see 7.8.4 |
|---|
| 390 | <CharacterEscapeSequence> |
|---|
| 391 | | <'0'> <!before <DecimalDigit>> #lookahead |
|---|
| 392 | | <HexEscapeSequence> |
|---|
| 393 | | <UnicodeEscapeSequence> |
|---|
| 394 | } |
|---|
| 395 | rule CharacterEscapeSequence { # see 7.8.4 |
|---|
| 396 | <SingleEscapeCharacter> |
|---|
| 397 | | <NonEscapeCharacter> |
|---|
| 398 | } |
|---|
| 399 | rule SingleEscapeCharacter { # see 7.8.4 |
|---|
| 400 | <'\''> |
|---|
| 401 | | <'"'> |
|---|
| 402 | | <'\\'> |
|---|
| 403 | | <'b'> |
|---|
| 404 | | <'f'> |
|---|
| 405 | | <'n'> |
|---|
| 406 | | <'r'> |
|---|
| 407 | | <'t'> |
|---|
| 408 | | <'v'> |
|---|
| 409 | } |
|---|
| 410 | rule EscapeCharacter { # see 7.8.4 |
|---|
| 411 | <SingleEscapeCharacter> |
|---|
| 412 | | <DecimalDigit> |
|---|
| 413 | | <'x'> |
|---|
| 414 | | <'u'> |
|---|
| 415 | } |
|---|
| 416 | rule HexEscapeSequence { # see 7.8.4 |
|---|
| 417 | <'x'> <HexDigit> <HexDigit> |
|---|
| 418 | } |
|---|
| 419 | rule UnicodeEscapeSequence { # see 7.8.4 |
|---|
| 420 | <'u'> <HexDigit> <HexDigit> <HexDigit> <HexDigit> |
|---|
| 421 | } |
|---|
| 422 | rule RegularExpressionLiteral { # see 7.8.5 |
|---|
| 423 | <'/'> <RegularExpressionBody> <'/'> <RegularExpressionFlags> |
|---|
| 424 | } |
|---|
| 425 | rule RegularExpressionBody { # see 7.8.5 |
|---|
| 426 | <RegularExpressionFirstChar> <RegularExpressionChars> |
|---|
| 427 | } |
|---|
| 428 | rule RegularExpressionChars { # see 7.8.5 |
|---|
| 429 | <null> |
|---|
| 430 | | <RegularExpressionChars> <RegularExpressionChar> |
|---|
| 431 | } |
|---|
| 432 | rule RegularExpressionFirstChar { # see 7.8.5 |
|---|
| 433 | <!before <[*\\\/]>> <NonTerminator> |
|---|
| 434 | | <BackslashSequence> |
|---|
| 435 | } |
|---|
| 436 | rule RegularExpressionChar { # see 7.8.5 |
|---|
| 437 | <!before <[\\\/]>> <NonTerminator> |
|---|
| 438 | | <BackslashSequence> |
|---|
| 439 | } |
|---|
| 440 | rule BackslashSequence { # see 7.8.5 |
|---|
| 441 | <'\\'> <NonTerminator> |
|---|
| 442 | } |
|---|
| 443 | rule NonTerminator { # see 7.8.5 |
|---|
| 444 | <!before <LineTerminator>> <SourceCharacter> |
|---|
| 445 | } |
|---|
| 446 | rule RegularExpressionFlags { # see 7.8.5 |
|---|
| 447 | <null> |
|---|
| 448 | | <RegularExpressionFlags> <IdentifierPart> |
|---|
| 449 | } |
|---|
| 450 | |
|---|
| 451 | # A.2 Number Conversions |
|---|
| 452 | |
|---|
| 453 | rule StringNumericLiteral { # see 9.3.1 |
|---|
| 454 | <StrWhiteSpace>? |
|---|
| 455 | | <StrWhiteSpace>? <StrNumericLiteral> <StrWhiteSpace>? |
|---|
| 456 | } |
|---|
| 457 | rule StrWhiteSpace { # see 9.3.1 |
|---|
| 458 | <StrWhiteSpaceChar> <StrWhiteSpace>? |
|---|
| 459 | } |
|---|
| 460 | rule StrWhiteSpaceChar { # see 9.3.1 |
|---|
| 461 | <TAB> |
|---|
| 462 | | <SP> |
|---|
| 463 | | <NBSP> |
|---|
| 464 | | <FF> |
|---|
| 465 | | <VT> |
|---|
| 466 | | <CR> |
|---|
| 467 | | <LF> |
|---|
| 468 | | <LS> |
|---|
| 469 | | <PS> |
|---|
| 470 | | <USP> |
|---|
| 471 | } |
|---|
| 472 | rule StrNumericLiteral { # see 9.3.1 |
|---|
| 473 | <StrDecimalLiteral> |
|---|
| 474 | | <HexIntegerLiteral> |
|---|
| 475 | } |
|---|
| 476 | rule StrDecimalLiteral { # see 9.3.1 |
|---|
| 477 | <StrUnsignedDecimalLiteral> |
|---|
| 478 | | <'+'> <StrUnsignedDecimalLiteral> |
|---|
| 479 | | <'-'> <StrUnsignedDecimalLiteral> |
|---|
| 480 | } |
|---|
| 481 | rule StrUnsignedDecimalLiteral { # see 9.3.1 |
|---|
| 482 | <'Infinity'> |
|---|
| 483 | | <DecimalDigits> <'.'> <DecimalDigits>? <ExponentPart>? |
|---|
| 484 | | <'.'> <DecimalDigits> <ExponentPart>? |
|---|
| 485 | | <DecimalDigits> <ExponentPart>? |
|---|
| 486 | } |
|---|
| 487 | rule DecimalDigits { # see 9.3.1 |
|---|
| 488 | <DecimalDigit> |
|---|
| 489 | | <DecimalDigits> <DecimalDigit> |
|---|
| 490 | } |
|---|
| 491 | rule DecimalDigit { # see 9.3.1 |
|---|
| 492 | <[0..9]> |
|---|
| 493 | } |
|---|
| 494 | rule ExponentPart { # see 9.3.1 |
|---|
| 495 | <ExponentIndicator> <SignedInteger> |
|---|
| 496 | } |
|---|
| 497 | rule ExponentIndicator { # see 9.3.1 |
|---|
| 498 | <'e'> |
|---|
| 499 | | <'E'> |
|---|
| 500 | } |
|---|
| 501 | rule SignedInteger { # see 9.3.1 |
|---|
| 502 | <DecimalDigits> |
|---|
| 503 | | <'+'> <DecimalDigits> |
|---|
| 504 | | <'-'> <DecimalDigits> |
|---|
| 505 | } |
|---|
| 506 | rule HexIntegerLiteral { # see 9.3.1 |
|---|
| 507 | <'0x'> <HexDigit> |
|---|
| 508 | | <'0X'> <HexDigit> |
|---|
| 509 | | <HexIntegerLiteral> <HexDigit> |
|---|
| 510 | } |
|---|
| 511 | rule HexDigit { # see 9.3.1 |
|---|
| 512 | <[0..9a..fA..F]> |
|---|
| 513 | } |
|---|
| 514 | |
|---|
| 515 | # A.3 Expressions |
|---|
| 516 | |
|---|
| 517 | rule PrimaryExpression :words { # see 11.1 |
|---|
| 518 | <'this'> |
|---|
| 519 | | <Identifier> |
|---|
| 520 | | <Literal> |
|---|
| 521 | | <ArrayLiteral> |
|---|
| 522 | | <ObjectLiteral> |
|---|
| 523 | | <'('> <Expression> <')'> |
|---|
| 524 | } |
|---|
| 525 | rule ArrayLiteral :words { # see 11.1.4 |
|---|
| 526 | <'['> <Elision>? <']'> |
|---|
| 527 | | <'['> <ElementList> <']'> |
|---|
| 528 | | <'['> <ElementList> <','> <Elision>? <']'> |
|---|
| 529 | } |
|---|
| 530 | rule ElementList :words { # see 11.1.4 |
|---|
| 531 | <Elision>? <AssignmentExpression> |
|---|
| 532 | | <ElementList> <','> <Elision>? <AssignmentExpression> |
|---|
| 533 | } |
|---|
| 534 | rule Elision :words { # see 11.1.4 |
|---|
| 535 | <','> |
|---|
| 536 | | <Elision> <','> |
|---|
| 537 | } |
|---|
| 538 | rule ObjectLiteral :words { # see 11.1.5 |
|---|
| 539 | <'{'> <'}'> |
|---|
| 540 | | <'{'> <PropertyNameAndValueList> <'}'> |
|---|
| 541 | } |
|---|
| 542 | rule PropertyNameAndValueList :words { # see 11.1.5 |
|---|
| 543 | <PropertyName> <':'> <AssignmentExpression> |
|---|
| 544 | | <PropertyNameAndValueList> <','> <PropertyName> <':'> <AssignmentExpression> |
|---|
| 545 | } |
|---|
| 546 | rule PropertyName :words { # see 11.1.5 |
|---|
| 547 | <Identifier> |
|---|
| 548 | | <StringLiteral> |
|---|
| 549 | | <NumericLiteral> |
|---|
| 550 | } |
|---|
| 551 | rule MemberExpression :words { # see 11.2 |
|---|
| 552 | <PrimaryExpression> |
|---|
| 553 | | <FunctionExpression> |
|---|
| 554 | | <MemberExpression> <'['> <Expression> <']'> |
|---|
| 555 | | <MemberExpression> <'.'> <Identifier> |
|---|
| 556 | | <'new'> <?ws_required> <MemberExpression> <Arguments> |
|---|
| 557 | } |
|---|
| 558 | rule NewExpression :words { # see 11.2 |
|---|
| 559 | <MemberExpression> |
|---|
| 560 | | <'new'> <?ws_required> <NewExpression> |
|---|
| 561 | } |
|---|
| 562 | rule CallExpression :words { # see 11.2 |
|---|
| 563 | <MemberExpression> <Arguments> |
|---|
| 564 | | <CallExpression> <Arguments> |
|---|
| 565 | | <CallExpression> <'['> <Expression> <']'> |
|---|
| 566 | | <CallExpression> <'.'> <Identifier> |
|---|
| 567 | } |
|---|
| 568 | rule Arguments :words { # see 11.2 |
|---|
| 569 | <'('> <')'> |
|---|
| 570 | | <'('> <ArgumentList> <')'> |
|---|
| 571 | } |
|---|
| 572 | rule ArgumentList :words { # see 11.2 |
|---|
| 573 | <AssignmentExpression> |
|---|
| 574 | | <ArgumentList> <','> <AssignmentExpression> |
|---|
| 575 | } |
|---|
| 576 | rule LeftHandSideExpression :words { # see 11.2 |
|---|
| 577 | <NewExpression> |
|---|
| 578 | | <CallExpression> |
|---|
| 579 | } |
|---|
| 580 | rule PostfixExpression :words { # see 11.3 |
|---|
| 581 | <LeftHandSideExpression> |
|---|
| 582 | | <LeftHandSideExpression><no_LineTerminator_here><'++'> |
|---|
| 583 | | <LeftHandSideExpression><no_LineTerminator_here><'--'> |
|---|
| 584 | } |
|---|
| 585 | rule UnaryExpression :words { # see 11.4 |
|---|
| 586 | <PostfixExpression> |
|---|
| 587 | | <'delete'> <UnaryExpression> |
|---|
| 588 | | <'void'> <UnaryExpression> |
|---|
| 589 | | <'typeof'> <UnaryExpression> |
|---|
| 590 | | <'++'> <UnaryExpression> |
|---|
| 591 | | <'--'> <UnaryExpression> |
|---|
| 592 | | <'+'> <UnaryExpression> |
|---|
| 593 | | <'-'> <UnaryExpression> |
|---|
| 594 | | <'~'> <UnaryExpression> |
|---|
| 595 | | <'!'> <UnaryExpression> |
|---|
| 596 | } |
|---|
| 597 | rule MultiplicativeExpression :words { # see 11.5 |
|---|
| 598 | <UnaryExpression> |
|---|
| 599 | | <MultiplicativeExpression> <'*'> <UnaryExpression> |
|---|
| 600 | | <MultiplicativeExpression> <'/'> <UnaryExpression> |
|---|
| 601 | | <MultiplicativeExpression> <'%'> <UnaryExpression> |
|---|
| 602 | } |
|---|
| 603 | rule AdditiveExpression :words { # see 11.6 |
|---|
| 604 | <MultiplicativeExpression> |
|---|
| 605 | | <AdditiveExpression> <'+'> <MultiplicativeExpression> |
|---|
| 606 | | <AdditiveExpression> <'-'> <MultiplicativeExpression> |
|---|
| 607 | } |
|---|
| 608 | rule ShiftExpression :words { # see 11.7 |
|---|
| 609 | <AdditiveExpression> |
|---|
| 610 | | <ShiftExpression> <'<<'> <AdditiveExpression> |
|---|
| 611 | | <ShiftExpression> <'>>'> <AdditiveExpression> |
|---|
| 612 | | <ShiftExpression> <'>>>'> <AdditiveExpression> |
|---|
| 613 | } |
|---|
| 614 | rule RelationalExpression :words { # see 11.8 |
|---|
| 615 | <ShiftExpression> |
|---|
| 616 | | <RelationalExpression> <'<'> <ShiftExpression> |
|---|
| 617 | | <RelationalExpression> <'>'> <ShiftExpression> |
|---|
| 618 | | <RelationalExpression> <'<='> <ShiftExpression> |
|---|
| 619 | | <RelationalExpression> <'>='> <ShiftExpression> |
|---|
| 620 | | <RelationalExpression> <'instanceof'> <ShiftExpression> |
|---|
| 621 | | <RelationalExpression> <'in'> <ShiftExpression> |
|---|
| 622 | } |
|---|
| 623 | rule RelationalExpressionNoIn :words { # see 11.8 |
|---|
| 624 | <ShiftExpression> |
|---|
| 625 | | <RelationalExpressionNoIn> <'<'> <ShiftExpression> |
|---|
| 626 | | <RelationalExpressionNoIn> <'>'> <ShiftExpression> |
|---|
| 627 | | <RelationalExpressionNoIn> <'<='> <ShiftExpression> |
|---|
| 628 | | <RelationalExpressionNoIn> <'>='> <ShiftExpression> |
|---|
| 629 | | <RelationalExpressionNoIn> <'instanceof'> <ShiftExpression> |
|---|
| 630 | } |
|---|
| 631 | rule EqualityExpression :words { # see 11.9 |
|---|
| 632 | <RelationalExpression> |
|---|
| 633 | | <EqualityExpression> <'=='> <RelationalExpression> |
|---|
| 634 | | <EqualityExpression> <'!='> <RelationalExpression> |
|---|
| 635 | | <EqualityExpression> <'==='> <RelationalExpression> |
|---|
| 636 | | <EqualityExpression> <'!=='> <RelationalExpression> |
|---|
| 637 | } |
|---|
| 638 | rule EqualityExpressionNoIn :words { # see 11.9 |
|---|
| 639 | <RelationalExpressionNoIn> |
|---|
| 640 | | <EqualityExpressionNoIn> <'=='> <RelationalExpressionNoIn> |
|---|
| 641 | | <EqualityExpressionNoIn> <'!='> <RelationalExpressionNoIn> |
|---|
| 642 | | <EqualityExpressionNoIn> <'==='> <RelationalExpressionNoIn> |
|---|
| 643 | | <EqualityExpressionNoIn> <'!=='> <RelationalExpressionNoIn> |
|---|
| 644 | } |
|---|
| 645 | rule BitwiseANDExpression :words { # see 11.10 |
|---|
| 646 | <EqualityExpression> |
|---|
| 647 | | <BitwiseANDExpression> <'&'> <EqualityExpression> |
|---|
| 648 | } |
|---|
| 649 | rule BitwiseANDExpressionNoIn :words { # see 11.10 |
|---|
| 650 | <EqualityExpressionNoIn> |
|---|
| 651 | | <BitwiseANDExpressionNoIn> <'&'> <EqualityExpressionNoIn> |
|---|
| 652 | } |
|---|
| 653 | rule BitwiseXORExpression :words { # see 11.10 |
|---|
| 654 | <BitwiseANDExpression> |
|---|
| 655 | | <BitwiseXORExpression> <'^'> <BitwiseANDExpression> |
|---|
| 656 | } |
|---|
| 657 | rule BitwiseXORExpressionNoIn :words { # see 11.10 |
|---|
| 658 | <BitwiseANDExpressionNoIn> |
|---|
| 659 | | <BitwiseXORExpressionNoIn> <'^'> <BitwiseANDExpressionNoIn> |
|---|
| 660 | } |
|---|
| 661 | rule BitwiseORExpression :words { # see 11.10 |
|---|
| 662 | <BitwiseXORExpression> |
|---|
| 663 | | <BitwiseORExpression> <'|'> <BitwiseXORExpression> |
|---|
| 664 | } |
|---|
| 665 | rule BitwiseORExpressionNoIn :words { # see 11.10 |
|---|
| 666 | <BitwiseXORExpressionNoIn> |
|---|
| 667 | | <BitwiseORExpressionNoIn> <'|'> <BitwiseXORExpressionNoIn> |
|---|
| 668 | } |
|---|
| 669 | rule LogicalANDExpression :words { # see 11.11 |
|---|
| 670 | <BitwiseORExpression> |
|---|
| 671 | | <LogicalANDExpression> <'&&'> <BitwiseORExpression> |
|---|
| 672 | } |
|---|
| 673 | rule LogicalANDExpressionNoIn :words { # see 11.11 |
|---|
| 674 | <BitwiseORExpressionNoIn> |
|---|
| 675 | | <LogicalANDExpressionNoIn> <'&&'> <BitwiseORExpressionNoIn> |
|---|
| 676 | } |
|---|
| 677 | rule LogicalORExpression :words { # see 11.11 |
|---|
| 678 | <LogicalANDExpression> |
|---|
| 679 | | <LogicalORExpression> <'||'> <LogicalANDExpression> |
|---|
| 680 | } |
|---|
| 681 | rule LogicalORExpressionNoIn :words { # see 11.11 |
|---|
| 682 | <LogicalANDExpressionNoIn> |
|---|
| 683 | | <LogicalORExpressionNoIn> <'||'> <LogicalANDExpressionNoIn> |
|---|
| 684 | } |
|---|
| 685 | rule ConditionalExpression :words { # see 11.12 |
|---|
| 686 | <LogicalORExpression> |
|---|
| 687 | | <LogicalORExpression> <'?'> <AssignmentExpression> <':'> <AssignmentExpression> |
|---|
| 688 | } |
|---|
| 689 | rule ConditionalExpressionNoIn :words { # see 11.12 |
|---|
| 690 | <LogicalORExpressionNoIn> |
|---|
| 691 | | <LogicalORExpressionNoIn> <'?'> <AssignmentExpressionNoIn> <':'> <AssignmentExpressionNoIn> |
|---|
| 692 | } |
|---|
| 693 | rule AssignmentExpression :words { # see 11.13 |
|---|
| 694 | <ConditionalExpression> |
|---|
| 695 | | <LeftHandSideExpression> <AssignmentOperator> <AssignmentExpression> |
|---|
| 696 | } |
|---|
| 697 | rule AssignmentExpressionNoIn :words { # see 11.13 |
|---|
| 698 | <ConditionalExpressionNoIn> |
|---|
| 699 | | <LeftHandSideExpression> <AssignmentOperator> <AssignmentExpressionNoIn> |
|---|
| 700 | } |
|---|
| 701 | rule AssignmentOperator :words { # see 11.13 |
|---|
| 702 | <'='> |
|---|
| 703 | | <'*='> |
|---|
| 704 | | <'/='> |
|---|
| 705 | | <'%='> |
|---|
| 706 | | <'+='> |
|---|
| 707 | | <'-='> |
|---|
| 708 | | <'<<='> |
|---|
| 709 | | <'>>='> |
|---|
| 710 | | <'>>>='> |
|---|
| 711 | | <'&='> |
|---|
| 712 | | <'^='> |
|---|
| 713 | | <'|='> |
|---|
| 714 | } |
|---|
| 715 | rule Expression :words { # see 11.14 |
|---|
| 716 | <AssignmentExpression> |
|---|
| 717 | | <Expression> <','> <AssignmentExpression> |
|---|
| 718 | } |
|---|
| 719 | rule ExpressionNoIn :words { # see 11.14 |
|---|
| 720 | <AssignmentExpressionNoIn> |
|---|
| 721 | | <ExpressionNoIn> <','> <AssignmentExpressionNoIn> |
|---|
| 722 | } |
|---|
| 723 | |
|---|
| 724 | # A.4 Statements |
|---|
| 725 | |
|---|
| 726 | rule Statement :words { # see clause 12 |
|---|
| 727 | <Block> |
|---|
| 728 | | <VariableStatement> |
|---|
| 729 | | <EmptyStatement> |
|---|
| 730 | | <ExpressionStatement> |
|---|
| 731 | | <IfStatement> |
|---|
| 732 | | <IterationStatement> |
|---|
| 733 | | <ContinueStatement> |
|---|
| 734 | | <BreakStatement> |
|---|
| 735 | | <ReturnStatement> |
|---|
| 736 | | <WithStatement> |
|---|
| 737 | | <LabelledStatement> |
|---|
| 738 | | <SwitchStatement> |
|---|
| 739 | | <ThrowStatement> |
|---|
| 740 | | <TryStatement> |
|---|
| 741 | } |
|---|
| 742 | rule Block :words { # see 12.1 |
|---|
| 743 | <'{'> <StatementList>? <'}'> |
|---|
| 744 | } |
|---|
| 745 | rule StatementList :words { # see 12.1 |
|---|
| 746 | <Statement> |
|---|
| 747 | | <StatementList> <Statement> |
|---|
| 748 | } |
|---|
| 749 | rule VariableStatement :words { # see 12.2 |
|---|
| 750 | <'var'> <?ws_required> <VariableDeclarationList> <';'> |
|---|
| 751 | } |
|---|
| 752 | rule VariableDeclarationList :words { # see 12.2 |
|---|
| 753 | <VariableDeclaration> |
|---|
| 754 | | <VariableDeclarationList> <','> <VariableDeclaration> |
|---|
| 755 | } |
|---|
| 756 | rule VariableDeclarationListNoIn :words { # see 12.2 |
|---|
| 757 | <VariableDeclarationNoIn> |
|---|
| 758 | | <VariableDeclarationListNoIn> <','> <VariableDeclarationNoIn> |
|---|
| 759 | } |
|---|
| 760 | rule VariableDeclaration :words { # see 12.2 |
|---|
| 761 | <Identifier> <Initialiser>? |
|---|
| 762 | } |
|---|
| 763 | rule VariableDeclarationNoIn :words { # see 12.2 |
|---|
| 764 | <Identifier> <InitialiserNoIn>? |
|---|
| 765 | } |
|---|
| 766 | rule Initialiser :words { # see 12.2 |
|---|
| 767 | <'='> <AssignmentExpression> |
|---|
| 768 | } |
|---|
| 769 | rule InitialiserNoIn :words { # see 12.2 |
|---|
| 770 | <'='> <AssignmentExpressionNoIn> |
|---|
| 771 | } |
|---|
| 772 | rule EmptyStatement :words { # see 12.3 |
|---|
| 773 | <';'> |
|---|
| 774 | } |
|---|
| 775 | rule ExpressionStatement :words { # see 12.4 |
|---|
| 776 | <!before <'function'>><Expression> <';'> #lookahead |
|---|
| 777 | } |
|---|
| 778 | rule IfStatement :words { # see 12.5 |
|---|
| 779 | <'if'> <'('> <Expression> <')'> <Statement> <'else'> <Statement> |
|---|
| 780 | | <'if'> <'('> <Expression> <')'> <Statement> |
|---|
| 781 | } |
|---|
| 782 | rule IterationStatement :words { # see 12.6 |
|---|
| 783 | <'do'> <Statement> <'while'> <'('> <Expression> <');'> |
|---|
| 784 | | <'while'> <'('> <Expression> <')'> <Statement> |
|---|
| 785 | | <'for'> <'('> <ExpressionNoIn>? <';'> <Expression>? <';'> <Expression>? <')'> <Statement> |
|---|
| 786 | | <'for'> <'('> <'var'> <VariableDeclarationListNoIn> <';'> <Expression>? <';'> <Expression>? <')'> <Statement> |
|---|
| 787 | | <'for'> <'('> <LeftHandSideExpression> <'in'> <Expression> <')'> <Statement> |
|---|
| 788 | | <'for'> <'('> <'var'> <VariableDeclarationNoIn> <'in'> <Expression> <')'> <Statement> |
|---|
| 789 | } |
|---|
| 790 | rule ContinueStatement :words { # see 12.7 |
|---|
| 791 | <'continue'><no_LineTerminator_here><Identifier>? <';'> |
|---|
| 792 | } |
|---|
| 793 | rule BreakStatement :words { # see 12.8 |
|---|
| 794 | <'break'><no_LineTerminator_here><Identifier>? <';'> |
|---|
| 795 | } |
|---|
| 796 | rule ReturnStatement :words { # see 12.9 |
|---|
| 797 | <'return'><no_LineTerminator_here><Expression>? <';'> |
|---|
| 798 | } |
|---|
| 799 | rule WithStatement :words { # see 12.10 |
|---|
| 800 | <'with'> <'('> <Expression> <')'> <Statement> |
|---|
| 801 | } |
|---|
| 802 | rule SwitchStatement :words { # see 12.11 |
|---|
| 803 | <'switch'> <'('> <Expression> <')'> <CaseBlock> |
|---|
| 804 | } |
|---|
| 805 | rule CaseBlock :words { # see 12.11 |
|---|
| 806 | <'{'> <CaseClauses>? <'}'> |
|---|
| 807 | | <'{'> <CaseClauses>? <DefaultClause> <CaseClauses>? <'}'> |
|---|
| 808 | } |
|---|
| 809 | rule CaseClauses :words { # see 12.11 |
|---|
| 810 | <CaseClause> |
|---|
| 811 | | <CaseClauses> <CaseClause> |
|---|
| 812 | } |
|---|
| 813 | rule CaseClause :words { # see 12.11 |
|---|
| 814 | <'case'> <Expression> <':'> <StatementList>? |
|---|
| 815 | } |
|---|
| 816 | rule DefaultClause :words { # see 12.11 |
|---|
| 817 | <'default'> <':'> <StatementList>? |
|---|
| 818 | } |
|---|
| 819 | rule LabelledStatement :words { # see 12.12 |
|---|
| 820 | <Identifier> <':'> <Statement> |
|---|
| 821 | } |
|---|
| 822 | rule ThrowStatement :words { # see 12.13 |
|---|
| 823 | <'throw'><no_LineTerminator_here><Expression> <';'> |
|---|
| 824 | } |
|---|
| 825 | rule TryStatement :words { # see 12.14 |
|---|
| 826 | <'try'> <Block> <Catch> |
|---|
| 827 | | <'try'> <Block> <Finally> |
|---|
| 828 | | <'try'> <Block> <Catch> <Finally> |
|---|
| 829 | } |
|---|
| 830 | rule Catch :words { # see 12.14 |
|---|
| 831 | <'catch'> <'('> <Identifier> <')'> <Block> |
|---|
| 832 | } |
|---|
| 833 | rule Finally :words { # see 12.14 |
|---|
| 834 | <'finally'> <Block> |
|---|
| 835 | } |
|---|
| 836 | |
|---|
| 837 | # A.5 Functions and Programs |
|---|
| 838 | |
|---|
| 839 | rule FunctionDeclaration :words { # see clause 13 |
|---|
| 840 | <'function'> <Identifier> <'('> <FormalParameterList>? <')'. <'{'> <FunctionBody> <'}'> |
|---|
| 841 | } |
|---|
| 842 | rule FunctionExpression :words { # see clause 13 |
|---|
| 843 | <'function'> <Identifier>? <'('> <FormalParameterList>? <')'> <'{'> <FunctionBody> <'}'> |
|---|
| 844 | } |
|---|
| 845 | rule FormalParameterList :words { # see clause 13 |
|---|
| 846 | <Identifier> |
|---|
| 847 | | <FormalParameterList> <','> <Identifier> |
|---|
| 848 | } |
|---|
| 849 | rule FunctionBody :words { # see clause 13 |
|---|
| 850 | <SourceElements> |
|---|
| 851 | } |
|---|
| 852 | rule Program :words { # see clause 14 |
|---|
| 853 | <SourceElements> |
|---|
| 854 | } |
|---|
| 855 | rule SourceElements :words { # see clause 14 |
|---|
| 856 | <SourceElement> |
|---|
| 857 | | <SourceElements> <SourceElement> |
|---|
| 858 | } |
|---|
| 859 | rule SourceElement :words { # see clause 14 |
|---|
| 860 | <Statement> <FunctionDeclaration> |
|---|
| 861 | } |
|---|
| 862 | |
|---|
| 863 | # A.6 Universal Resource Identifier Character Classes |
|---|
| 864 | |
|---|
| 865 | rule uri { # see 15.1.3 |
|---|
| 866 | <uriCharacters>? |
|---|
| 867 | } |
|---|
| 868 | rule uriCharacters { # see 15.1.3 |
|---|
| 869 | <uriCharacter> <uriCharacters>? |
|---|
| 870 | } |
|---|
| 871 | rule uriCharacter { # see 15.1.3 |
|---|
| 872 | <uriReserved> |
|---|
| 873 | | <uriUnescaped> |
|---|
| 874 | | <uriEscaped> |
|---|
| 875 | } |
|---|
| 876 | rule uriReserved { # see 15.1.3 |
|---|
| 877 | <';'> |
|---|
| 878 | | <'/'> |
|---|
| 879 | | <'?'> |
|---|
| 880 | | <':'> |
|---|
| 881 | | <'@'> |
|---|
| 882 | | <'&'> |
|---|
| 883 | | <'='> |
|---|
| 884 | | <'+'> |
|---|
| 885 | | <'$'> |
|---|
| 886 | | <','> |
|---|
| 887 | } |
|---|
| 888 | rule uriUnescaped { # see 15.1.3 |
|---|
| 889 | <uriAlpha> |
|---|
| 890 | | <DecimalDigit> |
|---|
| 891 | | <uriMark> |
|---|
| 892 | } |
|---|
| 893 | rule uriEscaped { # see 15.1.3 |
|---|
| 894 | <'%'> <HexDigit> <HexDigit> |
|---|
| 895 | } |
|---|
| 896 | rule uriAlpha { # see 15.1.3 |
|---|
| 897 | <[a..zA..Z]> |
|---|
| 898 | } |
|---|
| 899 | rule uriMark { # see 15.1.3 |
|---|
| 900 | <'-'> |
|---|
| 901 | | <'_'> |
|---|
| 902 | | <'.'> |
|---|
| 903 | | <'!'> |
|---|
| 904 | | <'~'> |
|---|
| 905 | | <'*'> |
|---|
| 906 | | <'\''> |
|---|
| 907 | | <'('> |
|---|
| 908 | | <')'> |
|---|
| 909 | } |
|---|
| 910 | |
|---|
| 911 | # A.7 Regular Expressions |
|---|
| 912 | |
|---|
| 913 | rule Pattern { # see 15.10.1 |
|---|
| 914 | <Disjunction> |
|---|
| 915 | } |
|---|
| 916 | rule Disjunction { # see 15.10.1 |
|---|
| 917 | <Alternative> |
|---|
| 918 | | <Alternative> <'|'> <Disjunction> |
|---|
| 919 | } |
|---|
| 920 | rule Alternative { # see 15.10.1 |
|---|
| 921 | <null> |
|---|
| 922 | | <Alternative> <Term> |
|---|
| 923 | } |
|---|
| 924 | rule Term { # see 15.10.1 |
|---|
| 925 | <Assertion> |
|---|
| 926 | | <Atom> |
|---|
| 927 | | <Atom> <Quantifier> |
|---|
| 928 | } |
|---|
| 929 | rule Assertion { # see 15.10.1 |
|---|
| 930 | <'^'> |
|---|
| 931 | | <'$'> |
|---|
| 932 | | <'\\'> <'b'> |
|---|
| 933 | | <'\\'> <'B'> |
|---|
| 934 | } |
|---|
| 935 | rule Quantifier { # see 15.10.1 |
|---|
| 936 | <QuantifierPrefix> |
|---|
| 937 | | <QuantifierPrefix> <'?'> |
|---|
| 938 | } |
|---|
| 939 | rule QuantifierPrefix { # see 15.10.1 |
|---|
| 940 | <'*'> |
|---|
| 941 | | <'+'> |
|---|
| 942 | | <'?'> |
|---|
| 943 | | <'{'> <DecimalDigits> <'}'> |
|---|
| 944 | | <'{'> <DecimalDigits> <',}'> |
|---|
| 945 | | <'{'> <DecimalDigits> <','> <DecimalDigits> <'}'> |
|---|
| 946 | } |
|---|
| 947 | rule Atom { # see 15.10.1 |
|---|
| 948 | <PatternCharacter> |
|---|
| 949 | | <'.'> |
|---|
| 950 | | <'\\'> <AtomEscape> |
|---|
| 951 | | <CharacterClass> |
|---|
| 952 | | <'('> <Disjunction> <')'> |
|---|
| 953 | | <'(?:'> <Disjunction> <')'> |
|---|
| 954 | | <'(?='> <Disjunction> <')'> |
|---|
| 955 | | <'(?!'> <Disjunction> <')'> |
|---|
| 956 | } |
|---|
| 957 | rule PatternCharacter { # see 15.10.1 |
|---|
| 958 | <-[^$\\.*+?()[\]{}|]> #SourceCharacter but not ... |
|---|
| 959 | } |
|---|
| 960 | rule AtomEscape { # see 15.10.1 |
|---|
| 961 | <DecimalEscape> |
|---|
| 962 | | <CharacterEscape> |
|---|
| 963 | | <CharacterClassEscape> |
|---|
| 964 | } |
|---|
| 965 | rule CharacterEscape { # see 15.10.1 |
|---|
| 966 | <ControlEscape> |
|---|
| 967 | | <'c'> <ControlLetter> |
|---|
| 968 | | <HexEscapeSequence> |
|---|
| 969 | | <UnicodeEscapeSequence> |
|---|
| 970 | | <IdentityEscape> |
|---|
| 971 | } |
|---|
| 972 | rule ControlEscape { # see 15.10.1 |
|---|
| 973 | <'f'> |
|---|
| 974 | | <'n'> |
|---|
| 975 | | <'r'> |
|---|
| 976 | | <'t'> |
|---|
| 977 | | <'v'> |
|---|
| 978 | } |
|---|
| 979 | rule ControlLetter { # see 15.10.1 |
|---|
| 980 | <[a..zA..Z]> |
|---|
| 981 | } |
|---|
| 982 | rule IdentityEscape { # see 15.10.1 |
|---|
| 983 | <!before <IdentifierPart>> <SourceCharacter> |
|---|
| 984 | } |
|---|
| 985 | rule DecimalEscape { # see 15.10.1 |
|---|
| 986 | <DecimalIntegerLiteral> <!before <DecimalDigit>> #lookahead |
|---|
| 987 | } |
|---|
| 988 | rule CharacterClass { # see 15.10.1 |
|---|
| 989 | <'['> <!before <'^'>> <ClassRanges> <']'> #lookahead |
|---|
| 990 | | <'[^'> <ClassRanges> <']'> |
|---|
| 991 | } |
|---|
| 992 | rule ClassRanges { # see 15.10.1 |
|---|
| 993 | <null> |
|---|
| 994 | | <NonemptyClassRanges> |
|---|
| 995 | } |
|---|
| 996 | rule NonemptyClassRanges { # see 15.10.1 |
|---|
| 997 | <ClassAtom> |
|---|
| 998 | | <ClassAtom> <NonemptyClassRangesNoDash> |
|---|
| 999 | | <ClassAtom> <'-'> <ClassAtom> <ClassRanges> |
|---|
| 1000 | } |
|---|
| 1001 | rule NonemptyClassRangesNoDash { # see 15.10.1 |
|---|
| 1002 | <ClassAtom> |
|---|
| 1003 | | <ClassAtomNoDash> <NonemptyClassRangesNoDash> |
|---|
| 1004 | | <ClassAtomNoDash> <'-'> <ClassAtom> <ClassRanges> |
|---|
| 1005 | } |
|---|
| 1006 | rule ClassAtom { # see 15.10.1 |
|---|
| 1007 | <'-'> |
|---|
| 1008 | | <ClassAtomNoDash> |
|---|
| 1009 | } |
|---|
| 1010 | rule ClassAtomNoDash { # see 15.10.1 |
|---|
| 1011 | <-[\\\]\-]> #SourceCharacter but not ... |
|---|
| 1012 | | <'\\'> |
|---|
| 1013 | | <ClassEscape> |
|---|
| 1014 | } |
|---|
| 1015 | rule ClassEscape { # see 15.10.1 |
|---|
| 1016 | <DecimalEscape> |
|---|
| 1017 | | <'b'> |
|---|
| 1018 | | <CharacterEscape> |
|---|
| 1019 | | <CharacterClassEscape> |
|---|
| 1020 | } |
|---|
| 1021 | |
|---|
| 1022 | |
|---|
| 1023 | |
|---|
| 1024 | grammar JavaScript::ECMAScript3::Grammar is JavaScript::ECMAScript3::Grammar::Spec; |
|---|
| 1025 | |
|---|
| 1026 | # Intended to be a working, usable grammar. |
|---|
| 1027 | # Unimplemented. |
|---|