?um/p1-90`ECMAScript
lexical input element의 identification이 input element를 consuming하는 syntactic grammar context에 sensitive한 여러 situation이 있습니다. 이는 lexical grammar에 대해 multiple
multiple lexical goal의 사용은 automatic semicolon insertion에 영향을 줄 lexical ambiguity가 없음을 ensure합니다. 예를 들어 leading division 또는 division-assignment와 leading
a = b
/hi/g.exec(c).map(d);
a = b / hi / g.exec(c).map(d);
Unicode format-control character(즉, LEFT-TO-RIGHT MARK 또는 RIGHT-TO-LEFT MARK 같은 Unicode Character Database의 category “Cf” 안의 character)는 이를 위한 higher-level protocol(mark-up language 등)이 없을 때 text range의 formatting을 control하는 데 사용되는 control code입니다.
editing과 display를 facilitate하기 위해 source text 안에서 format-control character를 allow하는 것은 useful합니다. 모든 format control character는 comment 안에서, 그리고 string literal, template literal, regular expression literal 안에서 사용될 수 있습니다.
U+FEFF (ZERO WIDTH NO-BREAK SPACE)는 primarily text의 start에서 그것을 Unicode로 mark하고 text의 encoding과 byte order의 detection을 allow하는 데 사용되는 format-control character입니다. 이 purpose로 intended된 <ZWNBSP> character는 때때로 text의 start 뒤에도 나타날 수 있습니다. 예를 들어 file을 concatenating한 result로 그렇습니다.
White space code point는 source text readability를 improve하고 token(indivisible lexical unit)을 서로 separate하는 데 사용되지만, otherwise insignificant합니다. White space code point는 어떤 두 token 사이에도, input의 start 또는 end에도 occur할 수 있습니다. White space code point는
ECMAScript white space code point는
| Code Points | Name | Abbreviation |
|---|---|---|
U+0009
|
CHARACTER TABULATION | <TAB> |
U+000B
|
LINE TABULATION | <VT> |
U+000C
|
FORM FEED (FF) | <FF> |
U+FEFF
|
ZERO WIDTH NO-BREAK SPACE | <ZWNBSP> |
| general category “Space_Separator” 안의 모든 code point | <USP> |
U+0020 (SPACE) 및 U+00A0 (NO-BREAK SPACE) code point는 <USP>의 part입니다.
white space code point와 마찬가지로, line terminator code point는 source text readability를 improve하고 token(indivisible lexical unit)을 서로 separate하는 데 사용됩니다. 그러나 white space code point와 달리, line terminator는 syntactic grammar의 behaviour에 어느 정도 influence를 가집니다. 일반적으로 line terminator는 어떤 두 token 사이에도 occur할 수 있지만, syntactic grammar에 의해 forbidden되는 몇몇 place가 있습니다. Line terminator는 automatic semicolon insertion(
line terminator는
Line terminator는 regular expression 안의 \s class가 match하는 white space code point의 set에 included됩니다.
ECMAScript line terminator code point는
| Code Point | Unicode Name | Abbreviation |
|---|---|---|
U+000A
|
LINE FEED (LF) | <LF> |
U+000D
|
CARRIAGE RETURN (CR) | <CR> |
U+2028
|
LINE SEPARATOR | <LS> |
U+2029
|
PARAGRAPH SEPARATOR | <PS> |
Comment는 single-line 또는 multi-line일 수 있습니다. Multi-line comment는 nest할 수 없습니다.
single-line comment는 // marker부터 line의 end까지의 모든 code point로 구성됩니다. 그러나 line end의
Comment는 white space처럼 behave하며 discarded됩니다. 단,
이 section의 여러 production은 section
Hashbang Comment는 location-sensitive이며 다른 type의 comment처럼 syntactic grammar를 위한 input element stream에서 discarded됩니다.
이 standard는 specific code point addition을 specify합니다: U+0024 (DOLLAR SIGN) 및 U+005F (LOW LINE)는
nonterminal
nonterminal _를 derive합니다.
Unicode property “ID_Start” 및 “ID_Continue”를 가진 code point의 set은 각각 Unicode property “Other_ID_Start” 및 “Other_ID_Continue”를 가진 code point를 포함합니다.
Unicode escape sequence는 \는 어떤 code point도 contribute하지 않습니다. \
Unicode Standard에 따라 canonically equivalent한 두
The
The
keyword는 fixed width font로 literally appear합니다. ECMAScript의 keyword에는 if, while, async, await 및 many others가 포함됩니다.
reserved word는 identifier로 사용할 수 없는 if와 while은 reserved word입니다. await는 async function과 module 안에서만 reserved됩니다. async는 reserved되지 않습니다; variable name 또는 statement label로 restriction 없이 사용할 수 있습니다.
이 명세는 어떤 name이 valid identifier이고 어떤 것이 reserved word인지 specify하기 위해 grammatical production과 await와 yield를 제외하고 unconditionally reserved됩니다. await와 yield에 대한 exception은 parameterized syntactic production을 사용하여
Math, window, toString, _처럼 always identifier로 allowed되고 keyword가 아닌 것;
identifier로 never allowed되지 않는 것, 즉 await와 yield를 제외하고 아래 listed된
contextually identifier로 allowed되는 것, 즉 await와 yield;
let, static, implements, interface, package, private, protected, public;
always identifier로 allowed되지만 as, async, from, get, meta, of, set, target.
conditional keyword 또는 contextual keyword라는 term은 때때로 last three category에 속해 일부 context에서는 identifier로, 다른 context에서는 keyword로 사용될 수 있는 keyword를 refer하는 데 사용됩니다.
\
\ els\u{65}라고 spelling하여 “else”라는 variable을 declare하는 것은 possible하지 않습니다.
enum은 이 명세에서 현재 keyword로 사용되지 않습니다. 이는 future language extension에서 keyword로 use하기 위해 set aside된 future reserved word입니다.
마찬가지로, implements, interface, package, private, protected, public은
예: 3in은 error이며 두 input element 3 및 in이 아닙니다.
numeric literal은
The
string literal은 single 또는 double quote로 enclosed된 0개 이상의 Unicode code point입니다. Unicode code point는 escape sequence로 represented될 수도 있습니다. closing quote code point, U+005C (REVERSE SOLIDUS), U+000D (CARRIAGE RETURN), U+000A (LINE FEED)를 제외한 모든 code point는 string literal에 literally appear할 수 있습니다. 어떤 code point든 escape sequence의 form으로 appear할 수 있습니다. String literal은 ECMAScript String value로 evaluate됩니다. 이러한 String value를 generating할 때 Unicode code point는
nonterminal
<LF> 및 <CR>은 empty code point sequence를 produce하는 \n 또는 \u000A 같은 escape sequence를 사용하는 것입니다.
string literal이 enclosing code를
function invalid() { "\7"; "use strict"; }
The
string literal은
| Escape Sequence | Code Unit Value | Unicode Character Name | Symbol |
|---|---|---|---|
\b
|
0x0008
|
BACKSPACE | <BS> |
\t
|
0x0009
|
CHARACTER TABULATION | <HT> |
\n
|
0x000A
|
LINE FEED (LF) | <LF> |
\v
|
0x000B
|
LINE TABULATION | <VT> |
\f
|
0x000C
|
FORM FEED (FF) | <FF> |
\r
|
0x000D
|
CARRIAGE RETURN (CR) | <CR> |
\"
|
0x0022
|
QUOTATION MARK |
"
|
\'
|
0x0027
|
APOSTROPHE |
'
|
\\
|
0x005C
|
REVERSE SOLIDUS |
\
|
regular expression literal은 literal이 evaluated될 때마다 RegExp object(===로 compare되는 regular expression object로 evaluate되지 않습니다. RegExp object는 runtime에 new RegExp에 의해 또는 RegExp
아래 production은 regular expression literal의 syntax를 describe하며 input element scanner가 regular expression literal의 end를 find하는 데 사용됩니다.
implementation은
Regular expression literal은 empty일 수 없습니다; empty regular expression literal을 represent하는 대신 code unit sequence //는 single-line comment를 start합니다. empty regular expression을 specify하려면 /(?:)/를 사용하십시오.
The
The
The
The
대부분의 ECMAScript statement와 declaration은 semicolon으로 terminated되어야 합니다. 그러한 semicolon은 source text에 항상 explicitly appear할 수 있습니다. 그러나 convenience를 위해, certain situation에서는 그러한 semicolon을 source text에서 omitted할 수 있습니다. 이러한 situation은 semicolon이 그 situation에서 source code token stream에 automatically inserted된다고 말함으로써 described됩니다.
다음 rule에서 “token”은 clause
semicolon insertion에는 세 가지 basic rule이 있습니다:
source text가 left to right로 parsed될 때, grammar의 어떤 production에도 allowed되지 않는 token(offending token이라고 함)이 encountered되면, 다음 condition 중 하나 이상이 true인 경우 semicolon이 offending token 앞에 automatically inserted됩니다:
}입니다.
)이고 inserted semicolon이 do-while statement(그러나 preceding rule에는 additional overriding condition이 있습니다: semicolon이 empty statement로 parsed될 경우 또는 그 semicolon이 for statement(
다음은 grammar 안의 only restricted production입니다:
이러한 restricted production의 practical effect는 다음과 같습니다:
++ 또는 -- 토큰을 만났고, 앞선 토큰과 ++ 또는 -- 토큰 사이에 하나 이상의 ++ 또는 -- 토큰 앞에 세미콜론이 자동으로 삽입된다.
using 토큰을 만났고 using 토큰 뒤에 세미콜론이 자동으로 삽입된다.
continue, break, return, throw 또는 yield 토큰을 만났고 다음 토큰 앞에서 continue, break, return, throw 또는 yield 토큰 뒤에 세미콜론이 자동으로 삽입된다.
=> 토큰 앞의 async 토큰 뒤에 function, ( 토큰 앞의 async 토큰은 뒤따르는 토큰들과 같은 표현식 또는 클래스 요소의 일부로 처리되지 않는다.
async 토큰 뒤에 * 토큰 앞의 그 결과 ECMAScript 프로그래머에게 주어지는 실질적인 조언은 다음과 같다:
++ 또는 -- 연산자는 그 피연산자와 같은 줄에 있어야 한다.
using 선언의 using 토큰과 같은 줄에서 시작해야 한다.
return 또는 throw 문에서의 yield 표현식에서의 return, throw 또는 yield 토큰과 같은 줄에서 시작해야 한다.
break 또는 continue 문에서의 break 또는 continue 토큰과 같은 줄에 있어야 한다.
=>는 같은 줄에 있어야 한다.
async 토큰은 바로 뒤따르는 토큰과 같은 줄에 있어야 한다.
source
{ 1 2 } 3
는 automatic semicolon insertion rule이 있어도 ECMAScript grammar에서 valid sentence가 아닙니다. 반대로, source
{ 1
2 } 3
역시 valid ECMAScript sentence는 아니지만, automatic semicolon insertion에 의해 다음으로 transformed됩니다:
{ 1
;2 ;} 3;
이는 valid ECMAScript sentence입니다.
source
for (a; b
)
는 valid ECMAScript sentence가 아니며, semicolon이 for statement의 header에 needed되기 때문에 automatic semicolon insertion에 의해 altered되지 않습니다. Automatic semicolon insertion은 for statement의 header 안의 두 semicolon 중 하나를 never inserts하지 않습니다.
source
return
a + b
는 automatic semicolon insertion에 의해 다음으로 transformed됩니다:
return;
a + b;
return과 expression a + b를 separate하기 때문에, expression a + b는 return statement에 의해 returned될 value로 treated되지 않습니다.
source
a = b
++c
는 automatic semicolon insertion에 의해 다음으로 transformed됩니다:
a = b;
++c;
b와 ++ 사이에 occur하기 때문에, token ++는 variable b에 applying되는 postfix operator로 treated되지 않습니다.
source
if (a > b)
else c = d
는 valid ECMAScript sentence가 아니며, grammar의 어떤 production도 그 point에 apply되지 않더라도, automatically inserted된 semicolon이 empty statement로 parsed될 것이기 때문에 else token 앞에서 automatic semicolon insertion에 의해 altered되지 않습니다.
source
a = b + c
(d + e).print()
는 not automatic semicolon insertion에 의해 transformed되지 않습니다. second line을 begin하는 parenthesized expression이 function call의 argument list로 interpreted될 수 있기 때문입니다:
a = b + c(d + e).print()
assignment statement가 left parenthesis로 begin해야 하는 circumstance에서는, programmer가 automatic semicolon insertion에 rely하기보다는 preceding statement의 end에 explicit semicolon을 provide하는 것이 good idea입니다.
ECMAScript program은 automatic semicolon insertion에 relying함으로써 very few semicolon을 가진 style로 written될 수 있습니다. 위에 described된 것처럼, semicolon은 every newline에 inserted되지 않으며, automatic semicolon insertion은 line terminator를 across하는 multiple token에 depend할 수 있습니다.
새 syntactic feature가 ECMAScript에 added됨에 따라, automatic semicolon insertion에 preceding하여 relying하는 line이 parsed될 때 grammar production을 change하게 하는 additional grammar production이 added될 수 있습니다.
이 section의 purpose상, automatic semicolon insertion의 case는 preceding source text에 따라 semicolon이 inserted될 수도 있고 inserted되지 않을 수도 있는 place이면 interesting하다고 considered됩니다. 이 section의 rest는 이 version의 ECMAScript에서 automatic semicolon insertion의 여러 interesting case를 describe합니다.
(). semicolon이 없으면 두 line은 together [). semicolon이 없으면 두 line은 `). semicolon이 없으면 두 line은 previous expression을 + 또는 -. semicolon이 없으면 두 line은 corresponding binary operator의 usage로 interpreted됩니다./ ECMAScript는 “[no
이 section의 rest는 이 version의 ECMAScript에서 “[no